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.
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_kind (which derives the kind from the layer's
KV cache manager config and spec) 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 uses the full-attention or
sliding-window manager. 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.
get_mamba_attn_backend(mamba_type)
¶
Select which mamba attention backend to use and lazily import it.