vllm.v1.attention.backends.pallas
PallasAttentionBackend
¶
Bases: AttentionBackend
Source code in vllm/v1/attention/backends/pallas.py
get_impl_cls
staticmethod
¶
get_impl_cls() -> type[PallasAttentionBackendImpl]
get_kv_cache_shape
staticmethod
¶
get_metadata_cls
staticmethod
¶
get_metadata_cls() -> type[PallasMetadata]
get_min_page_size
staticmethod
¶
get_min_page_size(vllm_config: VllmConfig) -> int
Source code in vllm/v1/attention/backends/pallas.py
get_page_size
staticmethod
¶
get_page_size(vllm_config: VllmConfig) -> int
get_state_cls
staticmethod
¶
get_state_cls() -> type[CommonAttentionState]
swap_blocks
staticmethod
¶
PallasAttentionBackendImpl
¶
Bases: AttentionImpl
Source code in vllm/v1/attention/backends/pallas.py
101 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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
__init__
¶
__init__(
num_heads: int,
head_size: int,
scale: float,
num_kv_heads: int,
alibi_slopes: Optional[list[float]],
sliding_window: Optional[int],
kv_cache_dtype: str,
blocksparse_params: Optional[dict[str, Any]] = None,
logits_soft_cap: Optional[float] = None,
attn_type: str = DECODER,
use_irope: bool = False,
) -> None
Source code in vllm/v1/attention/backends/pallas.py
forward
¶
forward(
layer: AttentionLayer,
query: Tensor,
key: Tensor,
value: Tensor,
kv_cache: Tensor,
attn_metadata: PallasMetadata,
output: Optional[Tensor] = None,
) -> Tensor
Forward pass with Pallas attention.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
Tensor
|
shape = [num_tokens, num_heads * head_size] |
required |
key
|
Tensor
|
shape = [num_tokens, num_kv_heads * head_size] |
required |
value
|
Tensor
|
shape = [num_tokens, num_kv_heads * head_size] |
required |
attn_metadata
|
PallasMetadata
|
Metadata for attention. |
required |
Returns: shape = [num_tokens, num_heads * head_size]
Source code in vllm/v1/attention/backends/pallas.py
PallasMetadata
dataclass
¶
Source code in vllm/v1/attention/backends/pallas.py
write_to_kv_cache
¶
Write the key and values to the KV cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Tensor
|
shape = [num_tokens, num_kv_heads * head_size] |
required |
value
|
Tensor
|
shape = [num_tokens, num_kv_heads * head_size] |
required |