vllm.v1.attention.backends.mamba2_attn
¶
Functions:
-
compute_varlen_chunk_metadata–Build chunk-aligned, variable-length metadata used by Mamba2 SSD kernels.
compute_varlen_chunk_metadata(query_start_loc, chunk_size)
¶
Build chunk-aligned, variable-length metadata used by Mamba2 SSD kernels.
Given per-sequence cumulative token starts query_start_loc of shape [B+1]
and a physical chunk_size, returns three tensors on the same device:
- cu_chunk_seqlens: (nchunks+1,) int32 exclusive prefix-sum of
logical-chunk lengths (each logical chunk never crosses a sequence or
physical-chunk boundary).
- last_chunk_indices: (B,) int32 index of the last logical chunk
for each sequence (=-1 for empty sequences).
- seq_idx_chunks: (nchunks,) int32 sequence index for each logical
chunk in order.
This is intentionally lightweight and CPU-side; it mirrors the metadata produced by the V1 Mamba2 meta-data builder and is exported so tests (and other callers) can avoid duplicating the logic.