LLM Inference #9: Prefill–Decode Disaggregation
Three users are streaming when a fourth sends a 4,096-token prompt. See why their next tokens wait and what it costs to give prompt processing its own GPUs.
Three users, A, B, and C, are halfway through their answers. Then D sends a 4,096-token document. What happens to A’s next token?
A’s next token waits for the whole batch
A, B, and C are in decode. Each GPU iteration generates one more token for each stream. D needs prefill first. The GPU processes D’s prompt and saves the attention keys and values that later steps will reuse. That saved state is the KV cache.
When one iteration does both jobs, A gets its next token when the batch finishes. If the batch includes all of D’s prompt, that can make one long gap. Chunked prefill spreads D’s prompt across several iterations. A can get a token after each chunk, but a mixed iteration can still take longer than decode alone. Smaller chunks can shorten those gaps while making D wait through more iterations.
DistServe puts prefill and decode on separate GPUs
DistServe gives prompt processing its own pool of GPUs. A, B, and C can keep decoding while D’s prompt runs because they no longer share an iteration. You can also size each pool for its own work. The new cost is that D’s cache has to reach the decode pool. The DistServe paper on separating the two phases
DistServe’s prefill worker builds the prompt KV and samples D’s first output token. The decode worker pulls the cache when it needs it and receives that token too. Its next model step uses token 1 and the prompt KV to produce token 2. This describes what the workers exchange. When the client sees token 1 depends on how the service sends it. DistServe’s decode handoff · DistServe’s pull scheduling
How a vLLM proxy joins the two pools
vLLM also supports running prefill and decode on separate workers. vLLM’s guide to disaggregated prefill
The client still wants to send one request and get one stream back. In one vLLM example, a proxy is the front door that coordinates those two workers. It sends D’s prompt to prefill and gets back the cache locations. Then it sends the original completion request and those locations to decode. The decode worker pulls the KV directly from prefill, and the proxy sends decode’s stream back to the client.
Why decode runs the last prompt position again
In this example, decode handles the entire client response through its usual completion path. Prefill samples a token for its internal reply. The proxy passes the original request and the cache locations to decode, so that internal sample stays out of the client stream.
The cache holds keys and values. The scores used to choose the next token are a separate result of running the model. When decode can reuse the KV for the entire prompt, it runs just the last prompt position again to recover those scores. Decode then samples the first token the client sees. D waits for the cache transfer and that extra step before seeing an answer.
How big is D’s cache?
Take the 70B Llama example from Part 1 on the KV cache. With full attention, every prompt position has a key and a value for each of eight KV heads in each of 80 layers. Each key or value has 128 elements, and BF16 uses two bytes per element. That works out to 320 KiB per position.
Actual network traffic depends on where the workers run and which blocks decode can reuse. If one 100 Gb/s link carries the whole payload once at its ideal rate, the bytes alone take about 107 ms. That calculation excludes setup, queueing, and contention.
Does the split pay off?
D could wait longer for its first token while A, B, and C see shorter gaps. D could also get a first token sooner if dedicated prefill saves more time than the handoff costs. A fixed split can leave one pool idle while the other builds a queue.
Replay the same requests at the same arrival times on the same hardware. Tune the chunk size for shared GPUs and the pool sizes for the split. Compare the p99 time to first token for new requests like D and the p99 token gap for streams already running. At p99, about 99 out of 100 waits are at or below the reported value. Include the gap from token 1 to token 2, especially if the service can send token 1 before the handoff finishes.
If chunking meets both targets at your busiest load, it already does the job. Use the split if it brings the stream gaps within target and keeps the first-token wait within budget.