vllm_gaudi.v1.kv_offload.worker.cpu_hpu
¶
Transfer
dataclass
¶
Source code in vllm_gaudi/v1/kv_offload/worker/cpu_hpu.py
CpuGpuOffloadingHandlers_init_
¶
CpuGpuOffloadingHandlers_init_(
self,
gpu_block_size: int,
cpu_block_size: int,
num_cpu_blocks: int,
gpu_caches: dict[str, Tensor],
attn_backends: dict[str, type[AttentionBackend]],
)
Source code in vllm_gaudi/v1/kv_offload/worker/cpu_hpu.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
SingleDirectionOffloadingHandler_init_
¶
SingleDirectionOffloadingHandler_init_(
self,
src_tensors: list[Tensor],
dst_tensors: list[Tensor],
src_block_size_factor: int,
dst_block_size_factor: int,
)
Initialize a SingleDirectionOffloadingHandler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_tensors
|
list[Tensor]
|
list of KV cache tensors to copy from. |
required |
dst_tensors
|
list[Tensor]
|
list of KV cache tensors to copy to. Order should match src_tensors. |
required |
src_block_size_factor
|
int
|
The number of kernel blocks per KV block in a source tensor. |
required |
dst_block_size_factor
|
int
|
The number of kernel blocks per KV block in a destination tensor. |
required |
Source code in vllm_gaudi/v1/kv_offload/worker/cpu_hpu.py
expand_block_ids
¶
expand_block_ids(
block_ids: ndarray,
block_size_factor: int,
output: ndarray,
skip_count: int = 0,
)
Convert a list of block IDs to a list of matching block ids, assuming each block is composed of actual block_size_factor blocks. Outputs to output tensor. The first skip_count blocks will be skipped. Note that skip_count must be less than block_size_factor.
For example, if block_ids = [0, 1, 3] and block_size_factor = 4, then it yields [0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 14, 15] since 0 maps to [0, 1, 2, 3] 1 maps to [4, 5, 6, 7] and 3 maps to [12, 13, 14, 15]
Source code in vllm_gaudi/v1/kv_offload/worker/cpu_hpu.py
get_handlers
¶
get_handlers(
self,
kv_caches: dict[str, Tensor],
attn_backends: dict[str, type[AttentionBackend]],
) -> Iterator[
tuple[
type[LoadStoreSpec],
type[LoadStoreSpec],
OffloadingHandler,
]
]
Source code in vllm_gaudi/v1/kv_offload/worker/cpu_hpu.py
swap_blocks
¶
swap_blocks(
src_kv_caches: tuple[Tensor, Tensor, Tensor, Tensor],
dst_kv_caches: tuple[Tensor, Tensor, Tensor, Tensor],
src_to_dsts: Tensor,
direction: Literal["h2d", "d2h"],
block_size: int = 128,
) -> None
Copy kv blocks between different buffers.