Skip to content

vllm.v1.kv_offload.tiering.fs.manager

FileSystemTierManager: pure-Python filesystem tier for KV cache offloading.

Store path

Data is written to a temp file () via os.write, then os.replace'd to the final path (without .tmp).

Load path

Data is read from the block file directly via os.readv into the provided memoryview slice.

_r//_g/.bin

(hash-based subdirectories to limit directory fan-out)

Classes:

FileSystemTierManager

Bases: SecondaryTierManager

Pure-Python disk-backed secondary tier.

Read-priority threads service load jobs preferentially; write-priority threads service store jobs preferentially. Both groups can drain either queue, so neither starves.

submit_store / submit_load are non-blocking: they enqueue tasks and return. get_finished_jobs() polls job completion and returns completed JobResults.

Cross-process sharing

KV cache sharing between multiple vLLM instances using the same root_dir (e.g., via a shared PVC) works by default: NONE_HASH (the chain-hash seed for block content hashes) is derived from a fixed default seed, so identical token content produces identical block filenames across instances. Setting the PYTHONHASHSEED environment variable to the same value on all instances overrides the default seed, and is required to share a cache when using a non-cryptographic prefix-caching hash algorithm, which seeds NONE_HASH randomly.

Methods:

  • __init__ –

    Args:

  • drain_jobs –

    Block until all in-flight transfers in the threadpool finish.

  • get_finished_jobs –

    Collect finished jobs; a failed promotion marks only its failed keys

  • shutdown –

    Release resources held by this tier.

__init__(offloading_spec, primary_kv_view, tier_type, root_dir, n_read_threads=16, n_write_threads=16, enable_kv_events=False, locality=None, backpressure_detector=None, access_mode=OffloadAccessMode.READWRITE)

offloading_spec: Contains normalized offloading configuration and blocks_per_chunk. primary_kv_view: Memoryview of the primary tier's CPU KV cache. tier_type: Tier type identifier, set by SecondaryTierFactory. root_dir: Root directory for block files. n_read_threads: Number of read-priority I/O threads. n_write_threads: Number of write-priority I/O threads. enable_kv_events: Emit BlockStored KV events for blocks successfully stored to this tier. Effective only when KV cache events are enabled globally (kv_events_config). locality: Whether this tier's storage is LOCAL or REMOTE relative to the publishing vLLM instance. backpressure_detector: Optional backpressure detector. access_mode: read serves loads but never writes blocks, write writes blocks but never serves loads, and readwrite (default) does both.

drain_jobs()

Block until all in-flight transfers in the threadpool finish.

get_finished_jobs()

Collect finished jobs; a failed promotion marks only its failed keys as a miss here (scheduler thread).

shutdown()

Release resources held by this tier.

Shuts down the lookup manager and the thread pool, clearing pending tasks and waiting for active threads to complete.