A coding agent finishes a model call. Its conversation remains available, but its cached attention state competes with every other request for GPU memory. By the time the agent makes another call, that state may have been reclaimed.

CPU memory offers somewhere else to keep it. The next request could recover a matching prefix from RAM instead of computing it again. That sounds like a capacity improvement until several requests need their state back at once, the GPU has little free space, and transfers are still using buffers that the allocator would like to recycle.

My PagedAttention experiment counted allocation waste in token slots. The prefix-caching companion follows reuse across a coding agent’s calls. This post examines the next question: what must a serving engine coordinate when cached KV can live outside GPU memory?

This is a design walkthrough of the vLLM v0.30.0 OffloadingConnector, using its versioned documentation and source. The examples assume a CUDA worker and a model with full attention. I have not run an offloading benchmark; the timings below are illustrative arithmetic, and the final section specifies the experiment still needed.

What the CPU tier adds

vLLM’s offloading guide describes a connector that copies completed KV blocks into host memory and restores cached state to the GPU when needed. CPUOffloadingSpec provides the CPU tier; TieringOffloadingSpec adds further storage tiers. The attention computation in this path still consumes GPU-resident KV.

For this discussion, there are three useful outcomes for a matching prefix:

Available state Work still required before that state can be used
Ready on the GPU Acquire usable references to its blocks
Ready only in CPU memory Obtain GPU destination space, transfer the state, and establish completion
Unavailable in either cache Compute the missing state from the input

A request can also combine these cases: a leading portion on the GPU, a further portion recoverable from CPU, and a new suffix requiring prefill. Treating every cache hit as the same event hides those costs.

CPU caching can extend the lifetime of reusable state. It does not make the GPU working set unlimited: restored KV and the request’s subsequent growth still need accelerator memory.

Copying state does not immediately free its source

Consider a toy GPU pool holding four chunks: A1 and A2 belong to prefix A, while B1 and B2 are in use by another request. A chunk here means a unit transferred together; the drawing is a capacity example, not a vLLM trace.

Four memory snapshots showing prefix A copied to CPU, its GPU slots reused by C, and A later restored after B releases destination capacity

After A’s CPU copy completes, both copies can exist. The GPU copy becomes reclaimable only when nothing still needs it. Once A’s GPU slots have been reused by C, a later request for A must obtain other GPU space before loading the CPU copy. In the last snapshot, B has finished and supplied that space. The CPU copy remains cached.

This is the first design constraint I would track: capacity occupied by an unfinished transfer has a lifetime, even when the associated response has already finished.

Suppose a device-to-host copy is reading A1 while the allocator assigns A1’s physical GPU slot to C. If C overwrites the bytes too soon, the CPU cache receives invalid state. An asynchronous copy therefore needs an ownership rule that lasts through completion, rather than merely through submission.

The pinned vLLM offloading scheduler tracks transfer jobs and source-block fences. Its completion handling is the place to inspect before assuming that request completion makes all of its storage reusable. That machinery addresses the lifetime problem; it does not make an in-flight source buffer free capacity.

Admission and eviction answer different questions

An agent might read a large file once, while its instructions recur across dozens of calls. Copying both into CPU memory spends bandwidth now, but their chances of saving future work differ.

Admission decides whether to preserve newly available state in the CPU cache. Eviction selects existing state to remove when that cache needs space. A recency policy for eviction cannot recover bandwidth already spent saving material that was never reused.

In the pinned CPU manager, the storage path can filter candidates using an access-count threshold, removes already-present entries from the proposed store, and asks a cache policy for victims when necessary. The manager also tracks entries being written or read, so resident and evictable capacity are different quantities.

For the single CPU tier, I would record these configuration choices with every run:

Setting Why it changes the experiment
cpu_bytes_to_use Sets the total host-cache budget across workers
block_size or blocks_per_chunk Sets transfer granularity; larger units can change both I/O overhead and reusable boundaries
store_threshold Controls how readily eligible state is admitted
offload_prompt_only Determines whether generated-token blocks are eligible for offload too
eviction_policy Chooses which eligible CPU entries give up space

These names and their scopes come from the v0.30.0 configuration reference. They describe the offload tier; they should not be confused with the GPU allocator’s settings.

The prompt-only choice is especially relevant to an agent. A model’s tool call is generated output in one request and conversation input in the next. Excluding generated state from offload changes what may survive if its GPU copy disappears before the next request.

A cache lookup is not permission to read the bytes

A CPU entry can be known to the cache while its initial store is still in progress. A reload can likewise have an assigned GPU destination while the copy into it is incomplete. Neither state is ready for consumption.

The offloading-manager interface separates preparation from completion. Preparing a store reserves and protects destination state; completing it makes that state loadable. Loads have corresponding lifetime hooks.

The pinned CPU lookup returns HIT_PENDING when the entry exists but is not ready. The full-attention prefix lookup defers its result when it encounters that state. This distinguishes usable data from a copy still in progress. Whether waiting is cheaper than recomputation under load remains a performance question to measure.

