14.k owns tiering inside one server (HBM, CPU, SSD) and the fetch-versus-recompute sum; 21.h owns prefix-aware routing; 9.e owns the transfer libraries. This lesson is about the KV cache once a deployment spans many GPUs and many replicas: how parallelism splits it, and how a fleet shares it.
Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Replica | One complete copy of the model serving its own requests. A fleet has many. |
| Shard | The part of a token’s KV that one GPU stores when a model is split across GPUs. |
| KV head replication | When there are more GPUs than KV heads, several GPUs store the same head: the same data in two or more places. |
| MLA latent | DeepSeek-style attention stores one compressed vector per token per layer instead of separate heads (12.g). It cannot be split by head. |
| Attention DP | Running attention data-parallel inside a model instance: each GPU keeps its own sequences’ cache, while the MoE layers are shared through expert parallelism (14.e). |
| Shared KV store | A cache outside any one engine (CPU memory pool, distributed file system, flash tier) that every replica can read and write. |
| Content hash | A block’s name, computed from its tokens and everything before them, so the same prefix gets the same name everywhere (12.m). |
1. What is it?#
On one GPU, the KV cache is one pool. In a real deployment it is spread out in two ways:
- Inside a model instance, the parallelism decides which GPU stores which part of each token’s KV: by head (TP), by layer (PP), by sequence (attention DP) or by token position (context parallelism). This decides how many tokens fit, and whether some are stored twice.
- Across a fleet, each replica has its own prefix cache. Either requests are sent to the replica that already holds their prefix, or the cache itself is shared through a store every replica can reach.
In November 2026 the second is standard practice at scale: Moonshot’s Mooncake Store behind Kimi, DeepSeek’s on-disk cache on its 3FS file system, LMCache, llm-d’s shared file-system tier, and NVIDIA Dynamo’s KV Block Manager all serve KV across machines.
Facts checked on 13 November 2026.
2. Why does it matter?#
- Capacity. The layout can make the same eight GPUs hold 0.6 million or 4.6 million tokens of cache for the same model (section 6). That is the difference between dozens and hundreds of concurrent users.
- Duplication. Each replica’s prefix cache is private, so a popular 50k-token document is cached once per replica that has seen it, and computed once per replica that has not.
- Reuse at fleet scale. DeepSeek reported that 56% of one day’s 608 billion input tokens were served from its on-disk cache instead of being prefilled: more than half the prefill work of a large fleet avoided.
3. Simple analogy#
A hospital’s patient files.
- TP: each file is split by specialty; cardiology keeps the heart pages of every patient.
- PP: split by time; the first ward keeps admission notes, the second keeps treatment notes.
- Attention DP: each doctor keeps complete files for their own patients only.
- Context parallelism: one enormous file is split by chapter across several cabinets.
- Across hospitals (replicas): either send the patient to the hospital that has their file (routing), or keep files in a shared regional archive any hospital can request (shared store).
4. Tiny example: one popular document#
Eight replicas of a 70B model; FP8 cache of 160 KB per token. A 50,000-token product manual is the start of many requests.
KV for the manual 50,000 × 160 KB ≈ 8 GB
no sharing, random load each replica computes it once and keeps a copy: 8 prefills, 64 GB of cache
prefix-aware routing requests for the manual go to one or two replicas: 1–2 prefills, 8–16 GB
shared store computed once, stored once; any replica loads 8 GB (1 GB per GPU at TP 8)
in tens of milliseconds over RDMA (14.k) instead of ~3 s of prefillRouting costs nothing per request but can overload the replica that owns a hot prefix. A store spreads the load but pays a transfer on every cross-replica hit. Large fleets use both.
5. Technical explanation#
How each parallelism splits the cache#
| Parallelism | How a token’s KV is split | Effect on capacity | Taught in |
|---|---|---|---|
| TP | By KV head: each GPU stores its heads for all tokens | Scales with TP up to the number of KV heads; beyond that heads are replicated | 14.c |
| PP | By layer: each stage stores its layers for all tokens | Scales with stages; no duplication | 14.d |
| DP (replicas) | Not split: each replica has its own cache for its own requests | Scales total capacity, not the limit for one sequence | 14.b |
| Attention DP + EP | By sequence: each GPU keeps whole caches for its own sequences | No duplication; one sequence must fit on one GPU | 14.e |
| Context parallelism | By token position: each GPU stores a slice of the sequence | The only layout that lets one sequence’s cache use many GPUs’ memory | 14.f |
Two cases catch people out:
- More GPUs than KV heads. A model with 8 KV heads at TP 16 stores every head on two GPUs. Doubling the GPUs adds no cache capacity.
- MLA under TP. An MLA model stores a single latent vector per token per layer, so there is nothing to split by head: at TP 8 every GPU stores the whole latent cache, eight copies. This is why DeepSeek-style models are served with attention DP (14.e) or with decode context parallelism, which splits the latent by token (14.f).
Hybrid models add a fixed state per sequence for their linear-attention layers (14.i); it follows the sequence, like attention DP.
Sharing across replicas: move the request, or move the cache#
Move the request to the cache (21.h). Engines publish events when they store or drop blocks; the router keeps an index of which replica holds which block hashes and scores replicas by expected hit plus load. No new storage, no transfer, but hot prefixes concentrate load, and a replica restart loses its cache.
Move the cache to the request. A shared store holds blocks that any replica can load:
| System | What it is |
|---|---|
| Mooncake Store (Moonshot AI) | A distributed KV store built from the CPU memory and SSDs of the serving nodes, with RDMA transfer; the core of Kimi’s KV-cache-centric design. Usable from vLLM, SGLang and LMCache. |
| 3FS (DeepSeek) | DeepSeek’s distributed file system, with a KV cache mode; its README reports read throughput peaking at 40 GiB/s on client nodes with one 400 Gb/s NIC each. |
| LMCache | KV management for vLLM and SGLang over CPU, local disk, Redis/Valkey, S3 and Mooncake, with sharing between instances. |
| llm-d FS backend / vLLM file tier | KV blocks as files on any shared file system; replicas that mount the same path share caches, and caches survive restarts and scale-down. |
| NVIDIA Dynamo KVBM | Dynamo’s block manager across GPU, CPU, SSD and remote storage (21.j). |
| NVIDIA Inference Context Memory Storage | An Ethernet-attached flash tier managed by BlueField-4 DPUs, announced at CES 2026 as a “G3.5” tier between local and shared storage (vendor positioning; storage partners are building products on it). |
Why sharing is simpler than it sounds#
KV blocks are immutable and content-addressed. A block’s name is a hash of its tokens and of the whole prefix before it; once written it never changes. So a shared store needs no cache coherence protocol: two replicas that compute the same block produce the same name and the same bytes, and a stale entry is impossible. What it does need:
- The right key. The hash must also cover everything that changes the bytes: model and version, KV dtype, block size, layout (TP or DCP shard), LoRA adapter, and a per-tenant salt. Two engines with different settings must never share blocks.
- Eviction across the fleet. Capacity is finite; the store needs a policy (LRU, frequency, time to live) and garbage collection.
- Soft state. Losing the store means recomputing, not losing data. Treat it as a cache, never as a source of truth, so a store failure degrades latency instead of failing requests (23.e).
Isolation#
A shared prefix cache leaks information: if a guessed prompt is served faster, someone else sent
it. Across untrusted tenants, salt the hash per tenant (vLLM’s cache_salt, 17.f, 21.f), and
encrypt shared tiers, which hold prompt contents at rest.
6. Under the hood: the layout decides the capacity#
The program places one token’s KV on a group of GPUs under six layouts, each GPU with 40 GB free for cache, and counts the copies and how many tokens the group can hold.
// kvsplit.go — where one token's KV lives, for different parallel layouts.
package main
import "fmt"
type layout struct {
name string
gpus float64 // GPUs in the group
perGPU float64 // bytes of one token's KV on each GPU that stores part of it
holders float64 // how many GPUs store a part (or a copy) of that token
full float64 // bytes of one token's KV, stored once
}
func main() {
const free = 40e9 // HBM left for KV on each GPU, bytes
// 70B dense: 80 layers x 8 KV heads x 128 dims x (K,V) x 1 byte (FP8).
gqa := 80.0 * 8 * 128 * 2 * 1
// DeepSeek-V3-style MLA: 61 layers x 576 latent values x 2 bytes (BF16). One shared "head".
mla := 61.0 * 576 * 2
layouts := []layout{
{"GQA-8 TP8", 8, gqa / 8, 8, gqa}, // one KV head per GPU
{"GQA-8 PP2 x TP4", 8, gqa / 2 / 4, 8, gqa}, // half the layers, two heads each
{"GQA-8 TP16", 16, gqa / 8, 16, gqa}, // 8 heads on 16 GPUs: each head twice
{"MLA TP8", 8, mla, 8, mla}, // the latent cannot be split by head
{"MLA DP8 attention", 8, mla, 1, mla}, // a token lives only on its own rank
{"MLA TP8 + DCP8", 8, mla / 8, 8, mla}, // split by token across the group
}
fmt.Printf("%-18s %5s %13s %7s %15s\n", "layout", "GPUs", "KB/GPU/token", "copies", "tokens in group")
for _, l := range layouts {
copies := l.perGPU * l.holders / l.full
tokens := free * l.gpus / (l.perGPU * l.holders)
fmt.Printf("%-18s %5.0f %13.1f %7.0f %14.1fM\n", l.name, l.gpus, l.perGPU/1e3, copies, tokens/1e6)
}
}Output:
layout GPUs KB/GPU/token copies tokens in group
GQA-8 TP8 8 20.5 1 2.0M
GQA-8 PP2 x TP4 8 20.5 1 2.0M
GQA-8 TP16 16 20.5 2 2.0M
MLA TP8 8 70.3 8 0.6M
MLA DP8 attention 8 70.3 1 4.6M
MLA TP8 + DCP8 8 8.8 1 4.6MHow to read it:
- TP and PP split cleanly while TP does not exceed the KV heads: 2 million tokens either way.
- TP 16 doubles the GPUs and adds nothing to cache capacity: every head is stored twice.
- MLA at TP 8 wastes seven eighths of the cache: 0.6 million tokens instead of 4.6 million. Attention DP and DCP both remove the copies.
- They differ for one long sequence. Under attention DP a sequence must fit on its own GPU (here about 570k tokens at most); under DCP one sequence can use all eight GPUs’ memory, at the cost of communication every step (14.f).
- Real engines add block padding, scales and metadata; check the capacity the engine logs at start-up.
7. Performance implications#
- Layout choice moves concurrency by up to the TP degree for MLA models, and by the replication factor for over-split GQA models.
- A cross-replica hit costs a transfer of tens of milliseconds for long prefixes over RDMA versus seconds of prefill; over a slow network or for short prefixes the gap narrows (14.k, 9.e).
- Routing hits are free; store hits are cheap; misses are expensive. The fleet-wide hit rate is the number that drives cost for chat, RAG and agent traffic.
- Hot prefixes concentrate load under pure cache-aware routing; a store lets any replica serve them.
8. Production implications#
- Pick parallelism with the cache in mind. Keep TP at or below the KV head count; serve MLA models with attention DP or DCP, not plain TP.
- Do prefix-aware routing first (21.h). It is the cheapest fleet-wide gain.
- Add a shared store when sessions return after the replica has evicted them, when replicas restart often (autoscaling), or when hot prefixes overload their owners.
- Key blocks on everything that changes the bytes, and salt per tenant across trust boundaries.
- Plan for the store failing. Requests must fall back to prefill, and dashboards should show the hit rate falling, not errors rising.
- Upgrade carefully. A new model version or KV dtype invalidates every stored block; expect a cold cache and higher load after a rollout (23.g).
9. Common mistakes#
- TP larger than the number of KV heads, then wondering why more GPUs did not add capacity.
- Serving an MLA model with plain TP and storing the latent cache eight times.
- Assuming more replicas mean longer context. DP adds total capacity, not per-sequence capacity.
- Building a shared store before prefix-aware routing.
- A hash key that misses a setting (dtype, adapter, version), so incompatible engines load each other’s blocks.
- Treating the store as durable and failing requests when it is unavailable.
- Sharing a cache across tenants without a salt.
10. Hands-on exercise#
- Run
kvsplit.go. Add a model with 4 KV heads at TP 8. How many copies, and what does it do to capacity? - Add a “GLM-5.3-style” layout from 14.i’s numbers (about 47.5 KB per token at FP8, MLA plus an indexer) at TP 8 and at TP 8 + DCP 8.
- For your fleet, estimate how many times your most common long prefix is cached and computed per hour, with round-robin routing and with prefix-aware routing.
- Run two vLLM instances that mount the same directory as a file-system KV tier. Send a long
prompt to one, then the same prompt to the other. Compare TTFT with and without the shared
tier, and with different
cache_saltvalues. - Design the hash key for a shared store used by three model versions, two KV dtypes and LoRA adapters. Which fields must it include?
11. Interview questions#
- How do TP, PP, attention DP and context parallelism each split the KV cache?
- Why does TP beyond the number of KV heads waste memory?
- Why is MLA a bad fit for plain TP, and what do engines do instead?
- Compare routing requests to caches with moving caches to requests.
- Why does a shared KV store not need a coherence protocol? What does it need instead?
- How can a shared prefix cache leak data between tenants, and how do you stop it?
- What happens to a fleet’s cache when you roll out a new model version?
12. Further reading#
Checked on 13 November 2026.
- [ESTABLISHED] Qin et al., “Mooncake: A KVCache-centric Disaggregated Architecture for LLM Serving” (FAST 2025)
- [ESTABLISHED] DeepSeek 3FS — distributed file system with a KV cache mode
- [ESTABLISHED] DeepSeek-V3/R1 inference system overview (February 2025) — on-disk cache hit rate in production
- [ESTABLISHED] LMCache documentation
- [EMERGING] llm-d — Native KV cache offloading to any file system (February 2026)
- [EMERGING] NVIDIA — BlueField-4 and Inference Context Memory Storage (January 2026) — vendor announcement
- [ESTABLISHED] Pope et al., “Efficiently Scaling Transformer Inference” (2022) — how partitioning choices place the KV cache