[Bugfix][MLA] Read sparse model settings from text config (#56160)

Signed-off-by: Andy Lo <andy@mistral.ai>
This commit is contained in:
Andy Lo
2026-09-11 18:02:13 +00:00
committed by GitHub
parent 6fe67cbbf3
commit dc07f1638f
11 changed files with 32 additions and 22 deletions
@@ -173,7 +173,7 @@ class PackDCPTopkCandidatesKernel(
if dcp_world_size <= 1:
return []
cp_interleave = vllm_config.parallel_config.cp_kv_cache_interleave_size
topk = vllm_config.model_config.hf_config.index_topk
topk = vllm_config.model_config.hf_text_config.index_topk
if topk <= 0:
return []
@@ -546,7 +546,7 @@ class StableTopKFromGatheredCandidatesKernel(
dcp_world_size = vllm_config.parallel_config.decode_context_parallel_size
if dcp_world_size <= 1:
return []
topk = vllm_config.model_config.hf_config.index_topk
topk = vllm_config.model_config.hf_text_config.index_topk
if topk <= 0:
return []
return self._trace_dispatch(self.dispatch)(
@@ -132,7 +132,7 @@ class SparseMLACommonMetadataBuilder(AttentionMetadataBuilder[T]):
self.device = device
self.model_config = vllm_config.model_config
self.mla_dims = get_mla_dims(self.model_config)
self.topk_tokens: int = vllm_config.model_config.hf_config.index_topk
self.topk_tokens: int = vllm_config.model_config.hf_text_config.index_topk
self.req_id_per_token_buffer = torch.empty(
(vllm_config.scheduler_config.max_num_batched_tokens,),
dtype=torch.int32,
@@ -202,7 +202,7 @@ class SparseMLACommonMetadataBuilder(AttentionMetadataBuilder[T]):
scheduler_config = vllm_config.scheduler_config
cache_config = vllm_config.cache_config
model_config = vllm_config.model_config
topk_tokens = model_config.hf_config.index_topk
topk_tokens = model_config.hf_text_config.index_topk
workspace_size = min(
max(
@@ -97,10 +97,10 @@ class CompressedSlotMappingKernel(
)
def get_warmup_keys(self, vllm_config: Any) -> list[CompileKey]:
hf_config = vllm_config.model_config.hf_config
hf_text_config = vllm_config.model_config.hf_text_config
configured_ratios = (
*(getattr(hf_config, "compress_ratios", None) or ()),
getattr(hf_config, "index_kpool", 1) or 1,
*(getattr(hf_text_config, "compress_ratios", None) or ()),
getattr(hf_text_config, "index_kpool", 1) or 1,
)
compress_ratios = tuple(
dict.fromkeys(int(ratio) for ratio in configured_ratios if int(ratio) > 1)
@@ -99,8 +99,8 @@ class FlashAttnMLASparseBackend(AttentionBackend):
if vllm_config.parallel_config.decode_context_parallel_size > 1:
return "FlashAttention MLA Sparse does not support DCP for now"
hf_config = vllm_config.model_config.hf_config
if not hasattr(hf_config, "index_topk"):
hf_text_config = vllm_config.model_config.hf_text_config
if not hasattr(hf_text_config, "index_topk"):
return "FlashAttention MLA Sparse requires model with index_topk"
return None
+4 -4
View File
@@ -396,7 +396,7 @@ class BuildPrefillChunkMetadataKernel(
def get_warmup_keys(self, vllm_config: VllmConfig) -> list[CompileKey]:
max_tokens = max(1, min(vllm_config.scheduler_config.max_num_batched_tokens, 8))
hf_config = vllm_config.model_config.hf_config
hf_text_config = vllm_config.model_config.hf_text_config
parallel_config = vllm_config.parallel_config
dcp_world = parallel_config.decode_context_parallel_size
dcp_interleave = parallel_config.cp_kv_cache_interleave_size
@@ -405,12 +405,12 @@ class BuildPrefillChunkMetadataKernel(
dict.fromkeys(
max(1, int(ratio))
for ratio in (
*(getattr(hf_config, "compress_ratios", None) or (1,)),
getattr(hf_config, "index_kpool", 1) or 1,
*(getattr(hf_text_config, "compress_ratios", None) or (1,)),
getattr(hf_text_config, "index_kpool", 1) or 1,
)
)
)
index_kpool = getattr(hf_config, "index_kpool", None)
index_kpool = getattr(hf_text_config, "index_kpool", None)
if index_kpool and index_kpool > 1 and index_kpool not in compress_ratios:
compress_ratios = compress_ratios + (index_kpool,)
return self._trace_dispatch(self.dispatch)(
@@ -435,7 +435,7 @@ class ROCMAiterMLASparseMetadataBuilder(
self.num_heads = self.model_config.get_num_attention_heads(parallel_config)
self.mla_dims = get_mla_dims(self.model_config)
self.topk_tokens = vllm_config.model_config.hf_config.index_topk
self.topk_tokens = vllm_config.model_config.hf_text_config.index_topk
attention_context = vllm_config.compilation_config.static_forward_context
# Sink decode must use AITER's nonpersistent path. In particular,
# gfx942 has no persistent+LSE kernel, and its metadata heuristic
@@ -232,7 +232,7 @@ class ConvertReqIndexToGlobalIndexKernel(
dcp_size = vllm_config.parallel_config.decode_context_parallel_size
dcp_interleave = vllm_config.parallel_config.cp_kv_cache_interleave_size
dcp_rank = get_dcp_group().rank_in_group if dcp_size > 1 else 0
num_topk_tokens = vllm_config.model_config.hf_config.index_topk
num_topk_tokens = vllm_config.model_config.hf_text_config.index_topk
max_num_blocks = cdiv(
vllm_config.model_config.max_model_len,
block_size * dcp_size,
@@ -128,7 +128,7 @@ class XPUMLASparseMetadataBuilder(AttentionMetadataBuilder[XPUMLASparseMetadata]
self.num_heads = self.model_config.get_num_attention_heads(parallel_config)
self.mla_dims = get_mla_dims(self.model_config)
self.topk_tokens = vllm_config.model_config.hf_config.index_topk
self.topk_tokens = vllm_config.model_config.hf_text_config.index_topk
self.topk_tokens_tensor = torch.tensor(
[self.topk_tokens], device=device, dtype=torch.int32
)