vllm.v1.attention.backends.mla.rocm_aiter_mla_sparse
¶
Classes:
Functions:
-
fit_kpool_indices_to_aiter–Keep the live kpool tail while fitting AITER's fixed top-k width.
-
merge_dcp_scores–Merge rank-major score candidates into this rank's physical CSR slots.
-
triton_convert_req_index_to_global_index–out[token_id, indice_id] =
ROCMAiterMLASparseImpl
¶
Bases: SparseMLACommonImpl[ROCMAiterMLASparseMetadata]
_attn_sink(q)
¶
Returns the sinks for the heads of q.
_forward_mla_aiter(layer, q, kv_c_and_k_pe_cache, attn_metadata)
¶
_forward_mla on aiter's Triton sparse MLA kernel.
Reads the same index stream, but needs no q head padding and no persistent metadata, and its launch depends on shapes only, so it is CUDA-graph capturable.
ROCMAiterMLASparseMetadataBuilder
dataclass
¶
Bases: SparseMLACommonMetadataBuilder[ROCMAiterMLASparseMetadata]
_build_shardq_metadata(metadata)
¶
Narrows the paged KV fields to this rank's ShardQ tokens.
_sparse_decode_max_split(max_seq_len)
¶
Cap max_split_per_batch for the aiter sparse-MLA decode reduce.
The reduce only covers the selected tokens per row (<= topk_tokens),
so aiter's default (-1 => split across every CU) over-fragments it.
Mirror triton_mla.py: aim for a minimum work per split, round to a
power of two, and cap by the CU count. Numerics are unchanged.
_aiter_uses_persistent_mla_decode(num_tokens, num_heads, q_dtype, kv_dtype)
¶
AITER ignores persistent metadata for some gfx950 BF16 16-head batches.
_compact_dcp_indices(indices, counts=None)
¶
Preserve each row's valid slot order while removing invalid KV entries.
Parameters:
-
(indices¶Tensor) –Per-row KV rows, where
-1marks an invalid entry. -
(counts¶Tensor | None, default:None) –Optional per-row count of valid entries, which must then be a prefix of the row. Pass it to save the separate prefix sum.
Returns:
_index_epoch(buf, owns_indexer)
¶
Number of indexer writes up to and including this layer.
_use_rocm_sparse_triton(*, kv_cache_dtype, head_size, kv_lora_rank, num_prefills, num_decodes, num_decode_tokens, max_query_len)
¶
Select the rope-free BF16 path not supported by AITER sparse MLA.
The ragged Triton kernel indexes metadata per query token, so multi-token speculative verification rows have the same capability requirements as plain decode rows.
_use_triton_long_bf16_prefill(kv_dtype, metadata)
¶
Only gfx942 routes long pure BF16 prefills to Triton.
Other archs must keep persistent AITER metadata for these batches.
fit_kpool_indices_to_aiter(token_indices, topk_tokens)
¶
Keep the live kpool tail while fitting AITER's fixed top-k width.
merge_dcp_scores(scores, local_indices, token_block_table, rank, world_size, page_size, block_stride_rows)
¶
Merge rank-major score candidates into this rank's physical CSR slots.
Same selection as aiter flydsl_dcp_topk_merge: the global top-k by
score, ties at the k-th score taken in rank-major position order.
triton_convert_req_index_to_global_index(req_id, block_table, token_indices, cu_seqlens, paged_kv_indices, BLOCK_STRIDE_ROWS, BLOCK_SIZE=64, NUM_TOPK_TOKENS=2048, BLOCK_N=128)
¶
out[token_id, indice_id] = block_table[req_id[token_id], token_indices[token_id, indice_id] // BLOCK_SIZE] * BLOCK_STRIDE_ROWS + token_indices[token_id, indice_id] % BLOCK_SIZE
Only when token_indices[token_id, indice_id] == -1 do we output -1. For safety, we also output -1 if the derived block_id would be out-of-bounds.