vllm.v1.attention.backends.cpu_attn
¶
Classes:
CPUAttentionBackend
¶
Bases: AttentionBackend
Methods:
-
supports_attn_type–CPU attention supports decoder,
supports_attn_type(attn_type)
classmethod
¶
CPU attention supports decoder, encoder-only and encoder-decoder attention.
CPUAttentionBackendImpl
¶
Bases: AttentionImpl
Methods:
-
forward–Forward pass for CPU attention backend.
forward(layer, query, key, value, kv_cache, attn_metadata, output, output_scale=None, output_block_scale=None)
¶
Forward pass for CPU attention backend.
Parameters:
-
(layer¶AttentionLayer) –The attention layer, providing the q/k/v quantization scales.
-
(query¶Tensor) –shape = [num_tokens, num_heads, head_size]
-
(key¶Tensor) –shape = [num_tokens, num_kv_heads, head_size]
-
(value¶Tensor) –shape = [num_tokens, num_kv_heads, head_size]
-
(kv_cache¶Tensor) –shape = [num_blocks, num_kv_heads, block_size, 2 * head_size]
-
(attn_metadata¶CPUAttentionMetadata | None) –Metadata for attention.
-
(output¶Tensor) –Tensor that the attention result is written into.
-
(output_scale¶Tensor | None, default:None) –Scale for fused output quantization; not supported by this backend.
-
(output_block_scale¶Tensor | None, default:None) –Block scale for fused output quantization; not supported by this backend.
Returns:
-
Tensor–shape = [num_tokens, num_heads * head_size]
CPUAttentionMetadataBuilder
¶
Bases: AttentionMetadataBuilder[CPUAttentionMetadata]
_group_sliding_window()
¶
The window shared by every layer in this group, else -1 (no window).
Taken from the layers rather than the group spec: one KV cache group can hold both windowed and global layers (e.g. Gemma-3 with the hybrid KV cache manager disabled), and the scheduler metadata built here is shared by the whole group, so it may only assume a window all of them agree on.
_riscv_supports_rvv()
cached
¶
Whether the C++ RVV attention path is usable.
The kernel in csrc/cpu/cpu_attn_rvv.hpp uses VLEN-agnostic RVVI()
macros and supports VLEN=128 and VLEN=256. CMake auto-detects the
largest zvl