vllm.v1.simple_kv_offload.manager
¶
Scheduler-side manager for SimpleCPUOffloadConnector.
Classes:
-
BlockStoreMeta–Per-block metadata snapshot for BlockStored event emission.
-
BoundaryStoreStats–Cumulative counters for boundary hand-off stores.
-
SimpleCPUOffloadScheduler–Scheduler-side manager for CPU offloading.
BlockStoreMeta
dataclass
¶
Per-block metadata snapshot for BlockStored event emission.
Captured at store-prep time (when the Request is available) and carried through TransferMeta to async completion, where the Request is gone.
BoundaryStoreStats
dataclass
¶
Cumulative counters for boundary hand-off stores.
Every branch that declines a hand-off is silent by design: the boundary is
simply not offloaded and a later request misses. Without counters the only
symptom is a lower cache hit rate with nothing in the logs, so each decline
reason is counted and exposed through
SimpleCPUOffloadConnector.get_boundary_store_stats(). Reset by
reset(), which carries any not-yet-drained deltas; not otherwise
cleared.
SimpleCPUOffloadScheduler
¶
Scheduler-side manager for CPU offloading.
Methods:
-
bind_gpu_block_pool–Bind GPU block pool so that we can touch blocks during stores.
-
get_num_new_matched_tokens–Return (num_new_tokens, is_async) from consecutive CPU cache hits.
-
get_stats–Drain per-step stats for the connector's stats hooks.
-
has_pending_stores–Return True if a store transfer is queued or in flight.
-
prepare_store_specs–Prepare store specs for the store event.
-
request_finished–Always returns (False, None). GPU blocks are protected by ref_cnt,
-
reset–Abandon pending transfers and reset the CPU cache when safe.
-
update_connector_output–Handle async transfer completions from worker.
_cached_gpu_block(resolved_hashes, block_idx, group_id)
¶
Return the GPU block still cached under this group's block hash.
_cleanup_load_request(req_id)
¶
Release all load resources for a request.
Shared between request_finished() and update_connector_output() paths. Removes the request from _reqs_to_load, cleans up event mappings, and frees CPU/GPU touch refs.
Returns the number of blocks in the load if it had been issued to the worker, else 0 (never-issued loads are not counted as completed by the caller).
_cleanup_store_request(req_id)
¶
Release store metadata for a request.
Metadata-only cleanup but no block freeing. Job completion handles block caching and GPU ref freeing via _process_store_completion().
_derive_cpu_config(gpu_config, cpu_capacity_bytes, num_cpu_blocks=None)
staticmethod
¶
Derive a CPU KVCacheConfig from the GPU config. Same kv_cache_groups, num_blocks scaled by CPU/GPU memory ratio.
An explicit num_cpu_blocks is checked against local capacity.
_estimate_lazy_target_blocks(kv_cache_config, max_num_batched_tokens, cp_world_size=1)
staticmethod
¶
GPU blocks to keep available (free/offloaded) per step in lazy mode.
_find_partial_tail_source(request, block_ids, group_idx)
¶
Locate one group's prompt-tail block for a fine-grained hit.
Mirrors FullAttentionManager._cache_partial_tail_block: only the
final prompt hash boundary is eligible, and boundaries that land on a
physical block edge are already covered by the positional scan.
Attention block tables are append-only, so the block is located positionally, as the mooncake store and offloading connector also do; no new core hand-off is required. The boundary key is registered at completion along with the block's other hashes, so nothing has to be captured here.
Groups that never key a prompt tail are filtered by the registered-key check below. Prefix-cached Mamba tables are not positional; their tail arrives through the boundary-state hand-off instead.
_free_pending_cpu_hit(pending)
¶
Release the temporary CPU block pin taken in get_num_new_matched_tokens().
_prepare_eager_store_specs(scheduler_output)
¶
Identify newly computed blocks to offload from scheduler requests.
Only considers blocks whose KV data has been confirmed computed by the GPU. Blocks from the current step are stored on a later step, or by the finish-time flush if the request completes first.
Returns:
_prepare_lazy_store_specs()
¶
Offload cached GPU blocks near eviction.
Walks the GPU free queue from its head, counting blocks that are free-or-offloaded (safe for the allocator to evict). Stops when target_free blocks are covered or CPU capacity is reached.
_process_store_completion(gpu_block_ids, cpu_block_ids, block_meta=None)
¶
Register copied blocks in the CPU prefix cache and release refs.
_process_store_event(event_idx)
¶
Process a fully-completed store event.
_queue_finished_eager_store(request, block_ids)
¶
Queue confirmed eager blocks omitted after a request enters decode.
_release_transfer_refs(transfer)
¶
Release transfer refs without making copied data cacheable.
_requeue_cpu_prefix(request, max_length=None)
¶
Requeue the CPU prefix a lookup of request would hit as most recent.
Stores land in prefix order and an admission-time requeue ages while the request runs, but a lookup stops at the first missing block. Requeue the hit tail first, as the GPU KV cache manager frees blocks, so the eviction takes the end of a prefix before its start.
_select_eager_blocks_to_store(state, block_ids_by_group)
¶
Return confirmed eager blocks, cursor advances, and event metadata.
bind_gpu_block_pool(gpu_block_pool)
¶
Bind GPU block pool so that we can touch blocks during stores. Called by Scheduler after kv_cache_manager is ready.
get_num_new_matched_tokens(request, num_computed_tokens)
¶
Return (num_new_tokens, is_async) from consecutive CPU cache hits.
get_stats()
¶
Drain per-step stats for the connector's stats hooks.
has_pending_stores()
¶
Return True if a store transfer is queued or in flight.
prepare_store_specs(scheduler_output)
¶
Prepare store specs for the store event.
request_finished(request, block_ids)
¶
Always returns (False, None). GPU blocks are protected by ref_cnt, so the scheduler can free blocks immediately.
reset()
¶
Abandon pending transfers and reset the CPU cache when safe.
Worker-side DMA may still be using blocks after reset is requested. Keep those block refs pinned until the existing completion path reports the transfer finished, then release refs without caching abandoned store results.
update_connector_output(connector_output)
¶
Handle async transfer completions from worker.
Load completions arrive via finished_recving (real req_ids). Store completions arrive via kv_connector_worker_meta as per-event worker counts. We accumulate across steps and process a store event only when all workers have reported completion.