What is chunked prefill?

Chunked prefill is an inference scheduling technique that splits a long prompt's prefill work into fixed-size chunks and processes them in the same batches as other requests' decoding steps.

Its relation to prefill is that of work to scheduling: prefill handles the whole prompt in one pass, while chunked prefill spreads the same work over several steps with an unchanged result. Continuous batching adds and removes requests from the batch; chunked prefill limits how much room long prompts take within those batches.

Topic
Inference and performance
Also known as
Chunked prefills
Origin
2023, Agrawal et al., SARATHI

How chunked prefill works

  1. An incoming long prompt is split into chunks by a token budget.
  2. At each step the server forms a batch: decode tokens of ongoing requests plus one prefill chunk that fits the budget.
  3. Each chunk's keys and values are added to the KV cache; the next chunk attends to earlier ones.
  4. When the last chunk is done the request moves to decoding and generates tokens with the others.

In more detail

Compute-bound versus memory-bandwidth-bound

Prefill is compute-bound (saturated matrix multiplications), whereas autoregressive decoding is memory-bandwidth-bound (loading full model weights for just one token per request). Piggybacking a prefill chunk onto a decode batch raises arithmetic intensity, letting the GPU compute prefill tokens using idle FLOPs that decode alone leaves unused.

Repeated KV cache reads and the token budget

Each subsequent prefill chunk must read the Key and Value tensors of all earlier chunks from GPU HBM during attention. If the chunk token budget is set too small, repeated KV reads consume extra memory bandwidth and reduce throughput, so servers tune `max_num_batched_tokens` to balance TTFT, ITL and throughput.

Default use and the link to prefill-decode disaggregation

In current inference stacks (such as vLLM and SGLang), chunked prefill is widely enabled by default for single-node serving and is often paired with prefix caching. For large multi-node clusters, however, Prefill-Decode (P/D) disaggregation separates prefill and decode onto distinct GPUs entirely, reserving chunked prefill mainly for intra-node or mixed pools.

Commonly confused terms

TermHow it differs
Prefill-decode disaggregationChunked prefill interleaves prefill chunks and decode tokens on the same GPUs, whereas prefill-decode (P/D) disaggregation separates prefill and decode onto dedicated GPU pools connected via high-speed fabric to eliminate interference completely.
Prefix cachingAutomatic prefix caching reuses previously computed KV cache blocks for shared prompt prefixes (such as system prompts), whereas chunked prefill schedules the computation of uncached prompt tokens across multiple steps.

Why chunked prefill matters for on-premises AI

Without chunking, a long prompt's prefill occupies the GPU alone for a while, pausing the token stream of other users mid-answer. Chunked prefill shortens these pauses, makes inter-token latency steadier and keeps the GPU busier. The price is that the long prompt's own time to first token may grow. Chunk size balances these two goals and is chosen from the organisation's real prompt distribution.

ON-PREMISES EXAMPLE

In a university's in-house assistant some users upload long thesis drafts while most ask short questions; with chunked prefill on, long uploads no longer interrupt the answer stream for short questions.

Common questions

Does chunked prefill change the result?

No. The same tokens go through the same attention computation, only spread over several steps. What changes is scheduling.

How is chunk size chosen?

Small chunks keep other users' streams smoother but delay the long prompt's first answer. Large chunks do the opposite; the value is set by measuring real traffic.

Sources

In the glossary: Glossary, A to C

What does this term mean for your infrastructure?

We can work out together in a technical assessment how it maps onto your data, hardware and security requirements.

Request a technical assessment →

This site sets no cookies. Visitor numbers are counted in aggregate using a cookieless method that does not identify anyone. See the Privacy Policy for details.