Zero Labs
Industry News / AI

When the KV Cache Spills Over PCIe

Source · Towards AI By Srinivas kodali

From the publisher’s feed, collected in the ZeroLabs newsroom.

When the KV Cache Spills Over PCIeNov 14, 2026 · @Srinivas KodaliOne model, one 8-GPU server, 200 long-context users. Where the KV cache goes when GPU memory runs out, what PCIe does to response time, and how to keep it under control.In my last article, PCIe in AI Inference: Where It Shines and Where It Lags, PCIe sat mostly idle while the GPU wrote tokens. It mattered only when data had to move in bulk.In long-context serving, the biggest bulk mover is the KV cache. Every chat, document and agent step leaves one behind. When GPU memory fills up, the cache spills into CPU memory and SSDs, and PCIe becomes the only road back.This article follows one production setup end to end: how big the cache gets, where it lives, how long it takes to bring back, and what breaks under real load.The setupOne example runs through the whole article: Llama 3.1 70B served by vLLM on a DGX H100-class server. The hardware numbers come from public spec sheets, and the software is open source.Table 1. The production setup used in this article.The workload is a typical coding or support assistant. Users paste documents, keep long chat histories, run agent steps, and pause to think between turns.How big is the KV cache?For every token in the context, each layer keeps one key and one value vector per KV head. For Llama 3.1 70B, that comes to:KV per token = 2 (key + value) × 80 layers × 8 KV heads × 128 dims × 2 bytes = 327,680 bytesThat is about 320 KB per token in BF16, or 160 KB in FP8. Multiply it by the context length to get each user’s cache.Table 2. KV cache per user, and how many users fit in about 400 GB of HBM.Why 400 GB? Start with 640 GB of HBM. Keep 10% back as a safety margin, then subtract 141 GB of weights and some working memory for activations.The math that forces a spillOur 200 sessions average 32K tokens each, so they need 200 × 10.7 GB = 2.15 TB of KV cache. HBM holds about 37 of them.That leaves 163 sessions with two choices:Drop and recompute. Throw the cache away and rebuild it from the text on the next turn.Park it. Copy the cache to CPU memory or SSD, and bring it back on the next turn.Recompute costs GPU time. Parking costs PCIe time. The rest of this article is about that trade.FP8 changes the picture. It halves the total to 1.07 TB, which fits in HBM plus CPU memory with no SSD needed.The spill pathA parked KV cache moves down a ladder. Each step away from the GPU adds capacity and loses bandwidth.Figure 1. The spill path on an 8× H100 server.Two numbers matter most. The road from CPU memory back to the GPU runs at about 50 GB/s in practice. The vLLM team measured that one-way peak on an H100, against 64 GB/s on paper. That is about 67 times narrower than HBM.SSDs are slower again. A Gen4 data center drive reads about 6 to 7 GB/s, and Red Hat measured 6.2 GB/s during its H100 inference tests.A returning user: recompute or reload?A user comes back after five minutes, and their 32K-token KV cache was parked. What does the next answer cost?With tensor parallelism across 8 GPUs, each GPU holds one-eighth of the cache. So each GPU pulls 1.34 GB over its own PCIe link, and all eight pull at the same time.Figure 2. Time to bring back one 32K-token user before the first new token.Reloading from CPU memory is more than 50 times faster than recomputing. Even the SSD path is at least 7 times faster.How long does recompute really take?Start with the work. Prefill costs about 2 FLOP per parameter per token, plus attention, which grows with the square of the context:Prefill work ≈ 2 × parameters × tokens + 2 × layers × hidden size × tokens²For 32K tokens on Llama 3.1 70B, that is about 4.6 + 1.4 = 6.0 PFLOP.Eight H100s peak at 7.9 PFLOP/s in dense BF16, or 989 TFLOP/s each. (The 1,979 TFLOP/s on the datasheet assumes sparsity, which dense models don’t use.) At that peak, recompute would take 0.76 s. Real prefill never runs at peak, because each of these steps needs compute or time beyond the raw math:Matrix multiplies do most of the work, but they never keep every tensor core busy.Attention grows with the square of the context and runs less efficiently than plain matrix multiplies.Small steps like normalization, softmax and activations add little math but still take time.Chunked prefill splits the prompt into pieces, which adds kernel launches and re-reads of earlier KV.Syncing the 8 GPUs after every layer moves data over NVLink, and the FLOP count doesn’t include it.Together, these put recompute at roughly 1.5 to 2.5 s on an idle server. FP8 roughly halves it. To get the real number for your own setup, measure a single 32K-token prefill:vllm bench latency --model meta-llama/Llama-3.1-70B-Instruct -tp 8 --input-len 32768 --output-len 1 --batch-size 1 --no-enable-prefix-cachingUnder load, recompute gets much slower. It waits behind other users’ prefills and shares the GPUs with their decode steps. LMCache measured Llama 3.1 70B on 8× H100 with 100 chat sessions of only 12K tokens each and a small CPU cache. Time to first token was 4.5 s at P50 and 8.3 s at P90.Recompute also has a hidden cost: every second of it is GPU time taken from users who are already generating tokens.What breaks under real loadThe 27 ms above is the best case: one user, an idle bus and well-tuned code. Production adds traffic, topology and wear.1. Return storms turn PCIe into a queueUsers don’t come back one at a time. A meeting ends, a batch of agents wakes up, or the morning rush starts. If 20 users return together, each GPU must pull 20 × 1.34 GB = 27 GB before the last of them sees a token.Figure 3. Wait for the last user when many return at once.At the full 50 GB/s, about 18 users fit inside a 500 ms budget. At 15 GB/s, the sustained rate one study measured on an H100 server, only 5 do. FP8 doubles each of these numbers.2. The link is sharedThe GPU’s PCIe link doesn’t belong to the KV cache alone. In many 8-GPU servers, each GPU sits behind a PCIe switch with its network card, and some designs put two GPUs on one switch. Network traffic, storage reads and KV reloads then compete for the same lanes.Figure 4. Three kinds of traffic share one GPU’s PCIe link.3. The two directions fightOffload writes new KV to CPU memory while reloads pull old KV back. PCIe is full duplex on paper, but host-side limits can make the two directions slow each other down. Test both directions at once with nvbandwidth before you trust one-way numbers.4. Tiny transfers waste the busvLLM stores KV in 16-token blocks. In its older layout, one Llama 3.1 70B block was only 8 KB per layer, and copy engines are poor at small copies. The newer layout packs all layers into one 1.25 MB block, which raised offload throughput about tenfold.5. One slow GPU sets the paceWith tensor parallelism, a reload finishes only when all eight GPUs finish. One link running at half width or an older PCIe generation slows down every user. Check link speed and width on all eight GPUs, not just one.6. The buffer sits on the wrong CPUIf a GPU’s pinned host buffer sits on the far CPU socket, every copy crosses the link between the sockets. nvidia-smi topo -m labels that path SYS, the slowest kind of GPU path.7. SSDs wear out and failKV offload writes all day. Read-intensive drives such as the Micron 7450 PRO are rated for one full drive write per day, so eight 3.84 TB drives can absorb about 31 TB a day. A steady 1 GB/s of KV writes is 86 TB a day, which wears the drives out in under 2 years instead of 5.On DGX H100, the data drives also ship as RAID 0. One failed drive empties the whole tier, and a restart means a cold cache.8. Requests miss a cache that existsWith several replicas, a returning user can land on a replica that never saw their KV cache, and the system recomputes anyway. With 4 replicas and plain round-robin routing, a returning user lands on the right server only 1 time in 4, so about 75% of returning turns recompute for nothing. Sticky or KV-aware routing fixes this by sending each turn back to the replica that holds its cache.9. Parked KV is user dataThe KV cache is a working copy of the user’s conversation. On disk, it needs the same encryption and deletion rules as chat logs. DGX H100’s data drives are self-encrypting, which helps, but retention rules are still your job.When to offload, and when not toOffload pays off when the same context comes back. When it doesn’t come back, offload just burns bandwidth.Table 4. Where the KV cache should live, by workload.Table 4. Where the KV cache should live, by workload.Reuse is the deciding number. The longer the context, the more a recompute costs, so long contexts pay back the offload even when only some sessions return.Key takeawaysA 32K-token user on Llama 3.1 70B carries 10.7 GB of KV cache, and an 8× H100 server holds about 37 of them in HBM.For one user, reloading from CPU memory over PCIe is more than 50× faster than recomputing, and the gap grows under load.Under load, PCIe becomes a queue: about 18 users returning at once use up a 500 ms budget, even at full speed.Most fixes come down to moving fewer, bigger bytes over the right path: FP8 KV, large blocks, the local CPU socket, and a known PCIe topology.FP8 halves nearly every number in this article. In the next article, I look at quantization: shrinking weights and the KV cache so one GPU node serves more tokens per second.ReferencesLlama 3.1 70B Instruct config: layers, KV heads, head size and hidden size for the KV and prefill formulasNVIDIA H100 specifications: 80 GB HBM3, 3.35 TB/s, 989 TFLOP/s dense BF16NVIDIA Hopper architecture in depth: PCIe Gen5 at 64 GB/s each wayNVIDIA DGX H100/H200 User Guide: 2 TB memory, 8× 3.84 TB self-encrypting NVMe in RAID 0vLLM: Inside vLLM’s new KV Offloading Connector: about 50 GB/s measured one-way on H100, block sizesRed Hat: Benchmarking tiered KV cache offloading on H100 GPUs: 6.2 GB/s NVMe readsMeng, Lee and Wang (arXiv 2601.19910): 15 GB/s sustained PCIe rate on H100StorageReview: Micron 7450 SSD specifications: one drive write per dayLMCache on Amazon SageMaker HyperPod: time to first token under load on 8× H100When the KV Cache Spills Over PCIe was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.