vllm.models.deepseek_v41.amd.ops.sparse_indexer
¶
The sparse indexer layer of DeepSeek-V4.1 with --monokernel on gfx942.
The layer runs vLLM's ROCm indexer op, rocm_aiter_sparse_attn_indexer, on every step except a step of only decode rows. Such a step runs the decode path of that op here, with the gfx942 launches of topk.py in front of vLLM's logits, candidate selection, candidate mask and top-k. Each launch returns False for a call that it cannot take, and then vLLM's op at that place runs. The model takes this layer only with --monokernel on gfx942 (DeepseekV41ROCMAiterMLAAttention._indexer_cls in rocm.py).
Classes:
-
Gfx942SparseAttnIndexer–vLLM's sparse indexer layer, whose HIP path runs
Functions:
-
gfx942_sparse_attn_indexer–rocm_aiter_sparse_attn_indexer with the same arguments, whose steps of
Gfx942SparseAttnIndexer
¶
Bases: SparseAttnIndexer
vLLM's sparse indexer layer, whose HIP path runs gfx942_sparse_attn_indexer in place of vLLM's ROCm op.
Source code in vllm/models/deepseek_v41/amd/ops/sparse_indexer.py
_decode_step(meta, num_tokens, kv_cache, q_fp8, weights, topk_tokens, max_model_len, topk_indices_buffer, compress_ratio, candidate_blocks, candidate_block_size, candidate_write)
¶
The decode path of rocm_aiter_sparse_attn_indexer, for a step of only decode rows whose K cache the model already wrote, with the gfx942 launches of topk.py in front of vLLM's ops.
Source code in vllm/models/deepseek_v41/amd/ops/sparse_indexer.py
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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
_decode_top_k(logits, meta, next_n, topk_indices, topk_tokens, compress_ratio, max_model_len)
¶
The decode top-k of vLLM's op: AITER's indexer top-k where AITER takes the call, and otherwise the gfx942 top-512 of topk.decode_top_k or, when that returns False, vLLM's top_k_per_row_decode.
Source code in vllm/models/deepseek_v41/amd/ops/sparse_indexer.py
_row_bounds(seq_lens, num_rows, next_n)
¶
The zero row starts and the int64 row ends that vLLM's candidate kernels take. Only the branches that run those kernels make them, so a layer whose call a gfx942 launch takes saves these two launches.
Source code in vllm/models/deepseek_v41/amd/ops/sparse_indexer.py
gfx942_sparse_attn_indexer(hidden_states, k_cache_prefix, kv_cache, q_fp8, k, weights, quant_block_size, scale_fmt, topk_tokens, head_dim, max_model_len, total_seq_lens, topk_indices_buffer, skip_k_cache_insert=False, compress_ratio=1, candidate_blocks=None, candidate_block_size=0, candidate_write=False)
¶
rocm_aiter_sparse_attn_indexer with the same arguments, whose steps of only decode rows run _decode_step. The profiling run, prefill and mixed steps, a layer that writes its own K cache and a process without --monokernel on gfx942 run vLLM's op unchanged.
Like vLLM's op, this is a break of a breakable CUDA graph capture. Its Python runs again at every replay, so the choice between the two paths is made for each step and not once at capture.