Prefill/decode disaggregation: separate shops for reading and writing
One kitchen, two trades
In a small restaurant, the same cook peels, chops and preps the vegetables, then plates the dishes during service. On a quiet evening that works fine. But the day a forty-pound vegetable delivery shows up mid-service, the plates wait: the cook cannot do both at once, and the diners already seated watch their food arrive in slow motion.
Big kitchens solved this long ago. A prep kitchen does all the bulk preparation, and a service line does nothing but plate, dish after dish, at a steady pace. Between them sits a pass. Each team has its own tools, hours and headcount, tuned to its trade. The price: prepared food has to be carried from one room to the other.
Serving a large language model is exactly this situation. Prefill/decode disaggregation means handing the reading of the question and the writing of the answer to two separate groups of machines, and passing between them the one thing that links them: the cache.
Recap: two phases with opposite needs
The lesson on continuous batching introduced the two regimes of a served model:
- prefill reads the whole question at once. All its tokens are known in advance, so they are processed together: lots of arithmetic for every weight read from memory. This phase is compute-bound;
- decode writes the answer one token at a time. For every token, the chip must reread all the model's weights and the conversation's cache, for very little arithmetic. This phase is memory-bandwidth-bound.
Prefill also produces the KV cache (the key-value cache, explained in KV Cache): the in-memory record of everything that has been read, which decode needs at every token so it does not have to reread it all.
In a conventional server, both phases run on the same graphics processing units (GPUs), mixed in the same batch. The batching lesson presented this mix as a stroke of luck: each phase fills the other's slack. That holds for throughput. For latency, it is a different story.
The problem: two phases stepping on each other's toes
Two stopwatches, not one
Users feel a model's speed through two quite different durations:
- time to first token (TTFT): the time spent staring at a blank screen. It depends mostly on prefill;
- time per output token (TPOT): the average gap between two words appearing. It depends on decode. People also track the gap between each pair of consecutive tokens, one by one, called inter-token latency (ITL): that is what exposes the hiccups, when the answer freezes for half a second and then resumes.
A service sets a target for each, for example a first token in under a second and then a token every few tens of milliseconds. These commitments are called service level objectives (SLOs). A chat assistant cares most about the first; a tool that generates long texts cares mostly about the second.
Useful throughput
Raw throughput, in tokens per second, can lie: a machine can post record throughput while half its users wait too long. Hence a more honest measure, which the DistServe authors put at the center of their work: goodput, the number of requests per second served while meeting both targets (in practice, for a large share of requests, say 90%). A request served late does not count.
Three ways to get in each other's way
1. Prefill makes decode stutter. A 30,000-token question arrives (a long document, an agent's history). Its prefill makes the current iteration enormously heavier, and every conversation that was in the middle of writing stops while it goes through. Their ITL spikes.
2. Chunked prefill is only a compromise. Cutting the long text into slices (the chunked prefill from the batching lesson) spreads the disruption out instead of removing it: every iteration that carries a slice is still slower than a pure decode iteration. And the knob pulls both ways: smaller slices disturb decode less, but you need more of them, so the new request's first token arrives later. You trade TPOT for TTFT.
3. One setting for two trades. On shared GPUs, both phases necessarily share the same layout. Yet they would like opposite choices:
- prefill likes to spread a single request across several GPUs (tensor parallelism, see advanced parallelism) to cut TTFT, and has no need for big batches, since one long question already keeps the chip busy on its own;
- decode wants the biggest batch possible, to share the rereading of the weights across many conversations, and lots of memory to hold their caches.
Nor can you add capacity to just one phase: every GPU you buy does both. To meet the TTFT target and the TPOT target at the same time, the operator ends up oversizing the whole fleet.
The mechanism: two GPU pools and a pass
The idea is simple to state: create two pools of GPUs, one doing only prefill, the other only decode. A request's journey becomes:
- The router takes the request. A global scheduler picks a prefill instance, based on each one's load and, as we will see, on where some of the useful cache already lives.
- The prefill instance reads the question. It produces the first token and the request's full KV cache.
- The cache crosses the network. It is sent to a decode instance over a fast link: NVLink (the direct GPU-to-GPU connection inside a server or a rack) or a remote direct memory access (RDMA) network, which writes straight into the memory of the GPU on the other side without going through the host processor.
- The decode instance takes over. It stores the cache in its paged memory (see PagedAttention), adds the request to its continuous batch and writes the rest of the answer.
The payoff is immediate: a long prefill no longer interrupts anyone, since the conversations being decoded run elsewhere. And each pool is tuned for itself:
- its own parallelism: spread for speed on the prefill side, spread for big batches on the decode side;
- its own size: if questions get longer (agents, long documents), add prefill GPUs; if answers get longer (reasoning), add decode GPUs. Practitioners often write the ratio as "1P3D" (one prefill instance for three decode instances), "2P1D", and so on;
- even its own hardware: the Splitwise authors (Microsoft) point out that decode, which leaves the arithmetic units largely idle, could run on cheaper, lower-power chips.
The DeepSeek-V3 technical report (December 2024) already described a deployment that separates prefill and decode, with different parallelism configurations. In March 2025, DeepSeek detailed its online service for V3 and R1. On the prefill side, a deployment unit spans 4 servers (32 GPUs), and each GPU hosts 9 routed experts plus the shared expert. On the decode side, the unit spans 18 servers (144 GPUs), and each GPU hosts only 2 routed experts plus the shared expert. Why spread more thinly for decode? Because an expert that lives on few GPUs receives tokens from a great many conversations at every step: its effective batch grows, and the rereading of its weights is shared more widely (experts are explained in MoE principles). Reported throughput per H800 server: about 73,700 input tokens per second in prefill (counting tokens found in the cache) and about 14,800 output tokens per second in decode.
The price: moving the cache
Nothing comes free: the cache produced on one side must reach the other before decode can start. The transfer time fits in one line:
Take the 7-billion-parameter model from the batching lesson, without grouped attention: about 0.5 MB of cache per token. An 8,000-token question therefore produces about 4.2 GB of cache. Over a 400-gigabit-per-second network link (50 gigabytes per second), moving it takes on the order of 80 milliseconds, assuming the link is entirely free. That is not nothing when the first-token target is counted in hundreds of milliseconds, and the traffic adds up with every request.
Hence two countermeasures:
- overlap the transfer: send the cache layer by layer while prefill is still computing the following layers, so that almost nothing is left to wait for at the end;
- make the cache smaller. This is where model architecture meets infrastructure. DeepSeek's multi-head latent attention (MLA) compresses each cache entry; DeepSeek V4.1-Flash reports, per its technical report, about 890 bytes per token. At that size, the same 8,000-token question weighs only about 7 MB: several hundred times less to carry. A compact cache does not just save GPU memory, it makes disaggregation almost free on the network side.
The cache as a first-class resource: Mooncake
Once you accept that the cache travels, a natural question follows: why throw it away after use? Mooncake, the platform that serves Moonshot AI's Kimi assistant, takes this logic all the way. Its paper describes a "KVCache-centric" architecture: prefill and decode run on separate pools, and between them sits a distributed cache pool, held in the host processors' (CPU) memory and on the cluster's SSDs, resources that were previously underused.
The gain comes from prefix reuse. Many requests start with the same text: the same system instructions, the same document, and above all the same history. If the cache for that opening already exists somewhere in the pool, prefill fetches it instead of recomputing it, and processes only the new part. Mooncake's scheduler therefore picks the prefill instance based on both its load and the amount of reusable cache within its reach; under overload, it rejects early the requests it predicts would miss their deadlines, rather than letting them degrade service for everyone.
This is what makes disaggregation especially profitable for agents. An agent resends its entire history at every turn, plus a small tool result. Without a cache pool, you would reread tens of thousands of tokens every time; with one, you read only a few hundred. DeepSeek's figures for its own service, over 24 hours in late February 2025, give the order of magnitude: of 608 billion input tokens, 342 billion (56.3%) were found in the KV cache kept on disk, built on their 3FS distributed file system.
Splitwise: Efficient generative LLM inference using phase splitting (Patel et al., Microsoft, ISCA 2024): split the phases across different machines, possibly with different hardware, and optimize the whole cluster for throughput, cost or power.
DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving (Zhong et al., OSDI 2024): remove interference, tune each phase's parallelism to its own TTFT and TPOT targets, and place the phases according to the cluster's bandwidth. On their benchmarks, the authors report up to 7.4 times more requests served within deadlines than the reference systems of the time.
Mooncake: A KVCache-centric Disaggregated Architecture for LLM Serving (Qin et al., Moonshot AI): the cache as the pivot of the whole service. Under real workloads, the paper reports that Kimi handles 75% more requests.
Next step: pulling out the vision encoder too
A model that reads images (see vision-language models) adds a step before prefill: a vision encoder turns each image into a sequence of tokens the language model can read. It is a separate network with its own profile: heavy on arithmetic, with inputs whose size varies widely from one image to the next. Running it on the same GPUs as prefill recreates exactly the interference we just removed. The logical next move is a three-way split: encoder / prefill / decode.
DeepInfer, the inference engine DeepSeek released on October 20, 2026 (under the Apache 2.0 license), illustrates the point. Its documentation lists, among what a complete service requires but this release does not include, a KV cache system and "VE/Prefill/Decode disaggregation", noting that most of the required engine functionality is already implemented. "VE" most likely stands for the vision encoder: V4.1-Flash ships with its own image encoder. In other words, the public release runs the model, but the pieces that turn an engine into a service at scale, phase separation and the cache pool, stay in-house at DeepSeek for now.
When it is not worth it
Disaggregation is a large-scale game. It loses its appeal, or even costs more than it saves, in several cases:
- small deployments: with a single 8-GPU server, splitting into two pools shrinks each one's batches accordingly, and batching loses part of its efficiency;
- short questions: if prefill is brief, it barely disturbs decode, and the cache transfer plus the routing complexity dominate the balance sheet;
- a slow network: without RDMA or NVLink, the cache transfer eats up the time-to-first-token budget;
- traffic that changes shape: a fixed ratio between the two pools leaves one idle while the other saturates as the request mix shifts through the day. GPUs then have to be reassigned on the fly, which adds yet more logic;
- operational complexity: a router, a transfer mechanism, a cache pool, each one a part that can fail or fall out of sync.
The debate is not settled, either: at moderate load, a well-tuned mixed server with chunked prefill remains a solid choice, and the tipping point depends on the model, the hardware and the workload.
| Mixed phases (continuous batching + chunked prefill) | Disaggregated phases | |
|---|---|---|
| Interference between phases | Reduced, never removed | Removed |
| Parallelism and batch size | One setting for both | One setting per phase |
| Capacity ratio | Fixed: every GPU does both | Adjustable to the load |
| Network cost | None | Cache transfer for every request |
| Suitable scale | One to a few servers | Tens to hundreds of GPUs |
| Complexity | Low | Router, transfer, often a cache pool |
Adoption
The Splitwise and DistServe ideas date from late 2023 and early 2024; Mooncake followed in summer 2024. The split then became common in large deployments from 2024-2025 onward: the DeepSeek-V3 report described it at the end of 2024, vLLM and SGLang offer it (see serving frameworks compared and model serving), and NVIDIA Dynamo, announced in March 2025, is built around it. Unlike continuous batching, now the expected minimum of any engine, disaggregation remains an architectural choice for those who serve at scale.
Why it matters
The cost of an AI service is no longer decided by the model alone, but by how the machines around it are organized. Separating reading from writing lets a provider meet the latency it promises users with less hardware, add capacity exactly where it is short, and, with a cache pool, stop paying twice to read the same context. For agents, which reread the same history over and over, that is a decisive share of the bill. It also explains why model designers fight so hard to shrink the cache: a compact cache is easier to hold, to keep and to move.
Key takeaways
- Two phases, two trades: prefill is compute-bound, decode is memory-bandwidth-bound; on shared GPUs they interfere and must share a single configuration.
- Two stopwatches and an honest throughput: TTFT measures the wait for the first token, TPOT the smoothness afterwards, and goodput only counts requests served within both targets.
- Two GPU pools and a pass: each phase gets its own parallelism, batch size and headcount, and the KV cache travels from one to the other over a fast network.
- The transfer is the price: it is overlapped with computation and shrunk by compact caches (MLA, V4.1-Flash), which make the split almost free.
- The cache becomes a resource in its own right: Mooncake keeps it in a distributed pool to reuse prefixes, which benefits agents above all; the next step also separates the vision encoder.
- A large-scale technique: small deployments, short questions or a slow network, and the mixed server remains the better choice.
1. A server mixes prefill and decode on the same GPUs, with chunked prefill. Why does a 30,000-token question still degrade the experience of other users?
2. What does goodput, or useful throughput, measure that raw throughput in tokens per second does not?
3. In the deployment DeepSeek described in March 2025, each decode GPU hosts only 2 routed experts, versus 9 on a prefill GPU. What is the logic behind this choice?
4. Why does a very compact KV cache, like the roughly 890 bytes per token reported for DeepSeek V4.1-Flash, make disaggregation more attractive?