Skip to content

vllm.v1.simple_kv_offload.worker

Worker-side handler for SimpleCPUOffloadConnector.

Classes:

SimpleCPUOffloadWorker

Worker-side handler for CPU offloading transfers.

Methods:

_alloc_cpu_caches(unique_gpu_caches, pin_memory)

Carve per-layer caches out of one mapping, pinned in bounded chunks.

_flush_and_sync_all()

Synchronize all in-flight transfer events.

_poll_stream_events(is_store)

Non-blocking poll for completed events and return the high-water mark.

build_connector_worker_meta()

Return completed store events since the last call.

get_finished(finished_req_ids)

Report completed transfer events to the scheduler.

Loads are submitted in start_load_kv() and stores in wait_for_save().

Returns:

  • set[str] | None –

    tuple of (finished_sending, finished_recving).

  • set[str] | None –
    • finished_sending: always None (stores use worker metadata).
  • tuple[set[str] | None, set[str] | None] –
    • finished_recving: req_ids whose loads have completed.

handle_preemptions(kv_connector_metadata)

Sync all in-flight transfers before preempted blocks are reused.

register_kv_caches(kv_caches)

Register GPU KV caches and allocate pinned CPU tensors. The worker will infer the underlying raw storage from the kv_caches.

Parameters:

  • kv_caches

    (dict[str, Tensor]) –

    Per-layer GPU KV caches. Values are either a single tensor (attention layers) or a list of tensors (Mamba layers in hybrid models). All values are included for offloading by resolving to their underlying raw storage.

shutdown()

Stop the copy thread and unregister the pinned CPU caches.

An in-process engine frees the host mapping without exiting, so a later registration can land on the same addresses. Never raises: it runs on the worker teardown path.

wait_for_save()

Submit async stores.

Stores (GPU->CPU) read the live KV cache, which the compute stream may still be writing under v1 overlapped execution, so they are ordered after a compute-done event recorded on the current stream. See

45704 for the bug and #39306 for the srcAccessOrder rationale.