vllm.v1.attention.selector ¶
Functions:
-
get_attn_backend–Selects which attention backend to use and lazily imports it.
-
get_attn_spec_kind–Derive the KV-cache group kind a layer belongs to from its signals.
-
get_mamba_attn_backend–Select which mamba attention backend to use and lazily import it.
get_attn_backend(head_size, dtype, kv_cache_dtype, use_mla=False, has_sink=False, use_sparse=False, use_mm_prefix=False, use_per_head_quant_scales=False, attn_type=None, num_heads=None, has_sliding_window=False) ¶
Selects which attention backend to use and lazily imports it.
Source code in vllm/v1/attention/selector.py
get_attn_spec_kind(use_mla, has_sliding_window, attn_type) ¶
Derive the KV-cache group kind a layer belongs to from its signals.
Mirrors get_kv_cache_spec_kind (which derives the kind from the produced KVCacheSpec) so users can target groups by kind when setting AttentionConfig.backend_per_kind.
SINK_FULL_ATTENTION is intentionally not derived here: it is produced only by the StaticSinkAttention layer, whereas a plain Attention layer with attention sinks (e.g. gpt-oss) still yields a FullAttentionSpec/SlidingWindowSpec. Sinks therefore do not change the kind.
Parameters:
-
(use_mla¶bool) –Whether the layer uses multi-head latent attention.
-
(has_sliding_window¶bool) –Whether the layer applies a sliding window.
-
(attn_type¶str) –The layer's
AttentionType.
Returns:
-
KVCacheSpecKind–The
KVCacheSpecKindthe layer maps to.
Source code in vllm/v1/attention/selector.py
get_mamba_attn_backend(mamba_type) ¶
Select which mamba attention backend to use and lazily import it.