vllm.model_executor.layers.sparse_mqa_indexer
¶
Sparse Attention Indexer that scores only the candidate blocks.
DeepSeek V4.1 two-level selection: the candidate-source indexer publishes
the top candidate blocks and later indexers pick their top-k inside them.
SparseAttnIndexer does that by computing dense logits over the whole
context and masking; this layer instead calls DeepGEMM's sparse MQA-logits
kernels on the candidate blocks only, so the work is O(candidate blocks)
instead of O(context). It requires the DeepseekV41SparseIndexerBackend
metadata (see AttentionConfig.indexer_sparse_logits).
Classes:
-
SparseMQAIndexer–Candidate-consuming indexer on DeepGEMM's sparse MQA-logits kernels.
SparseMQAIndexer
¶
Bases: Module
Candidate-consuming indexer on DeepGEMM's sparse MQA-logits kernels.
Only valid for indexer layers that read candidate blocks on SM100, with
the FP8 or the MXFP4 indexer cache. The K cache is written by the model
before this runs; forward takes the same arguments as
SparseAttnIndexer so the attention layer can call either.
Attributes:
-
weights_dtype–Per-head weights dtype the sparse kernels take. The fused Q RoPE-quant
weights_dtype = torch.bfloat16
class-attribute
instance-attribute
¶
Per-head weights dtype the sparse kernels take. The fused Q RoPE-quant
kernel writes it directly on the MXFP4 cache; on the FP8 cache it emits
fp32 (Q scale folded in) and forward casts.
_reserve_workspaces(device)
¶
Profiling run: claim the K-gather workspace and the peak sparse logits allocation so the memory estimate covers them.
_gather_prefill_chunk_k(kv_cache, k_quant_full, k_scale_full, chunk)
¶
Gather one prefill chunk's paged K into the packed workspace.
_prefill_k_workspaces(total_seq_lens, head_dim, use_fp4_cache)
¶
The K-gather workspace (values, scales) of the indexer cache
format, shared with the dense indexer layers of the same model.