[Bugfix] GLM-5.3-Flash: fp8 plan dtype on SM90 sparse MLA, and right-size the indexer prefill workspace (#55222)
Signed-off-by: Mikhail Kostryukov <mike@triptrack.net> Signed-off-by: NickLucche <nicolo.lucchesi@mistral.ai> Co-authored-by: Mikhail Kostryukov <drakosha81@proton.me> Co-authored-by: NickLucche <nicolo.lucchesi@mistral.ai>
This commit is contained in:
co-authored by
Mikhail Kostryukov
NickLucche
parent
50239dfc4d
commit
c37f86e572
@@ -312,7 +312,9 @@ class Indexer(nn.Module):
|
||||
self.prefix = prefix
|
||||
from vllm.v1.attention.backends.mla.indexer import get_max_prefill_buffer_size
|
||||
|
||||
self.max_total_seq_len = get_max_prefill_buffer_size(vllm_config)
|
||||
self.max_total_seq_len = (
|
||||
get_max_prefill_buffer_size(vllm_config) // self.index_kpool
|
||||
)
|
||||
self.indexer_op = SparseAttnIndexerKpool(
|
||||
self.k_cache,
|
||||
self.quant_block_size,
|
||||
|
||||
@@ -443,10 +443,16 @@ class FlashInferMLASparseSM90Builder(FlashInferMLASparseMetadataBuilder):
|
||||
assert topk_indices_buffer is not None
|
||||
hf_config = vllm_config.model_config.hf_text_config
|
||||
assert hf_config.index_topk is not None
|
||||
# fp8 KV cache is stored as uint8; plan() needs the logical dtype.
|
||||
kv_plan_dtype = (
|
||||
torch.float8_e4m3fn
|
||||
if kv_cache_spec.dtype == torch.uint8
|
||||
else kv_cache_spec.dtype
|
||||
)
|
||||
self.state = _SM90State(
|
||||
device,
|
||||
impl.num_heads,
|
||||
kv_cache_spec.dtype,
|
||||
kv_plan_dtype,
|
||||
vllm_config.scheduler_config.max_num_batched_tokens,
|
||||
topk_indices_buffer.shape[1],
|
||||
kv_lora_rank=impl.kv_lora_rank,
|
||||
|
||||
@@ -901,8 +901,17 @@ class DeepseekV32IndexerMetadataBuilder(AttentionMetadataBuilder):
|
||||
self.use_pcp = self.pcp_world_size > 1
|
||||
self.pcp_rank = get_pcp_group().rank_in_group if self.use_pcp else 0
|
||||
self.cp_kv_cache_interleave_size = parallel_config.cp_kv_cache_interleave_size
|
||||
# KV compression (DeepseekV4). Default to 1 for no compression.
|
||||
self.compress_ratio = 1
|
||||
if isinstance(self.kv_cache_spec, MLAAttentionSpec):
|
||||
assert isinstance(self.kv_cache_spec.tokens_per_state, int)
|
||||
self.compress_ratio = self.kv_cache_spec.tokens_per_state
|
||||
# NOTE(Chen):an estimated max size of flattened_kv. Need to double check.
|
||||
self.max_prefill_buffer_size = get_max_prefill_buffer_size(self.vllm_config)
|
||||
# Counted in compressed rows, like the chunker's seq_lens and the
|
||||
# workspace.
|
||||
self.max_prefill_buffer_size = (
|
||||
get_max_prefill_buffer_size(self.vllm_config) // self.compress_ratio
|
||||
)
|
||||
self.num_speculative_tokens = (
|
||||
self.vllm_config.speculative_config.num_speculative_tokens
|
||||
if self.vllm_config.speculative_config
|
||||
@@ -984,14 +993,6 @@ class DeepseekV32IndexerMetadataBuilder(AttentionMetadataBuilder):
|
||||
(self.num_sms + 1, 2), dtype=torch.int32, device=self.device
|
||||
)
|
||||
|
||||
# KV compression. Default to 1 for no compression.
|
||||
self.compress_ratio = 1
|
||||
# Get compress_ratio for DeepseekV4 support
|
||||
if isinstance(self.kv_cache_spec, MLAAttentionSpec):
|
||||
# MLA compression is a whole number of tokens per state (fractions
|
||||
# are whisper block pooling and never reach MLA).
|
||||
assert isinstance(self.kv_cache_spec.tokens_per_state, int)
|
||||
self.compress_ratio = self.kv_cache_spec.tokens_per_state
|
||||
if self.dcp_world_size > 1 and self.compress_ratio > 1:
|
||||
raise NotImplementedError(
|
||||
"DCP is not supported with sparse indexer KV compression "
|
||||
|
||||
Reference in New Issue
Block a user