Walk me through what happens inside the server when an LLM processes a request. Why are prefill and decode bottlenecked differently?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Two phases. Prefill: the whole prompt is run through the model in one forward pass - every prompt token is processed in parallel, so the work is large matrix-matrix multiplies. That's high arithmetic intensity, and the GPU is compute-bound. Prefill produces the first output token and populates the KV cache; its duration is what dominates time-to-first-token. Decode: output tokens are generated one at a time. Each step, the model does a forward pass for a single token - matrix-vector multiplies - but still has to read every weight of the model (plus the KV cache) from HBM to produce that one token. Very few FLOPs per byte moved, so decode is memory-bandwidth-bound: the GPU spends its time streaming weights, not computing.
Full worked answer with diagram
Two phases. Prefill: the whole prompt is run through the model in one forward pass - every prompt token is processed in parallel, so the work is large matrix-matrix multiplies. That's high arithmetic intensity, and the GPU is compute-bound. Prefill produces the first output token and populates the KV cache; its duration is what dominates time-to-first-token. Decode: output tokens are generated one at a time. Each step, the model does a forward pass for a single token - matrix-vector multiplies - but still has to read every weight of the model (plus the KV cache) from HBM to produce that one token. Very few FLOPs per byte moved, so decode is memory-bandwidth-bound: the GPU spends its time streaming weights, not computing.
Concrete consequence: a 70B model in FP16 is ~140 GB of weights. On a GPU with ~3.35 TB/s of HBM bandwidth, batch-1 decode can't exceed roughly 3350/140 ≈ ~24 tokens/s regardless of compute - you're rate-limited by memory reads.
This asymmetry drives essentially all serving design:
- Batching helps decode enormously (one weight-read serves the whole batch) but barely helps prefill (already compute-saturated).
- Weight quantization speeds decode (~fewer bytes to stream) more than prefill.
- TTFT and TPOT are different SLOs with different levers: TTFT is about queueing + prompt length; TPOT is about bandwidth and batch contention.
- Mixing the two phases on the same GPUs causes interference (long prefills stall everyone's decode), which is why chunked prefill and prefill/decode disaggregation exist.
Worth sketching. It puts both bottlenecks on one picture, so the interviewer sees you know which phase is starved of compute and which of bandwidth.
flowchart LR
P["Prompt of N tokens"] --> PF["Prefill: one pass,<br/>matrix-matrix, compute-bound"]
PF --> KV["KV cache populated"]
PF --> T1["First token (TTFT)"]
KV --> D["Decode step: read every weight<br/>plus KV from HBM, bandwidth-bound"]
D -->|"one token per weight sweep"| D
D --> OUT["Streamed output (TPOT)"]
What a good answer covers
- Prefill: the whole prompt is run through the model in one forward pass - every prompt token is processed…
- That's high arithmetic intensity, and the GPU is compute-bound
- Prefill produces the first output token and populates the KV cache; its duration is what dominates…
- Decode: output tokens are generated one at a time
- Each step, the model does a forward pass for a single token - matrix-vector multiplies - but still has…
Key terms: Prefill · compute-bound · Decode · memory-bandwidth-bound · Batching · Weight quantization
In the glossary: Prefill · Arithmetic intensity · Decode · HBM · TPOT / ITL · Chunked prefill
Interviewer follow-ups to expect
Why doesn't adding more compute (a faster GPU with the same bandwidth) speed up batch-1 decode?
At roughly what batch size does decode become compute-bound?
How would you speed up TTFT specifically?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep