← Reference · Nestor G Pestelos Jr · Print this page

Systems Engineering · Machine Learning

Chunked Prefill

Reference entry · last updated September 8, 2026

Chunked prefill is an inference scheduling optimization for large language models that partitions long prompt prefill requests into smaller token chunks across multiple execution iterations. By interleaving chunked prompt evaluation with active token decoding, chunked prefill prevents long input prompts from blocking decode steps, bounding tail inter-token latency without sacrificing GPU compute saturation.

1. First Principles: The Prefill-Decode Interference Problem

Serving systems for autoregressive language models handle two fundamentally asymmetric computational phases [1]:

In standard continuous batching systems, the scheduler prioritizes whole requests. When an incoming request carries a long prompt (such as a 16k or 32k token document), the GPU spends hundreds of milliseconds exclusively computing the prefill. During this window, all ongoing decode streams are paused. This head-of-line blocking creates extreme tail latency spikes in Inter-Token Latency (ITL), degrading user streaming experiences.

2. Mechanism and Token Budget Allocation

2.1 Budgeting and Slicing

Chunked prefill resolves phase contention by setting a maximum token budget \(T_{\text{budget}}\) per iteration step (for instance, 512, 1,024, or 2,048 tokens) [1, 2]. When a request arrives with prompt length \(N_{\text{prompt}} > C_{\text{chunk}}\), the scheduler slices the prompt into consecutive chunks:

\[C_1, C_2, \dots, C_m \quad \text{where} \quad \sum_{j=1}^m |C_j| = N_{\text{prompt}}\]

In each forward pass, the model processes only one chunk \(C_j\) for that request, caching its resulting KV activations into memory before yielding to the next scheduling iteration.

2.2 Piggybacking and Mixed Batching

Rather than executing prefill chunks and decode steps in separate batches, chunked prefill co-schedules them in a single mixed batch. The iteration batch satisfies:

\[B_{\text{decode}} + \sum_{i} |C_{\text{chunk}, i}| \le T_{\text{budget}}\]

This technique (termed "piggybacking" in Sarathi) creates a complementary hardware synergy: the memory-bandwidth-bound decode tokens piggyback on the compute-heavy prefill chunk forward pass [1]. Tensor cores remain saturated with chunk GEMM (General Matrix Multiply) operations while weights are streamed to advance decode streams, maximizing aggregate hardware efficiency.

3. Performance Trade-offs: ITL Stability vs. TTFT

Chunked prefill introduces a deliberate engineering trade-off between tail inter-token latency and time to first token:

4. Systems Architecture and Disaggregation

Chunked prefill is standard in modern inference engines including vLLM and TensorRT-LLM. In larger multi-node production clusters, chunked prefill coexists with physical disaggregation (such as Splitwise and DistServe) [3, 4]. While disaggregated serving assigns separate GPU pools to prefill and decode workloads, chunked prefill remains essential within homogeneous clusters and within prefill workers handling variable context lengths.

See also

References

  1. A. Agrawal et al., "Sarathi: Efficient LLM Inference by Chunked Prefills with Piggybacking," arXiv preprint arXiv:2308.16369, 2023. Free full text: https://arxiv.org/abs/2308.16369
  2. A. Agrawal et al., "Taming Throughput-Latency Tradeoff in LLM Inference with Sarathi-Serve," in Proceedings of the 18th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2024, pp. 117–134. Free full text: https://www.usenix.org/conference/osdi24/presentation/agrawal
  3. Y. Zhong et al., "DistServe: Disaggregating Prefill and Decoding for Goodput-optimized Large Language Model Serving," in Proceedings of the 18th USENIX Symposium on Operating Systems Design and Implementation (OSDI), 2024, pp. 193–210. Free full text: https://www.usenix.org/conference/osdi24/presentation/zhong
  4. P. Patel et al., "Splitwise: Efficient Generative LLM Serving Using Phase Separation," in Proceedings of the 51st Annual International Symposium on Computer Architecture (ISCA), 2024, pp. 1008–1024. Free full text: https://arxiv.org/abs/2311.18677
  5. W. Kwon et al., "Efficient Memory Management for Large Language Model Serving with PagedAttention," in Proceedings of the 29th ACM Symposium on Operating Systems Principles (SOSP), 2023, pp. 611–626. Free full text: https://arxiv.org/abs/2309.06180