Skip to content
Inference Academy

Disaggregated prefill and decode explained: why big deployments split the GPUs

Prefill and decode fight over the same GPUs: long prompts stall everyone's streaming. Disaggregated serving runs them on separate pools and ships the KV cache between them. How it works, a worked example of the interference it removes, the KV transfer cost and how layer-by-layer streaming hides it, how to size the two pools, the failure modes, and when chunked prefill is enough.

Key takeaways

  • On shared GPUs, a long prefill in the same step stalls every user's next token: an 8K-token prompt can freeze 55 streams for about 150 ms on a 70B model.
  • Disaggregated serving runs prefill and decode on separate GPU pools and transfers the KV cache between them.
  • The KV transfer is large, about 1.3 GB for an 8K prompt on a 70B model with FP8 cache, but streaming it layer by layer during prefill can hide it almost entirely.
  • It pays off for long prompts, strict inter-token latency targets, large traffic and fast networking.
  • Try chunked prefill on shared GPUs first; it shrinks interference to the size of a chunk with no extra infrastructure.

By

7 min read

Share
On this page

If you've used a busy LLM service and seen the stream of tokens freeze for half a second mid-answer, you've probably seen prefill interference. Someone else's long prompt was processed in the same step as your next token. Disaggregated serving is the architecture that removes that interference, and it has become a standard pattern in large deployments.

This guide explains the problem with numbers, how disaggregation works, what the KV transfer costs and how to hide it, how to size the two pools, and when the simpler alternative is enough.

#The problem: two phases, one GPU

The two phases of inference want opposite things (prefill vs decode):

  • Prefill is compute bound and comes in big chunks: a 16K-token prompt is a lot of work at once.
  • Decode is bandwidth bound and comes in small, steady steps that must stay fast for streaming to feel smooth.

On a shared GPU, a step that includes a big prefill takes much longer, and every decoding user waits for it. You can see that as inter-token latency spikes. Prefill also competes with decode for batch slots and memory.

#A worked example

Take a Llama-class 70B model in FP8 on a node of eight H100s with tensor parallelism 8, serving 55 users whose decode steps take about 8 ms each (the setup from how many GPUs do you need).

An 8,192-token prompt needs about 1.16×10151.16 \times 10^{15} FLOPs of prefill. At about half of the node's FP8 peak, that's roughly 146 ms.

  • Without any protection, that prefill runs in one step. All 55 users see a gap of about 150 ms between two tokens, nearly 20 times their normal 8 ms. If prompts like this arrive several times a second, streaming stutters constantly.
  • With chunked prefill at 512 tokens per step, each step carries about 9 ms of prefill work plus the decode work, so steps take about 17 ms for the 16 steps it takes to finish the prompt. Users see their speed roughly halve for a quarter of a second instead of a freeze.
  • With disaggregation, the decode GPUs never run prefill. Steps stay at about 8 ms regardless of what prompts arrive.

#The idea: separate pools

Run prefill on one set of GPUs and decode on another:

  1. A request arrives and goes to a prefill worker, which processes the prompt and builds its KV cache.
  2. The KV cache is transferred to a decode worker.
  3. The decode worker adds the request to its continuous batch and streams tokens.
Why separate prefill from decode
Animated

One shared GPU

Colocated: decode is running smoothly

Every 25 ms the GPU emits one token for each running sequence.

Each tick is one output token for the running sequences. Gaps are stalls users notice as stutter.

Now decode steps never contain a big prefill, so inter-token latency stays steady. And each pool can be sized and configured for its own bottleneck: prefill pools for compute, decode pools for memory capacity and bandwidth. You can even use different GPU types or different parallelism for each: for example, a smaller tensor-parallel size for prefill (which is compute-bound and batches well) and a larger one for decode (to meet a tight per-token budget).

The idea was developed in research systems such as Splitwise and DistServe, and in production at Moonshot AI (Mooncake). It's now built into NVIDIA Dynamo, llm-d, SGLang and vLLM (Dynamo vs llm-d).

#The cost: moving the KV cache

The transferred cache is big. For a Llama-class 70B model with FP8 KV cache, each token's cache is 160 KiB (KV cache explained), so an 8K-token prompt produces about 1.3 GB.

Link Rough bandwidth Time to move 1.3 GB in one go
NVLink within a node several hundred GB/s a few milliseconds
400 Gb/s RDMA network about 50 GB/s about 26 ms
100 Gb/s network about 12.5 GB/s about 100 ms

Sent all at once after prefill finishes, that transfer adds directly to time to first token.

#Hiding it: stream layer by layer

Prefill computes the model one layer at a time, and each layer's KV cache is final as soon as that layer finishes. So the prefill worker can send layer 1's cache while computing layer 2, and so on.

