Explainer
KV cache offload: where the cache goes when GPU memory runs out
KV cache offloading to CPU memory, SSD and remote stores: how much prefix reuse public traces hold, the bandwidth where reloading beats recomputing, and how vLLM, LMCache, SGLang HiCache and Dynamo offload.
- LLM inference
- KV cache
- KV cache offload
- GPU infrastructure
An engine keeps each request's keys and values in GPU memory so that it never reads the same prompt twice. When that memory fills, it evicts old blocks. A later request that needed them must compute them again. Offload gives those blocks a place to go instead: host memory, a local SSD, or a store on the network. It turns a capacity problem into a bandwidth problem.
I wanted two numbers that the usual advice leaves out. How much reuse does real traffic hold, and how much of it fits on a GPU? And how fast must a tier be before reloading a prefix beats computing it again? I replayed three public traces, two sampled from production and one synthetic, through a prefix cache of every size, from one GPU's memory to unlimited. Then I computed the break-even bandwidth for seven models with the formulas behind the KV cache calculator.
A cache the size that one H100 gives Qwen3-8B, about 377,000 tokens, holds an eighth of the reuse in the chat trace. And for most models, reloading a long prefix from host memory or a fast drive beats recomputing it, until several GPUs share that tier's bandwidth.
Hover a part to see its nameHow much reuse is there to keep?
Start with the ceiling. If the cache never evicted anything, what share of prompt tokens would it serve? I call that the oracle hit rate. No prefix cache does better, so it tells you how much any offload tier can win.
Mooncake, the serving platform for Moonshot AI's Kimi chatbot, published three traces with its FAST '25 paper. Two are sampled from one hour of its online requests. The third is built from public datasets, with arrivals drawn at random. Each request lists its arrival time, its lengths, and a hash for each 512-token block of its prompt. Two requests with the same first hashes share a prefix. I replayed each trace in arrival order through one shared cache that evicts the least recently used block. A request hits the longest run of blocks from its start that the cache still holds.
| Trace | Requests | Mean prompt | Distinct prompt tokens | Oracle hit rate |
|---|---|---|---|---|
| Conversation, one hour | 12,031 | 12,035 | 93.6 million | 37.4% |
| Tool and agent, one hour | 23,608 | 8,596 | 93.8 million | 57.1% |
| Synthetic multi-turn from public datasets, 17 minutes | 3,993 | 15,325 | 22.5 million | 65.1% |
What matters more is how fast the hit rate falls when the cache is smaller than the traffic. To put a GPU on that scale, take Qwen3-8B on one H100. vLLM lets itself use 90% of the 80 GB by default. After 16.4 GB of weights, at most about 55 GB is left for the cache: room for about 377,000 tokens at 144 KiB each. One H200 holds about 749,000.
These are cache sizes, not deployments. The chat trace sends about 41,000 prompt tokens per second, more than one H100 can prefill for Qwen3-8B, and Kimi does not serve Qwen3-8B. Read each size as one shared cache in front of all the traffic.
| Cache size, tokens | Chat | Tool and agent | Synthetic, public datasets |
|---|---|---|---|
| 377K: one H100 | 4.4% | 35.0% | 6.8% |
| 749K: one H200 | 4.8% | 35.4% | 11.7% |
| 2M | 8.6% | 38.1% | 23.2% |
| 6.8M: 1 TB of host memory | 24.7% | 49.8% | 49.7% |
| 13.6M: 2 TB of host memory | 32.1% | 54.9% | 62.4% |
| 20M | 35.8% | 56.8% | 65.1% |
| No limit | 37.4% | 57.1% | 65.1% |
The three workloads bend in different places. Agent traffic sends the same context again within seconds, so a cache the size of one GPU already serves 35% of its prompt tokens, 61% of what is possible. Chat traffic comes back after minutes, when the user reads and replies. The hit rate stays under 9% until the cache holds 2 million tokens, then climbs to 32% at 13.6 million. The synthetic multi-turn trace climbs steadily the whole way.
That bend is the first knee. Below it, the GPU's own cache is enough, and offload has little to add. Above it, the GPU throws away reuse that the traffic offers, and every miss is a prefill the GPU runs again. A second knee comes when the next tier fills too. For this chat trace, 1 TB of host memory, if all of it holds KV, fits 6.8 million Qwen3-8B tokens and serves 24.7%. 2 TB serves 32.1%. Everything past that needs an SSD or a remote store.
How many bytes is that?
A token count becomes bytes through the per-token size of each model, which the KV cache essay derives. The chat trace reaches 96% of its oracle at 20 million tokens.
| Model | Attention | Bytes per token | 20 million tokens |
|---|---|---|---|
| Llama-2-7B | MHA | 524,288 | 10.5 TB |
| Qwen3-8B | GQA | 147,456 | 2.95 TB |
| Qwen3-30B-A3B | GQA, mixture of experts | 98,304 | 1.97 TB |
| DeepSeek-V3 | MLA | 70,272 | 1.41 TB |
| gpt-oss-120b | Alternating sliding window | 36,864 | 0.74 TB |
| Qwen3-Next-80B-A3B | Hybrid, linear attention | 24,576 | 0.49 TB, plus state |
| Nemotron-H-8B | Hybrid, Mamba-2 | 16,384 | 0.33 TB, plus state |
The attention design moves the answer by a factor of about thirty. For an MHA model, the chat trace's useful working set is larger than the memory of most hosts. For an MLA or hybrid model, it fits in the memory of one large host.
When does reloading beat recomputing?
Reloading a prefix costs its bytes divided by the tier's bandwidth. Recomputing it costs its prefill: about two floating-point operations for each active parameter and each token, plus an attention term that grows with the square of the length. Leave the attention term out for now. Per token, reloading wins when
B > \frac{b \cdot F}{2N}where is the tier's bandwidth to one GPU, is the cache bytes per token, is the GPU's achieved floating-point rate, and is the active parameters. The right side is the break-even bandwidth. Below it, recompute is faster. Above it, reload is faster.
For , I assume prefill runs at half of the H100's dense BF16 rate of 989.4 TFLOPS. Prefill is the most compute-bound phase of inference, and half is my assumption. Mixture-of-experts prefill often runs lower. Each dense parameter count comes from the model's config, and each active count from its model card.
The mixture-of-experts rows are single-GPU equivalents. DeepSeek-V3 does not fit on one H100, and it runs in FP8, not BF16. In a real deployment, several GPUs recompute together while each reloads over its own link, so treat its row as a ratio of bytes to work, not as a deployment.
| Model | Break-even bandwidth |
|---|---|
| Llama-2-7B, MHA | 19.25 GB/s |
| Qwen3-30B-A3B, GQA MoE | 7.37 GB/s |
| Qwen3-8B, GQA | 4.45 GB/s |
| Qwen3-Next-80B-A3B, hybrid | 2.03 GB/s |
| gpt-oss-120b, sliding window | 1.79 GB/s |
| Nemotron-H-8B, hybrid | 0.50 GB/s |
| DeepSeek-V3, MLA | 0.47 GB/s |
Every model needs less than 20 GB/s. Most need less than 8. MLA and hybrid models need under 2.5 GB/s, because they store few bytes for each FLOP they would spend to rebuild them. Compare these with the tiers:
- PCIe Gen5 x16 between a GPU and host memory: 64 GB/s peak each way. Real copies reach less.
- NVLink-C2C on a Grace Hopper superchip: 900 GB/s in both directions together, so 450 GB/s each way.
- One 400 Gb/s network card: 50 GB/s.
- One PCIe Gen5 enterprise NVMe drive: up to 14 GB/s of sequential reads.
For scale, take a 32,768-token prefix of Qwen3-8B: 4.83 GB of cache. Over PCIe Gen5 at its 64 GB/s peak, it reloads in about 75 ms. Prefill at the assumed rate recomputes it in about 1.09 s.
Hover a part to see its nameEvery model breaks even below one PCIe Gen5 link. Every model except the MHA one breaks even below one NVMe drive. For long prefixes on most models, reload wins from host memory and from a drive that one GPU reads alone. Hybrid models must also reload their fixed state, which the per-token figure leaves out.
Three conditions favor recompute.
- Shared bandwidth. Each GPU has its own x16 link. A drive serves every GPU that reads from it. An 8-GPU server with one Gen5 drive gives each GPU 1.75 GB/s when all of them read at once, below what Qwen3-8B needs. Four drives give each GPU 7 GB/s.
- Short prefixes. Every transfer has a fixed start cost: a lookup, a request to the store, a copy to launch. For a few hundred tokens, that cost can exceed the prefill. SGLang's HiCache does not fetch from its storage tier until the hit is at least 256 tokens long, by default.
- Scattered copies. The GPU computes layer by layer, so its cache is laid out by layer. A block stored in that layout moves as one small copy per layer. SGLang added page-first layouts and its own copy kernels for this reason, and reports up to three times the speed of plain
cudaMemcpyAsync.
Two effects favor reload more than the formula shows. The attention term grows with the square of the prompt, so past tens of thousands of tokens recompute costs more. And on a busy server, the two choices spend different resources. Recompute spends the GPU's arithmetic, which every other request in the batch also needs. Reload spends link time and copy engines, and it can run while the GPU computes, though it still shares memory bandwidth with that work. When a server runs past its first knee, that difference decides throughput: the GPU spends more and more of its time computing old prompts again.
What the engines do today
Every engine below follows the same plan. It checks the GPU first, then asks a connector how much more of the prompt a lower tier can supply. It loads those blocks while it computes, layer by layer, and writes new blocks down after prefill.
vLLM defines the plan as an interface, KVConnectorBase_V1. The scheduler side asks get_num_new_matched_tokens: how many prompt tokens, past the GPU's own prefix cache, the connector can load. The worker side starts loads with start_load_kv, waits for one layer at a time in wait_for_layer_load, and saves with save_kv_layer. The per-layer wait lets layer load while layer computes. vLLM ships two native offload connectors, OffloadingConnector and SimpleCPUOffloadConnector, whose backends are host memory or disk. It also ships connectors for LMCache, Mooncake Store, 3FS and FlexKV, and a MultiConnector that chains them.
LMCache plugs into the engine through a connector and stores the cache in chunks of 256 tokens by default. Its first level is CPU memory. Its second level is a set of adapters: a local or shared filesystem, 3FS, Mooncake Store, a NIXL store, Valkey, S3 and raw block devices, among others.
SGLang HiCache names its tiers like a CPU's caches. L1 is GPU memory. L2 is host memory, and it is private: two instances never read each other's L2, even on one machine. L3 is a storage backend (a file system, Mooncake, 3FS, NIXL or AIBrix), and it is shared only when every instance points at the same one. Three write policies set when blocks move down: on every access, only once a block is hot, or only when it is evicted. Three prefetch policies set how long a request waits for L3: not at all, until the fetch finishes, or until a timeout. The default timeout is 2 seconds plus 0.1 seconds per 1,024 tokens, capped at 30 seconds.
NVIDIA Dynamo named the same tiers G1 to G4: GPU, CPU, SSD and remote. Its KV Block Manager was deprecated in Dynamo 1.5.0 and is no longer built or shipped. Dynamo now points users to the engine's native offload, LMCache or FlexKV for host and disk tiers.
Mooncake Store comes from Kimi's serving platform. It is now a backend for TensorRT-LLM, LMDeploy, FlexKV and llm-d, as well as for vLLM and SGLang.
What MLA and hybrid models change
MLA stores one compressed row per token per layer, so it has the lowest bytes per FLOP of any design here. Its break-even bandwidth is under 0.5 GB/s, so reload wins from nearly anywhere. One cost goes the other way: under tensor parallelism, every GPU holds the whole row. SGLang writes MLA blocks down from one rank only, so the store keeps one copy instead of one per GPU.
Hybrid models such as Qwen3-Next and Nemotron-H add little per token, but each request also carries a fixed recurrent state: 37.7 MiB for Qwen3-Next-80B-A3B and 97.4 MiB for Nemotron-H-8B in vLLM. A prefix hit needs that state at the exact token where the hit ends, so engines save it only at checkpoints, and a hit can land only on one. The KV cache essay shows why that makes hybrid prefix matches fragile. Offload keeps more of those checkpoints, so more prefixes can hit, but each hit still lands on a checkpoint.
Sparse attention, as in DeepSeek-V3.2, reads fewer past tokens per step but stores all of them, plus an index. It does not make an offloaded prefix smaller.
A checklist before you add a tier
- Measure your oracle hit rate on your own traffic. If it is low, no tier helps.
- Find the first knee: the cache size where the hit rate starts to climb. If your GPU cache is already larger than that, offload buys little.
- Size each tier for the knee you want to reach. The whole working set is usually more than you need.
- Divide a shared tier's bandwidth by the GPUs that read it at once, then compare it with the break-even bandwidth.
- Count prompt tokens by source: computed, GPU, host, disk and remote. The counts must add up to every prompt token, or a fallback is hiding.
- Check the achieved transfer rate against the device's rated speed. A tier that falls back to a slower path raises no error.
Limits
The traces come from one provider, and they hash blocks of 512 tokens, so a hit shorter than a block counts as a miss. My replay uses one shared cache for all of a trace's traffic and evicts the least recently used block. Real deployments split the cache across replicas and use other policies. The 50% prefill rate is an assumption. A different rate scales every break-even bandwidth by the same factor.
Questions engineers ask
Does offload help if my cache already fits in GPU memory?
No. Below the first knee, the GPU's own prefix cache serves every hit the traffic offers. Offload then costs only its copies and its memory.
Is host memory enough, or do I need an SSD?
It depends on how long your users take to come back. The agent trace got 87% of its possible hits from 1 TB of host memory for Qwen3-8B. The chat trace got 66%.
Why would recompute ever win?
When the prefix is short, when many GPUs share one slow tier, or when the tier's path falls back to a slower one. For a long prefix on a fast link that one GPU reads alone, reload wins for every model here.
How do I turn on KV cache offload in vLLM?
Set --kv-offloading-size to the CPU buffer in GiB, summed across tensor-parallel ranks. --kv-offloading-backend chooses native or lmcache. Without a size, vLLM does not offload.
Does an FP8 KV cache change the break-even?
Yes. It halves the bytes per token, which halves every break-even bandwidth here and doubles the tokens each tier holds.
References
- Qin et al., Mooncake: Trading More Storage for Less Computation, A KVCache-centric Architecture for Serving LLM Chatbot (opens in a new tab), USENIX FAST 2025.
- Mooncake, FAST '25 traces (opens in a new tab), commit da2d74d: conversation, tool and agent, and synthetic, with 512-token block hashes. The Mooncake README (opens in a new tab) lists the engines that use Mooncake Store.
- vLLM,
kv_offloading_sizeandkv_offloading_backend(opens in a new tab), commit 361f362. - vLLM,
KVConnectorBase_V1(opens in a new tab) and the v1 connectors (opens in a new tab), commit 361f362. - LMCache, L2 adapters (opens in a new tab) and the chunk size (opens in a new tab), commit 3cdeedd.
- SGLang, HiCache design (opens in a new tab), commit 4791be0, for the tiers, policies, layouts and the MLA write-back.
- NVIDIA Dynamo, deprecations (opens in a new tab), commit a552d9f, for the KV Block Manager.
- gpu-specs (opens in a new tab), for the H100 and H200 memory and BF16 rates and the PCIe Gen5 rate, each quoted from NVIDIA's pages.
- NVIDIA, H100 specifications (opens in a new tab), for NVLink-C2C at 900 GB/s on Grace Hopper.
- Samsung, PM1743 (opens in a new tab), and KIOXIA, CM7-R (opens in a new tab), for 14,000 MB/s sequential reads.
- Model cards for active parameters: Qwen3-30B-A3B (opens in a new tab), DeepSeek-V3 (opens in a new tab), gpt-oss-120b (opens in a new tab), Qwen3-Next-80B-A3B (opens in a new tab).