Describe the prefill and decode phases of inference. Which is compute-bound and which is memory-bandwidth-bound, and how does that show up in time-to-first-token and inter-token latency?
Theme reported publicly: Mistral AI, Speechmatics
Answer
Model answer, written in a candidate's voice
In short
- Prefill: whole prompt processed in parallel; large matmuls; compute-bound; dominates TTFT with queueing
- Decode: one token per sequence per step; reads weights and KV cache; low arithmetic intensity; memory-bandwidth-bound; sets inter-token latency
- Single-stream ceiling ≈ bandwidth ÷ bytes read per step; e.g. ~16 GB weights on ~1 TB/s ≈ ~60 tokens/s; batching amortises weight reads
- Long prompts in a shared batch stall decodes; use chunked prefill or disaggregated prefill/decode
- Product: stream output, trim prompts, reuse cached prefixes
In full
Prefill is the prompt-processing phase: the whole prompt is fed through the model in parallel, so it is dominated by large matmuls and is compute-bound, and it is the main driver of time-to-first-token together with queueing. Decode is the generation phase: each step produces one token per sequence and must read the weights and the KV cache, so arithmetic intensity is low and it is memory-bandwidth-bound, which sets inter-token latency. A rough single-stream ceiling is memory bandwidth divided by bytes read per step — for example, ~16 GB of weights on ~1 TB/s is on the order of ~60 tokens/s — and batching helps by amortising weight reads across many sequences, though it can add per-step work and latency. In a shared batch, long prompts can stall decodes, so systems use chunked prefill or disaggregated prefill/decode to keep decode steps short. Product-wise, that means stream output, trim prompts, and reuse cached prefixes rather than re-prefilling the same context.
What a strong answer covers
- Prefill processes the whole prompt in parallel (large matmuls, compute-bound) and dominates TTFT together with queueing
- Decode produces one token per sequence per step and must read all weights and the cache — low arithmetic intensity, bandwidth-bound — and sets inter-token latency
- Rough single-stream ceiling ≈ memory bandwidth ÷ bytes read per step (e.g. ~16 GB of weights on ~1 TB/s → roughly 60 tokens/s); batching amortises weight reads
- Long prompts stall decodes in a shared batch → chunked prefill or disaggregated prefill/decode
- Product implications: stream output, trim prompts, reuse cached prefixes
Common mistakes
- Assuming the GPU is fully utilised during single-stream decode
- ignoring queueing time inside TTFT