Skip to content

vllm.v1.simple_kv_offload.sizing

Shared sizing helpers for SimpleCPUOffloadConnector.

Functions:

  • num_offload_blocks –

    How many blocks of the pipeline stage with the largest blocks fit in

num_offload_blocks(kv_cache_config, capacity_bytes, bytes_per_block)

How many blocks of the pipeline stage with the largest blocks fit in capacity_bytes; without pipeline_stages, blocks of bytes_per_block.

Source code in vllm/v1/simple_kv_offload/sizing.py
def num_offload_blocks(
    kv_cache_config: KVCacheConfig, capacity_bytes: int, bytes_per_block: int
) -> int:
    """How many blocks of the pipeline stage with the largest blocks fit in
    `capacity_bytes`; without `pipeline_stages`, blocks of `bytes_per_block`."""
    largest = max(
        (stage.bytes_per_block for stage in kv_cache_config.pipeline_stages),
        default=bytes_per_block,
    )
    return max(1, capacity_bytes // largest)