What is continuous batching?
Continuous batching is a scheduling method in language model serving that reorganises the batch at every decoding step, removing finished requests and adding queued ones immediately.
It differs from dynamic batching in its scheduling unit: dynamic batching groups requests arriving within a time window and processes the group until it finishes, while continuous batching updates the batch each step. Its main aim is higher hardware use and total throughput, not speeding up a single request.
- Topic
- Inference and performance
- Also known as
- Iteration-level scheduling, in-flight batching
- Origin
- 2022, Yu et al. (Orca)
How continuous batching works
- At each model step the inference server generates the next token for every request in the batch together.
- A request whose answer is complete leaves the batch at that step; a queued request takes the free slot without waiting for the longest request to finish.
- Prefill for new requests and decoding for ongoing ones are interleaved in the same or consecutive steps.
- This needs flexible KV cache management; PagedAttention allows it by allocating memory in blocks.
In more detail
Chunked prefill and prefill-decode interference
Inserting a large unchunked prompt prefill into an active decoding batch spikes Inter-Token Latency (ITL / TPOT) for every user currently streaming a reply. Chunked prefill breaks long prompts into fixed token budgets across consecutive steps, keeping streaming smooth while still maintaining high GPU compute utilisation.
Disaggregated prefill and decode serving
Because prefill is compute-bound while autoregressive decoding is memory-bandwidth-bound, mixing them on the same GPU creates resource contention. Disaggregated serving (such as DistServe and Splitwise) assigns dedicated GPU pools to prefill and decode, transferring KV caches over fast interconnects to meet strict TTFT and TPOT SLAs independently.
The memory bandwidth bottleneck, TTFT, TPOT and goodput
Continuous batching improves GPU arithmetic intensity during decoding: since generating one token per request is limited by memory bandwidth rather than FLOPs, reading model weights once to produce a token for dozens of concurrent requests multiplies effective throughput. Serving performance is therefore tracked via Time-to-First-Token (TTFT), Time-Per-Output-Token (TPOT) and SLO-compliant goodput.
Preemption and recompute policies when the KV cache fills
When active requests fill the KV cache pool completely under continuous batching, the scheduler must preempt lower-priority or newly arrived requests, either swapping their KV blocks to CPU RAM or discarding and recomputing them later. Proper batch sizing and admission limits prevent thrashing under bursty load.
Commonly confused terms
| Term | How it differs |
|---|---|
| PagedAttention | Continuous batching is the request-scheduling mechanism across decode iterations; PagedAttention is the virtual-memory KV cache allocation technique that makes dynamic batch growth and eviction memory-safe without fragmentation. |
| Speculative decoding | Speculative decoding accelerates single-request generation latency by verifying multiple draft tokens in parallel, whereas continuous batching maximises multi-request GPU utilisation and aggregate throughput. |
Why continuous batching matters for on-premises AI
When answer lengths vary widely, classic batching makes short requests wait for the longest and leaves the GPU idle; continuous batching fills that gap. The same in-house hardware then serves more concurrent users and hardware cost per request falls. The effect depends on load, request lengths and server settings; under heavy load per-request latency can rise. Settings are therefore tuned against throughput and latency targets together.
A bank's in-house application assessment assistant runs with continuous batching under changing daily load; short questions are answered without waiting for long report requests to finish.
Common questions
Does continuous batching always cut latency?
No. The effect depends on load, request lengths, resources and server settings. The main gain is total throughput; under heavy load individual latency can rise.
Does continuous batching need separate software?
Most current language model inference engines offer it built in. Batch size and memory limits are tuned to the organisation's load profile at setup.
Related terms
Sources
- Yu et al., Orca: A Distributed Serving System for Transformer-Based Generative Models, OSDI 2022
- Kwon et al., Efficient Memory Management for Large Language Model Serving with PagedAttention, SOSP 2023
In the glossary: Glossary, A to C