vllm.v1.attention.backends.mla.indexer
¶
Classes:
-
DeepseekV32IndexerMetadataBuilder– -
KpoolTailBackend–Storage-only backend for the GLM-5.3-Flash kpool tail cache.
-
KpoolTailMetadataBuilder–Build only the circular slot mapping needed by the storage-only tail.
-
PCPGlobalChunkPlan–PCP packing for one indexer prefill chunk under PCP + DCP.
Functions:
-
build_pcp_global_chunk_plan–Plan the PCP packing for one chunk from its requests' KV shard rows.
-
compute_kpool_tail_slot_mapping–Map every token to its request's one circular tail block.
-
dense_logits_rows–Query rows per dense MQA-logits call whose fp32 [rows, max_seqlen_k]
-
dsa_indexer_uses_fp4–Whether the DeepSeek sparse indexer should use the MXFP4 K cache.
-
upload_shardq_indices–Gather indices on the device and query ranges renumbered over them.
DeepseekV32IndexerMetadataBuilder
¶
Bases: AttentionMetadataBuilder
Methods:
-
should_build_custom_decode_rows–Whether build() takes this step's flattened decode rows from
_build_decode_rows(common_attn_metadata, num_decodes, num_decode_tokens)
¶
Build a decode step's flattened rows when should_build_custom_decode_rows is True: write one row per decode token into decode_seq_lens_buffer (compressed lengths, padding rows 0), expanded_block_table_buffer and decode_lens_buffer, plus per_req_decode_lens_buffer, and return the (seq_lens, block_table, decode_lens) views for num_decode_tokens rows.
_prefill_split_seq_lens(seq_lens_cpu)
¶
Per-request KV lengths the prefill chunker budgets logits with; subclasses whose logits rows are wider than the context override.
_prepare_decode_tensors(seq_lens, block_table, decode_lens, decode_lens_cpu, query_start_loc, num_decodes, num_decode_tokens, use_native, next_n, max_decode_len)
¶
Prepare native or per-token flattened decode tensors.
_split_indexer_prefill_chunks(compressed_seq_lens_cpu, prefill_query_lens_cpu, workspace_size, max_logits_bytes, request_offset=0, fused_mqa_topk_eligible=False)
staticmethod
¶
Split this step's prefill requests into chunks, respecting: - N constraint: total_seq_lens <= workspace_size (existing O(N) workspace) - Logits constraint: M * N * 4 <= max_logits_bytes
When a single request-level chunk still exceeds the logits budget, sub-chunks on the query dimension (M) to bound peak memory.
With fused_mqa_topk_eligible (chunks for the fused MQA+top-k kernel,
which needs no logits buffer) chunks whose gathered keys fit
FUSED_MQA_TOPK_MAX_KEYS are bounded by FUSED_MQA_TOPK_MAX_ROWS rows
instead of the logits budget. Requests are never packed past that key
limit, so only a single request longer than it takes the logits-budget
path. Chunks the dispatch keeps dense are row-split by the indexer.
Returns list of (req_slice, query_slice) tuples.
_split_pcp_dcp_prefill_chunks(row_req_idx, row_shard_rows, row_query_lens_cpu, max_logits_bytes, request_offset)
¶
Chunk by request rather than by row, so a split prefill's two rows charge their shared context once, then widen each chunk back to rows.
row_shard_rows holds the whole request's largest DCP shard on
every row, so the plan is identical on every PCP rank.
should_build_custom_decode_rows(common_attn_metadata)
¶
Whether build() takes this step's flattened decode rows from _build_decode_rows instead of its default path. A builder that returns True overrides _build_decode_rows and returns False on varlen decode and DCP steps.
KpoolTailBackend
¶
Bases: DeepseekV32IndexerBackend
Storage-only backend for the GLM-5.3-Flash kpool tail cache.
KpoolTailMetadataBuilder
¶
Bases: AttentionMetadataBuilder
Build only the circular slot mapping needed by the storage-only tail.
PCPGlobalChunkPlan
dataclass
¶
PCP packing for one indexer prefill chunk under PCP + DCP.
_supports_native_decode(next_n)
¶
Whether decode can pass next_n Q rows per request to the kernel
instead of flattening to one single-token row per query, which re-reads
the KV tile once per row.
build_pcp_global_chunk_plan(row_req_idx, row_shard_rows, dcp_world_size, device, interleave=1)
¶
Plan the PCP packing for one chunk from its requests' KV shard rows.
The global layout is padded to shard rows x W per request. Positions
past a request's true extent lie beyond every token's causal bound, so
the kernel never reads them.
compute_kpool_tail_slot_mapping(slot_mapping, block_table, query_start_loc, positions, num_actual_tokens, num_reqs, kpool, out=None)
¶
Map every token to its request's one circular tail block.
dense_logits_rows(max_seqlen_k, max_logits_bytes=None)
¶
Query rows per dense MQA-logits call whose fp32 [rows, max_seqlen_k] logits fit max_logits_bytes (default: VLLM_SPARSE_INDEXER_MAX_LOGITS_MB).
The prefill chunk planner sub-chunks requests with it; the indexers split the rows of chunks planned for fused_mqa_topk (not bounded by the budget) that take the dense path.
dsa_indexer_uses_fp4(vllm_config)
¶
Whether the DeepSeek sparse indexer should use the MXFP4 K cache.
upload_shardq_indices(split, query_start_loc_cpu, device)
¶
Gather indices on the device and query ranges renumbered over them.
Fresh host memory each step: async scheduling builds the next step before this step's copy runs, which a reused pinned buffer would race with.