Inference, Serving & Production·Question 18 of 76Intermediate

What is chunked prefill and what scheduling problem does it fix?

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

The problem: in a continuously batched engine, prefills and decodes share the GPU. A newly admitted request with a long prompt runs a big, compute-saturating prefill - and while it runs, every in-flight decode stalls. Users see their token streams freeze; ITL spikes from tens of milliseconds to seconds. Schedulers that prioritise prefill optimise TTFT at the cost of ITL; schedulers that hold prefills back protect ITL but wreck TTFT and throughput. With 50K - 100K-token prompts this isn't an edge case - one document-heavy request degrades everyone.

Full worked answer with diagram

The problem: in a continuously batched engine, prefills and decodes share the GPU. A newly admitted request with a long prompt runs a big, compute-saturating prefill - and while it runs, every in-flight decode stalls. Users see their token streams freeze; ITL spikes from tens of milliseconds to seconds. Schedulers that prioritise prefill optimise TTFT at the cost of ITL; schedulers that hold prefills back protect ITL but wreck TTFT and throughput. With 50K - 100K-token prompts this isn't an edge case - one document-heavy request degrades everyone.

Chunked prefill (popularised by Sarathi/Sarathi-Serve, now standard in vLLM and others) splits the prompt into chunks - e.g., 512-2048 tokens - and processes one chunk per iteration, batched together with the ongoing decode steps. The long prefill becomes a background process that advances incrementally instead of a bulldozer that monopolises the GPU.

Two benefits:

  • Stall-free decodes: ITL stays stable regardless of what prompts arrive. The tail of inter-token latency - the thing chat users actually feel - is protected.
  • Better GPU efficiency: decode-only batches are memory-bound (compute idle); prefill chunks are compute-heavy (bandwidth spare). Mixing them in one batch fills both pipes - the prefill piggybacks on the weight-reads decode was doing anyway.

Costs: the chunked prompt's own TTFT gets somewhat worse (its prefill is spread over many iterations, and each chunk's attention must re-read the KV of all earlier chunks, adding some bandwidth overhead), and there's a tuning knob - chunk size - trading TTFT against ITL protection. Interviewers like hearing the framing: chunked prefill converts an interference problem into an explicit, tunable scheduling tradeoff. It's also a stepping stone to the fuller fix: disaggregating prefill and decode onto separate pools.

Worth sketching. One iteration drawn as a mixed batch shows why this is a utilisation win, not just a fairness patch.

flowchart LR
    A["Iteration N"] --> B["One prefill chunk of 512-2048 tokens<br/>plus every in-flight decode step"]
    B --> C["Chunk fills the compute pipe,<br/>decode fills the bandwidth pipe"]
    C --> D["Iteration N+1: next chunk"]
    D --> B
    B --> E["ITL stays flat while<br/>a 100K prompt is admitted"]

What a good answer covers

  • The problem: in a continuously batched engine, prefills and decodes share the GPU
  • A newly admitted request with a long prompt runs a big, compute-saturating prefill - and while it runs,…
  • Users see their token streams freeze; ITL spikes from tens of milliseconds to seconds
  • Schedulers that prioritise prefill optimise TTFT at the cost of ITL; schedulers that hold prefills back…
  • With 50K - 100K-token prompts this isn't an edge case - one document-heavy request degrades everyone

Key terms: Chunked prefill · Stall-free decodes · Better GPU efficiency

Interviewer follow-ups to expect

  1. How would you pick the chunk size?

  2. Why does mixing a prefill chunk into a decode batch improve hardware utilization rather than just sharing the pain?

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