vllm.v1.attention.backends.gdn_attn
¶
Backend for GatedDeltaNet attention.
Classes:
Functions:
-
build_flashinfer_kda_checkpoint_plan–Build the FlashInfer CuTe DSL KDA checkpoint plan for all non-spec rows.
-
plan_flashinfer_checkpoints–Lay out internal checkpoints as FlashInfer prefill kernels emit them.
GDNAttentionMetadataBuilder
¶
Bases: AttentionMetadataBuilder[GDNAttentionMetadata]
Methods:
-
build_for_cudagraph_capture–This method builds the metadata for full cudagraph capture.
-
update_block_table–Re-gather this group's state indices. The other fields are
_check_chunk_metadata_override(builder_cls, backend)
staticmethod
¶
Reject a subclass whose chunk metadata the AITER path would skip.
AITER brings its own varlen prefill metadata and never calls
_build_chunk_metadata, so a builder that overrides it would lose
that override without a word. No in-tree subclass can get here --
_resolve_gdn_prefill_backend only selects this backend for models
with 128-dim GDN key and value heads, which the KDA builders are not --
but a future one should be told rather than quietly ignored.
_stage_decode(num_prefills, num_decodes, num_spec_decodes)
¶
Whether decode metadata goes into the FULL cudagraph buffers.
_stage_spec_decode(num_prefills, num_decodes, num_spec_decodes, num_spec_decode_tokens)
¶
Whether spec-decode metadata goes into the FULL cudagraph buffers.
build_for_cudagraph_capture(common_attn_metadata)
¶
This method builds the metadata for full cudagraph capture. Currently, only decode is supported for full cudagraphs with Mamba.
update_block_table(metadata, blk_table, slot_mapping)
¶
Re-gather this group's state indices. The other fields are
batch-level and stay shared with metadata.
build_flashinfer_kda_checkpoint_plan(checkpoint, device)
¶
Build the FlashInfer CuTe DSL KDA checkpoint plan for all non-spec rows.
CuTe DSL KDA requires int64 checkpoint_cu_starts and non-None int32
checkpoint_state_indices to use completed-boundary (floor(seq_len / N))
indexing excluding the initial state.
plan_flashinfer_checkpoints(offsets, query_lens, *, always_return_slots=False)
¶
Lay out internal checkpoints as FlashInfer prefill kernels emit them.
The interval (gcd of the offsets) can emit states no row uses; slots
skips writing them. Slots rule out GDN's CP route, so they are returned
only when needed unless always_return_slots is set.
Parameters:
-
(offsets¶list[int]) –Checkpoint offset into each checkpoint row's query, 0 for none. The last
len(query_lens)rows are the prefill kernel's. -
(query_lens¶list[int]) –Query length of each sequence the prefill kernel runs.
-
(always_return_slots¶bool, default:False) –Always return
slotseven when every emitted state is used (required by FlashInfer's CuTe DSL KDA kernel).
Returns:
-
int–(every_n_tokens, cu_starts, rows, slots): the interval, cumulative -
list[int]–per-sequence counts of emitted states, each checkpoint row's buffer
-
list[int]–row, and each emitted state's buffer row (-1: skipped), or None when
-
list[int] | None–every emitted state is used and
always_return_slotsis False.