For a 200-token prompt and 1000-token completion, why does decode dominate end-to-end latency?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A request has a 200-token prompt and asks for a 1000-token completion. Explain why decode dominates wall-clock latency even though prefill processes more characters per pass. Use a back-of-envelope comparison.
Prefill is one parallel pass over the whole prompt, so it is fast. Decode is one sequential pass per output token, so 1000 tokens means 1000 trips and the wall-clock bulk.
Imagine baking. Prefill is like mixing all your ingredients in one big bowl at once: you do it once and it is quick, no matter how many ingredients. Decode is like decorating a cake one sprinkle at a time, and each sprinkle has to wait for the previous one to land before you know where to place the next. With 1000 sprinkles, the decorating takes far longer than the mixing, even though mixing involved more stuff. The prompt is the mixing step. The completion is the decorating step. Every output word must wait for the word before it, so a long completion stacks up many tiny waits into most of the total time you feel.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: prefill is one parallel pass setting TTFT, decode is N sequential passes setting TPOT, the data dependency, the HBM bandwidth gate, and a tokens per second back of envelope.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Reasoning from character or token counts. Prefill touches more tokens but runs them in parallel in one pass; decode runs far fewer tokens but pays a full sequential pass for each one.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.