chunked-prefill -- splitting a prefill so it stops stalling everyone else

Reading a prompt and writing a reply are different jobs, and a server does one round of work at a time. When someone pastes an enormous document, reading all of it in one round occupies the machine, and everybody else's reply stops mid-sentence until it is done. Cutting the reading into slices and putting one slice into each round, beside the next word for everyone else, keeps the other replies flowing. The cost lands on the person who pasted the document: their wait for a first word gets a little longer, because their reading is now spread over several rounds instead of taking one to itself.

Interactive page: the scheduling consequence of the two inference regimes. A serving engine runs one batched step at a time, so a long prompt's prefill -- one big compute step -- blocks every other sequence's next token while it runs. Chunked prefill splits that prefill into pieces of at most a per-step token budget — a few hundred to a few thousand tokens in a real engine (vLLM's max_num_batched_tokens, tuned around 2048 for latency 8192+ for throughput); the toy budget on this page is far smaller so the packing is visible packs each piece into a step alongside the waiting sequences' decode tokens, up to a per-step token budget. Anchor: A4 KV cache / runtime shape (Family J, serving time). Companion to prefill-vs-decode, which shows why the two regimes have different shapes; this page shows what a scheduler does about it.

What it shows

The millisecond figures come from a deliberately simple illustrative cost model -- a fixed per-step overhead plus a per-token cost -- chosen so the shape of the trade is readable. They illustrate the mechanism; they are not a measurement of any particular engine or accelerator.

Press play (or scrub) to walk the scheduler steps; drag the dashed budget line up and down to re-pack the timeline and watch the two numbers move in opposite directions; hover a step for exactly what it carried, or a gap in a token strip for what occupied the scheduler while that sequence waited.

Render tier

T1 (Canvas2D throughout: stacked step bars, arrival strips, budget sweep).

Wiring

layout.mount + controls (prompt length, waiting sequences, token budget, scheduler mode) + a Transport over the scheduler steps (autoplay + loop) onPointer budget-line drag + hover-to-inspect + two challenges + an A/B compare across the two scheduler modes. URL hooks: every control is mirrored into the query string (?P= ?S= ?budget= ?mode=), plus ?step=N, ?hover=x,y and ?play=1. Source: page.js.