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
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
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.