Prefill vs decode in LLM inference
One LLM request creates two different workloads on the same model.
First, the engine processes the prompt and builds its KV cache. Then it generates output one token at a time while reading that cache.
Calling both phases “inference” is correct but operationally incomplete. They stress the hardware differently, expose different latency metrics, and compete when a scheduler mixes them carelessly.
This guide uses the DistServe paper and current vLLM scheduling guidance as primary references.
In this article
- Prefill turns the prompt into model state
- Decode advances one dependent step at a time
- The two phases have different arithmetic shapes
- TTFT and inter-token latency can move in opposite directions
- A long prefill can stall many decodes
- Chunked prefill creates scheduling boundaries
- Chunking is not the same as continuous batching
- Disaggregation gives each phase its own resources
- Prefix caching mainly reduces repeated prefill work
- Capacity planning must count both token streams
- A practical diagnosis order
- The useful mental model
Continue reading
This field note is part of Fanout Pro, with the complete archive, courses, labs, and every Daily paper guide.
See plans