[Config] Unify indexer cache dtype under attention_config.indexer_kv_dtype (#52550)

Signed-off-by: Yongye Zhu <zyy1102000@gmail.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yongye Zhu
2026-08-17 10:20:04 +08:00
committed by GitHub
co-authored by Claude Opus 5
parent 0ad04cff1b
commit 967e104fad
6 changed files with 65 additions and 24 deletions
+24 -13
View File
@@ -40,6 +40,28 @@ from vllm.v1.kv_cache_interface import KVCacheSpec, MLAAttentionSpec
logger = init_logger(__name__)
# The DSA indexer K cache is always quantized; "auto" means fp8 (V3.2 layout)
# and mxfp4 is the opt-in Blackwell path.
DSA_INDEXER_KV_DTYPES = ("fp8", "mxfp4")
def dsa_indexer_uses_fp4(vllm_config: VllmConfig) -> bool:
"""Whether the DeepSeek sparse indexer should use the MXFP4 K cache."""
kv_dtype = vllm_config.attention_config.resolve_indexer_kv_dtype("fp8")
if kv_dtype not in DSA_INDEXER_KV_DTYPES:
raise ValueError(
f"indexer_kv_dtype={kv_dtype!r} is not supported by the DeepSeek "
f"sparse indexer (expected one of {DSA_INDEXER_KV_DTYPES})."
)
use_fp4 = kv_dtype == "mxfp4"
if use_fp4 and not current_platform.is_device_capability_family(100):
raise ValueError(
"indexer_kv_dtype='mxfp4' requires Blackwell datacenter GPUs "
"(sm_10x, e.g. B200/GB200); sm_120 (consumer Blackwell) and "
"earlier architectures are not supported."
)
return use_fp4
@triton.jit
def _prepare_uniform_decode_kernel(
@@ -526,18 +548,7 @@ class DeepseekV32IndexerMetadataBuilder(AttentionMetadataBuilder):
if self.vllm_config.speculative_config
else 0
)
self.use_fp4_indexer_cache = (
self.vllm_config.attention_config.use_fp4_indexer_cache
)
assert (
current_platform.is_device_capability_family(100)
or not self.use_fp4_indexer_cache
), (
"use_fp4_indexer_cache requires Blackwell datacenter GPUs "
"(sm_10x, e.g. B200/GB200); sm_120 (consumer Blackwell) and "
"earlier architectures are not supported."
)
self.use_fp4_indexer_cache = dsa_indexer_uses_fp4(self.vllm_config)
next_n = self.num_speculative_tokens + 1
self.decode_threshold = next_n
@@ -546,7 +557,7 @@ class DeepseekV32IndexerMetadataBuilder(AttentionMetadataBuilder):
self.supports_varlen = _supports_varlen_paged_mqa_logits()
logger.info_once(
"DSA indexer decode path: use_flattening=%s supports_varlen=%s "
"(next_n=%d, use_fp4_indexer_cache=%s)",
"(next_n=%d, use_fp4_cache=%s)",
self.use_flattening,
self.supports_varlen,
next_n,