vllm.v1.attention.backends.triton_attn_diffkv
¶
Triton attention backend with different K/V head dimensions (DiffKV).
The KV cache layout is identical to FlashAttentionDiffKVBackend: K and V
are packed along the last dim in the logical shape
[num_blocks, num_kv_heads, block_size, head_size_qk + head_size_v].
Classes:
-
TritonAttentionDiffKVImpl–Triton attention impl for the DiffKV packed KV cache layout.
-
TritonAttentionDiffKVMetadataBuilder–Override the parent's softmax buffer last-dim to head_size_v.
TritonAttentionDiffKVImpl
¶
Bases: TritonAttentionImpl
Triton attention impl for the DiffKV packed KV cache layout.
Methods:
-
forward–Forward pass.
forward(layer, query, key, value, kv_cache, attn_metadata, output, output_scale=None, output_block_scale=None)
¶
Forward pass.
Shapes
query: [num_tokens, num_heads, head_size_qk] key: [num_tokens, num_kv_heads, head_size_qk] value: [num_tokens, num_kv_heads, head_size_v] kv_cache: [num_blocks, num_kv_heads, block_size, head_size_qk + head_size_v] output: [num_tokens, num_heads, head_size_v]
TritonAttentionDiffKVMetadataBuilder
¶
Bases: TritonAttentionMetadataBuilder
Override the parent's softmax buffer last-dim to head_size_v.
The parent allocates softmax_segm_output with last-dim sized to
next_power_of_2(head_size) (== Q/K head size). For DiffKV the
accumulator and per-segment partial outputs are V-shaped, so we
re-allocate with next_power_of_2(head_size_v) instead.