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_kv_cache_shape(
num_blocks: int,
block_size: int,
num_kv_heads: int,
head_size: int,
) -> tuple[int, ...]
Source code in vllm/v1/attention/backends/pallas.py
get_max_num_seqs
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
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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
kv_sharing_target_layer_name
instance-attribute
¶
__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,
kv_sharing_target_layer_name: Optional[int] = None,
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,
output_scale: 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
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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
|
PallasMetadata
dataclass
¶
Source code in vllm/v1/attention/backends/pallas.py
kv_cache_update_op_impl
¶
kv_cache_update_op_impl(
kv: Tensor,
slot_mapping: Tensor,
kv_cache: Tensor,
num_kv_update_slices: Tensor,
page_size: int,
num_slices_per_block: int,
)
Source code in vllm/v1/attention/backends/pallas.py
kv_cache_update_op_non_xla
¶
kv_cache_update_op_non_xla(
kv: Tensor,
slot_mapping: Tensor,
kv_cache: Tensor,
num_kv_update_slices: Tensor,
page_size: int,
num_slices_per_block: int,
) -> Tensor
Source code in vllm/v1/attention/backends/pallas.py
kv_cache_update_op_xla
¶
kv_cache_update_op_xla(
kv: Tensor,
slot_mapping: Tensor,
kv_cache: Tensor,
num_kv_update_slices: Tensor,
page_size: int,
num_slices_per_block: int,
) -> Tensor
Source code in vllm/v1/attention/backends/pallas.py
write_to_kv_cache
¶
write_to_kv_cache(
key: Tensor,
value: Tensor,
kv_cache: Tensor,
slot_mapping: Tensor,
num_slices_per_kv_cache_update_block: int,
num_kv_update_slices: Tensor,
) -> None
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 |
num_slices_per_kv_cache_update_block
|
int
|
int |
required |