Skip to content

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 dataclass

Bases: DeepseekV32IndexerMetadata

Attributes:

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.

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.

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.