vllm.v1.attention.backends.mla.sparse_indexer
¶
DeepSeek V4.1 indexer backend for the DeepGEMM sparse MQA-logits path.
Candidate-consuming indexer layers score only the candidate blocks published
by the candidate-source layer (fp8_fp4_(paged_)sparse_mqa_logits) instead
of dense logits over the whole context. This backend extends the dense
indexer metadata with the per-row scratch that path needs, so the layer op
allocates nothing per step, and lets all consumer layers of a step share one
candidate expansion and DeepGEMM schedule (they all read the same candidate
blocks). Opt in with AttentionConfig.indexer_sparse_logits.
Classes:
-
DeepseekV41SparseIndexerMetadata– -
DeepseekV41SparseIndexerMetadataBuilder–Dense indexer metadata plus the sparse-logits row scratch.
-
SparseMQARowsMetadata–Per-row state for one sparse-logits call: the decode rows, or one
DeepseekV41SparseIndexerMetadata
dataclass
¶
Bases: DeepseekV32IndexerMetadata
Attributes:
-
sparse_prefill(list[SparseMQARowsMetadata] | None) –Parallel to
prefill.chunks.
Source code in vllm/v1/attention/backends/mla/sparse_indexer.py
sparse_prefill = None
class-attribute
instance-attribute
¶
Parallel to prefill.chunks.
DeepseekV41SparseIndexerMetadataBuilder
¶
Bases: DeepseekV32IndexerMetadataBuilder
Dense indexer metadata plus the sparse-logits row scratch.
Every requirement of the sparse kernels is checked here, at engine start, rather than falling back to the dense path per step.
Source code in vllm/v1/attention/backends/mla/sparse_indexer.py
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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
SparseMQARowsMetadata
dataclass
¶
Per-row state for one sparse-logits call: the decode rows, or one prefill chunk. Buffers are builder-owned views sized to the rows.
kernel_metadata (the DeepGEMM schedule) is filled by the first
consumer indexer layer of the step together with sparse_indices /
end; later consumer layers reuse all three.
Attributes:
-
block_table(Tensor | None) –Decode only: [rows, pages] per-row page table.
-
col_indices(Tensor) –[rows, topk] int32 scratch for the sparse-column top-k.
-
end(Tensor) –[rows] int32 valid sparse-column count per row.
-
row_indices(Tensor | None) –Decode only: [rows] row -> request index.
-
row_ke(Tensor) –[rows] int32 K-range end (prefill) or compressed context length.
-
row_ks(Tensor) –[rows] int32 K-range start per row; zeros for paged decode.
-
sparse_indices(Tensor) –[rows, num_sparse_blocks] int32 DeepGEMM sparse block ids.
Source code in vllm/v1/attention/backends/mla/sparse_indexer.py
block_table = None
class-attribute
instance-attribute
¶
Decode only: [rows, pages] per-row page table.
col_indices
instance-attribute
¶
[rows, topk] int32 scratch for the sparse-column top-k.
end
instance-attribute
¶
[rows] int32 valid sparse-column count per row.
row_indices = None
class-attribute
instance-attribute
¶
Decode only: [rows] row -> request index.
row_ke
instance-attribute
¶
[rows] int32 K-range end (prefill) or compressed context length.
row_ks
instance-attribute
¶
[rows] int32 K-range start per row; zeros for paged decode.
sparse_indices
instance-attribute
¶
[rows, num_sparse_blocks] int32 DeepGEMM sparse block ids.