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 with the MXFP4
indexer cache on SM100. 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
Source code in vllm/model_executor/layers/sparse_mqa_indexer.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
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 so no cast runs per step.
_reserve_workspaces(device)
¶
Profiling run: claim the K-gather workspace and the peak sparse logits allocation so the memory estimate covers them.
Source code in vllm/model_executor/layers/sparse_mqa_indexer.py
_gather_prefill_chunk_k(kv_cache, k_quant_full, k_scale_full, chunk)
¶
Gather one prefill chunk's paged K into the packed workspace.
Source code in vllm/model_executor/layers/sparse_mqa_indexer.py
_prefill_k_workspaces(total_seq_lens, head_dim)
¶
The packed MXFP4 K-gather workspace (values, scales), shared with
the dense indexer layers of the same model.