For the 8K-token example, each of the 80 layers produces about 16 MB of cache and takes about 1.8 ms to prefill:

Link Time to send one layer's cache Hidden behind the next layer's 1.8 ms of compute?
400 Gb/s RDMA about 0.33 ms Yes, easily
100 Gb/s about 1.3 ms Yes, just

With streaming, almost the entire transfer overlaps with prefill, and only the last layer's transfer adds to time to first token. That's why fast transfer libraries (such as NVIDIA's NIXL) and engine support for layer-wise transfer matter so much. Short prompts are harder to hide, because there's less compute per layer to overlap with.

#When it pays off

Disaggregation is worth the complexity when:

  • Prompts are long (RAG, documents, agents with long histories), so prefill interference is severe.
  • Decode latency targets are strict: inter-token P99 matters to your product.
  • Traffic is large enough to keep separate pools busy. A single small deployment can't split into efficient halves.
  • You have fast networking between the pools.

It's usually not worth it for short prompts, small deployments, or relaxed latency targets.

#The alternative: chunked prefill

Before splitting GPUs, try chunked prefill on shared GPUs. The engine caps tokens processed per step and splits long prompts into chunks mixed with decode steps. Interference shrinks to the size of a chunk, as the worked example showed. It costs some TTFT, and some efficiency at very small chunk sizes, but needs no extra infrastructure.

Chunked prefill Disaggregated
Infrastructure One pool Two pools, KV transfer, routing
Decode interference Reduced to chunk size Removed
TTFT Slightly higher Adds transfer time unless overlapped
Independent scaling No Yes: size each pool for its bottleneck
Best for Most deployments Large scale, long prompts, strict ITL

Many teams use chunked prefill first and move to disaggregation when traffic and latency targets justify it.

#Sizing the two pools

The ratio of prefill GPUs to decode GPUs follows from your workload (how many GPUs do you need):

  • Prefill GPUs scale with arrival rate times prompt tokens (minus prefix cache hits), divided by achievable prefill throughput, with headroom for queueing.
  • Decode GPUs scale with concurrent sequences, which is arrival rate times output length times time per token, limited by memory and the per-token latency budget.

Two contrasting workloads:

Workload Prompt Output Pool balance
Document Q&A (8K prompt, 1K answer, strict latency) Long Medium About 4 prefill nodes to 3 decode in the worked plan
Reasoning model (1K prompt, 8K of thinking and answer) Short Very long Mostly decode; a small prefill pool

Because traffic shape changes through the day, large deployments adjust the ratio dynamically (NVIDIA Dynamo's planner does this, for example).

#What can go wrong

  • Transfer failures. If the KV transfer fails or a decode worker dies, the request must be prefilled again. Make this a retry path, not an error.
  • Imbalanced pools. If decode is full, finished prefills queue with their KV caches held in memory; if prefill is the bottleneck, decode GPUs sit idle. Watch queue depth on both sides.
  • Routing. The router must pick a decode worker with free KV memory, and ideally one that already holds part of the conversation's cache.
  • Debugging. A slow request now spans two machines and a network transfer. Trace across all three (distributed tracing).

#Metrics to watch

  • Time to first token, split into queueing, prefill and transfer time.
  • Inter-token latency P95 and P99 on the decode pool.
  • KV transfer time and bandwidth used.
  • Queue depth and utilisation of each pool.
  • Prefix cache hit rate on the prefill pool.

#Common mistakes

  • Disaggregating a small deployment, so neither pool is well used.
  • Ignoring KV transfer time in TTFT budgets, or sending it in one piece instead of streaming.
  • A fixed prefill-to-decode ratio when traffic shape changes through the day.
  • Skipping prefix caching, which should cut prefill load before you split anything.

#FAQ

Does disaggregation make prefill faster? Not directly. It makes decode steady, and lets you size and tune each pool separately, which often improves both.

Can both pools be on the same node? Yes. Splitting a node's GPUs between prefill and decode uses NVLink for the transfer, which is very fast, though it gives less flexibility in scaling.

Is it only for huge companies? The open-source frameworks make it accessible, but it only pays off once traffic is large enough to keep two pools busy.

#Go deeper

Disaggregated prefill and decode covers the architecture and KV transfer in depth, and the disaggregated serving lab has you measure interference, then remove it. Scheduling and chunked prefill covers the shared-GPU alternative.

disaggregationservingprefilldecodeinference-engineering

Found this useful?

Send it to someone who is learning the same thing.

Share this article

Next: learn it step by step, free

Capacity planning and cost

Turn traffic and latency targets into a GPU count and a monthly bill. A free lesson with step-through diagrams and a quiz.

Get new articles by email

One short email when a new guide is out. Unsubscribe any time.