Destination capacity needs the same care. A request waiting for a reload may have reserved GPU blocks that cannot yet contribute useful computation. Enough simultaneous reloads can tie up capacity that decode requests also need for growth. I would measure how much memory is ready, reserved for transfers, and reclaimable, alongside total occupancy.

Fetching competes with recomputation

For a CPU-only hit, a useful first approximation is:

time until fetched KV is usable ≈
    destination-capacity wait + transfer-queue wait
    + bytes / effective transfer bandwidth + completion overhead

Recomputation has its own queueing and GPU execution cost. The comparison must use the same missing prefix and include the resources each path delays. Neither nominal link bandwidth nor an isolated prefill timing captures a loaded service.

Here is deliberately hypothetical arithmetic. Suppose a prefix occupies 512 MiB and the available transfer bandwidth is 16 GiB/s. Copying those bytes takes 31.25 ms before other overhead. If recomputation would take 80 ms under the same conditions, fetching has room to help. Add a 60 ms transfer-queue wait, and the fetch path already takes at least 91.25 ms.

These are chosen numbers to expose the decision, not measurements of hardware or vLLM. Actual overlap can change the result: some transfers may run alongside other useful work, while contention can delay work elsewhere.

I would also count the earlier GPU-to-CPU copy. A prefix loaded once required a store before that load. A prefix never loaded spent transfer bandwidth and CPU capacity without avoiding any later computation. Saving time on one request and improving the service as a whole are separate measurements.

Edge cases that change the design

An asynchronous transfer API does not, on its own, specify all recovery behavior. The pinned offloading worker’s completion loop contains this check, with bookkeeping omitted here:

for transfer_result in self.worker.get_finished():
    assert transfer_result.success

That is evidence against assuming this path transparently recomputes after an arbitrary transfer failure. A missing cache entry and a failed in-flight transfer are different cases. The former leaves the original input available for ordinary computation; recovery from the latter needs an explicit implementation contract.

These are the other cases I would put in a trace before treating the cache as operationally understood:

Situation Question the trace needs to answer
A request is cancelled during reload When are its destination blocks and CPU read references released?
CPU capacity is full of entries still involved in transfers The manager can refuse a store when it cannot reclaim enough entries. How does the caller handle that, and can unrelated requests progress?
Many requests ask for one cold GPU prefix How much transfer and destination allocation is shared, and how much is duplicated?
Different prefixes arrive in a burst Does reload traffic delay active decode or only the new requests?
An agent compacts its conversation Which initial chunks remain reusable, and how much saved tail state never gets read again?
A request reaches another worker Can that worker access compatible state, or must it recompute?

For the final case, CPU caching within one worker should not be mistaken for a shared cluster cache. Making state accessible elsewhere introduces another placement and transfer problem. Cache identity also has to cover the model and layout that produced the bytes; matching visible text is insufficient.

The experiment I would run next

I would start with one GPU, one worker, a fixed model revision, and a scripted agent conversation. Each turn would append a known suffix. A second trace would compact the conversation while preserving a stable opening. This keeps prefix matching controlled before introducing transfer contention.

The comparison would use the same GPU KV budget and workload, with GPU prefix caching enabled in both runs. CPU offloading would be the treatment. Engine warmup would be completed separately from cache conditioning, and cache state would be established deliberately for each case.

Case How to establish it What it isolates
Cold input Use a previously unseen prefix Cost of filling caches
GPU hit Repeat immediately and verify GPU reuse Reuse without a reload
CPU hit Introduce unrelated work until the GPU copy is reclaimed; verify the CPU entry survives Recovery through the host tier
Miss after pressure Drive both copies out, then repeat Recomputation after eviction
Burst of CPU hits Request several host-resident prefixes together Transfer queues and destination pressure
Compacted conversation Replace the suffix after a known boundary Partial reuse and retention of obsolete history

Elapsed idle time alone would not establish a CPU hit. I would need evidence that the GPU copy was absent and that bytes actually moved from CPU to GPU for the request.

For each case, I would record cached tokens by tier where instrumentation exposes them, bytes stored and loaded, transfer duration and queueing, GPU and CPU occupancy, and time to first token. Under concurrency, I would also record the time between generated tokens for requests already decoding, plus latency percentiles and completed requests within a stated latency target. Missing counters would be identified as instrumentation gaps.

The result manifest would include the exact vLLM build, connector configuration, model and tokenizer revisions, KV dtype, GPU, host-memory configuration, interconnect, prompt token IDs, arrival schedule, and cache-conditioning procedure. A GPU environment is required for those timings; the allocation simulation does not substitute for them.

The question I want that experiment to settle is whether preserving a prefix saves enough future work to justify its storage and movement under the chosen workload. CPU capacity makes retention possible. Buffer lifetimes, transfer queues, and admission policy determine how useful that retention becomes.