Put a one-line answer and a 2,000-token report in the same batch, and they finish nearly two thousand decode steps apart, because each step produces one token per request. A server that holds the batch until the slowest request ends leaves the short request’s slot idle for all those steps, and everything in the queue waits behind it.
Continuous batching is how modern serving engines avoid that: they rebuild the batch at every step, so finished requests leave and queued ones join. This guide explains how it works, how it differs from static and dynamic batching, and the limit that appears once scheduling stops wasting compute: KV cache memory.
What is continuous batching?
Continuous batching is a scheduling technique for large language model (LLM) inference that rebuilds the batch at every generation step. After each forward pass, the server retires finished sequences. It admits waiting requests as KV cache memory and the per-step token budget allow, without waiting for the current batch to finish.
Orca introduced iteration-level scheduling; TensorRT-LLM uses the name in-flight batching for the same step-level approach. You may also see it called dynamic batching, but that term can mean request-level batching instead. The distinction is when membership can change, rather than the label alone.
A request-level completion barrier holds up both directions: short requests can’t leave early, and new requests can’t join until the batch finishes. Orca (Yu et al., OSDI 2022) removed that barrier and reported 36.9x the throughput of NVIDIA FasterTransformer at the same latency on GPT-3 175B across 16 A100 GPUs. That is a 2022 comparison with a request-level baseline, not a current-engine benchmark.
Why batching matters for LLM inference
During memory-bound decode, moving weights and KV state dominates the time spent producing each token. A single sequence does relatively little arithmetic per weight read. Batching spreads that read across multiple sequences, allowing more useful work before the weights must be loaded again. The benefit depends on how much spare compute the workload leaves available.
Prefill processes known prompt tokens together in highly parallel matrix operations, while decode advances each sequence one token at a time. Mixing those workloads changes how a step uses compute and memory bandwidth. Our guide to the two phases of LLM inference, prefill and decode, covers their hardware profiles; our guide to LLM serving places batching among the other deployment levers.
More sequences also require more KV state. Batch growth stops when the memory needed for those requests no longer fits, even if batching could use more compute.
Static vs. dynamic vs. continuous batching
The three strategies differ in when the batch can change.
| Strategy | When a batch starts | Can a finished request leave early? | Can a new request join mid-batch? | Best fit |
|---|---|---|---|---|
| Static batching | Once a fixed number of requests has arrived | No, it waits for the longest request | No | Offline jobs with uniform input and output lengths |
| Dynamic batching (request-level) | When the batch is full or a timeout expires | No | No | Models with a roughly fixed cost per request, such as image generation |
| Continuous batching (iteration-level) | Whenever a slot is free and a request is waiting | Yes, after the step that emits its end-of-sequenc e token | Yes, at the next step if KV memory and token budgets allow | Interactive LLM serving with variable output lengths |
Dynamic batching can refer to two different scheduling boundaries. Triton’s dynamic batcher gathers requests until its size or bounded-delay condition is met, then runs them together at request granularity; max_queue_delay_microseconds controls that wait. Anyscale’s 2023 explanation and Hugging Face’s walkthrough also use dynamic batching for replacing finished sequences between iterations.
We use the request-level meaning because Triton ships a feature under that name, and it is a different mechanism: dynamic batching decides when a batch starts; continuous batching decides what is in the batch on every step.
Request-level dynamic batching still fits fixed-cost work such as image generation, and Machine Learning Mastery notes it can give a faster time to first token (TTFT) under light LLM traffic.
How continuous batching works, step by step
Scheduling at every iteration
Each step is a forward pass over scheduled tokens from active sequences. In TensorRT-LLM, a request that hits its stop token leaves before the next execution iteration, allowing a queued request to enter. A newly admitted request processes its prompt in one prefill step or several chunks before producing its first token. vLLM V1 schedules prompt and generated tokens through the same per-request token accounting.
Consider a four-slot batch. A needs eight steps, B needs two, and C and D need three each. E, F, and G wait in the queue, needing four, three, and five steps respectively.

| By the end of step 8 | Static batching | Continuous batching |
|---|---|---|
| Requests finished | 4 (A, B, C, D) | 7 (A to G) |
| Slot-steps doing work, of 32 | 16 | 28 |
Continuous batching’s four idle slot-steps come from an empty queue at steps 7 and 8, not from waiting on A. It is an illustration, not a benchmark, since a prefill step costs more than a decode step.
Mixing prefill and decode in one batch
Mixed batches combine several prompt tokens for a new request with one next-token input for each decoding sequence. Padding every sequence to the longest input wastes work: the Hugging Face eight-sequence example with a 100-token prompt adds 693 padding tokens. Packed batching instead concatenates the useful tokens and uses attention boundaries to separate sequences. TensorRT-LLM requires packed inputs for in-flight batching.
Orca’s selective batching combines tokens across requests for non-attention operations, while handling each request’s attention separately. That split lets differently shaped sequences share the operations that can be batched without forcing all attention inputs into one padded shape.
Chunked prefill
A long prefill can occupy a step long enough to delay the next token of every sequence already decoding. Chunked prefill spreads that prompt processing across several iterations instead. SARATHI’s decode-maximal schedule pairs one prefill chunk with the remaining decode work, letting decodes share a step without waiting for the entire prompt to be processed.
Chunking also affects TTFT. Smaller chunks lower arithmetic intensity, and later chunks must re-read earlier chunks’ KV cache. TensorRT-LLM reports lower average TTFT with chunking, but higher TTFT for the few requests whose prefill would otherwise finish in one iteration. When the phases still interfere too much, disaggregated serving separates them onto different GPU pools.
KV cache memory is what caps the batch
Continuous batching removes idle slots; it does not create memory. Every request in flight keeps its KV cache in GPU memory while it is active, growing by one token per decode step, and when free KV blocks run out, the scheduler stops admitting requests, however much compute sits unused. In vLLM’s scheduler, a waiting request whose blocks cannot be allocated is not scheduled.
Every concurrent request holds KV memory
For OPT-13B at FP16, KV state requires 800 KB per token, reaching 1.6 GB for a 2,048-token request in the PagedAttention paper’s 2023 example. That leaves room for only tens of requests. Anyscale’s June 2023 estimate for a 13B model on a 40 GB A100 was about 28 sequences at 512 tokens, or 7 at 2,048.
Grouped-query attention shrinks the per-token cost, not the shape of the problem. Qwen3-8B’s config works out to 144 KiB per token in BF16, so a 10 GiB KV budget holds very different batches by context length:
| Tokens per request | KV cache per request | Requests that fit in 10 GiB |
|---|---|---|
| 1,024 | 144 MiB | 71 |
| 8,192 | 1.125 GiB | 8 |
| 32,768 | 4.5 GiB | 2 |
That is our arithmetic, with every request at full length. To work out the KV cache size for your model and context length, follow our step-by-step sizing method. Our guide to how much GPU memory the KV cache takes per request covers the levers that shrink it.
Paging the cache lets more requests fit
Orca reserved each request’s maximum KV capacity up front and held it until completion. In the earlier systems profiled by Kwon et al., only 20.4% to 38.2% of KV memory stored actual token state. Allocating blocks as sequences grow lets PagedAttention retain less unused capacity, leaving room to batch more requests. Its SOSP 2023 evaluation reported 2-4x higher throughput at comparable latency against FasterTransformer and Orca on OPT and LLaMA models, using A100 GPUs with ShareGPT and Alpaca traces. Our PagedAttention guide goes deeper.
What happens when the cache runs out: preemption
Paging raises the ceiling without removing it. When vLLM can’t allocate enough KV space for the batch, it can preempt a running request and reconstruct its state once capacity returns. V1 uses RECOMPUTE by default, so a request may pay for prefill again and take longer end to end. Under v0.30.0’s default first-come-first-served policy, the most recently added running request is preempted; with priority scheduling across workloads, the lowest-priority request goes first.
The vLLM tuning options address capacity from either side: increase gpu_memory_utilization (0.92 in v0.30.0), reduce max_num_seqs or max_num_batched_tokens, or use tensor or pipeline parallelism so each GPU stores less of the model. Reserving too little KV memory limits concurrent requests and therefore throughput. SGLang also retracts requests when its KV pool fills; supporting more simultaneous requests requires more cache capacity.

Where tiered KV cache fits
Tiering does not change that arithmetic for running requests. It changes the cost of work around the batch, since much KV cache describes context that comes back: shared system prompts, popular documents, earlier conversation turns. vLLM keeps a prefix cache in GPU memory by default and offloads KV cache beyond it only when configured, for example with --kv-offloading-size and its native or LMCache backends, or through a KV connector set with --kv-transfer-config.
Tensormesh Platform manages KV cache across GPU memory, host memory, and storage for vLLM fleets on Kubernetes. It is not a scheduler and does not replace vLLM’s scheduler. We keep active state in GPU memory, the hot set in host memory, and a larger retained cache in filesystem-backed storage. Saved state outside a pod can be reused after a restart, and cross-node sharing, listed as Preview in v1.0.0, lets a node retrieve compatible cached work from another instead of recomputing it. We were founded by the creators of LMCache and build on it; LMCache remains open source. This reduces repeated prefill work rather than raising the active batch limit: a new request can load retained context instead of rebuilding it on the GPU. Tensormesh Platform runs with vLLM today, and SGLang support is next.
Continuous batching in vLLM, SGLang, and TensorRT-LLM
All three batch continuously; the knobs differ.
vLLM has continuous batching, chunked prefill, and prefix caching built in. V1 prioritizes pending decode work, then fills the remaining max_num_batched_tokens budget with prefill. A prompt that doesn’t fit the remaining budget is split into chunks; chunked prefill is enabled by default where possible. Two limits govern each step: max_num_seqs bounds its sequence count, and max_num_batched_tokens bounds its token count. GPU-dependent defaults matter when comparing setups. For v0.30.0, they are:
| GPU memory per device | vllm serve tokens / seqs | LLM class tokens / seqs |
|---|---|---|
| Under 70 GiB, and any A100 | 2048 / 256 | 8192 / 256 |
| 70 GiB or more, not A100 (H100, H200) | 8192 / 1024 | 16384 / 1024 |
| 160 GiB or more (B200, B300) | 16384 / 1024 | 16384 / 1024 |
--performance-mode throughput doubles both defaults when you leave them unset, and v0.31.0, released October 5, keeps the same table. vLLM’s guidance is that budgets around 2048 favor inter-token latency (ITL), larger ones favor TTFT, and values above 8192 suit throughput on smaller models and large GPUs. On an H100, where vllm serve defaults to 8192 tokens and 1024 sequences, a latency-first deployment might pin both lower:
vllm serve Qwen/Qwen3-8B \
--max-num-seqs 256 \
--max-num-batched-tokens 2048At startup, vLLM logs “GPU KV cache size: N tokens, Maximum concurrency for M tokens per request: X.XXx”, where M is the model’s maximum length. That second figure is how many maximum-length requests fit in the KV cache at once, the memory ceiling on the batch before max_num_seqs applies. Under load, watch two of vLLM’s Prometheus metrics, vllm:num_requests_waiting and rate(vllm:num_preemptions_total[5m]): a growing queue with climbing preemptions is a reason to check KV capacity alongside compute utilization.
SGLang continuous batching runs in its scheduler’s decode loop. Its server arguments expose --max-running-requests and --chunked-prefill-size, where -1 disables chunking. Our vLLM vs SGLang comparison covers how their prefix reuse differs.
TensorRT-LLM bounds a batch with max_batch_size and max_num_tokens (8192 by default since v0.11). Sizing the token limit to the workload leaves more memory for KV state and can make room for more concurrent requests. Hugging Face TGI also implements continuous batching, though the project is in maintenance mode.
The trade-offs: throughput, TTFT, and inter-token latency
Continuous batching raises throughput and, under moderate load, lowers latency. In Anyscale’s June 2023 benchmark, vLLM reached up to 23x the throughput of a static-batching Hugging Face Pipelines baseline on OPT-13B, with one 40 GB A100 and 512-token prompts. Those engines have since been rewritten, and Anyscale suspected much of the gain came from vLLM’s dynamic memory reservation rather than scheduling alone.
The benefit shrinks as the server fills and new requests queue for fewer free slots; Anyscale saw latency climb between 1 and 4 queries per second for systems with smaller maximum batch sizes. That is the KV cache limit again, showing up as queueing time, and the per-step token budget is the other dial:
| If you are missing | Move | vLLM setting |
|---|---|---|
| ITL targets while long prompts arrive | Smaller per-step budget | max_num_batched_tokens near 2048 |
| TTFT targets on long prompts | Larger per-step budget | max_num_batched_tokens above 8192 |
| Throughput, with preemptions in the logs | More KV cache per GPU | gpu_memory_utilization , tensor or pipeline parallelism |
Measuring TTFT properly is the subject of our TTFT guide.
Key takeaways
- Continuous batching schedules per step, not per request, so finished sequences leave and queued requests join between steps.
- “Dynamic batching” means two things; the request-level kind cannot release a request early.
- When KV cache capacity is the bottleneck, scheduling alone can’t admit more requests; the server must wait or preempt work.
- Chunked prefill trades some TTFT for smoother decoding, with the per-step token budget as the dial.
Before tuning anything, read two numbers from your own deployment: the “Maximum concurrency” line vLLM prints at startup and the rate of vllm:num_preemptions_total under real traffic. If KV cache memory is what limits your serving, see how Tensormesh Platform manages it across GPU memory, host memory, and storage.
Contact our team to discuss KV cache capacity for your vLLM deployment.
Frequently asked questions
Is continuous batching the same as dynamic batching?
Triton-style request-level dynamic batching groups requests until a size limit or timeout and runs the batch to completion. Continuous batching changes membership between steps. Anyscale’s 2023 post uses “dynamic batching” for the continuous approach, so compare scheduling boundaries rather than names.
What is in-flight batching?
In-flight batching is TensorRT-LLM’s name for continuous, iteration-level batching. It runs prefill and decode sequences together with packed inputs, avoiding padding them all to the longest sequence.
Does continuous batching increase latency?
A waiting request can start at the next step once KV memory and the token budget allow, rather than waiting for a whole batch to finish. Latency can still rise as the server saturates, and prefill mixed into a step can slow inter-token latency. The per-step token budget controls how much prefill work shares that step.
What limits the batch size in continuous batching?
KV cache memory, plus caps such as vLLM’s
max_num_seqsandmax_num_batched_tokens, because each running request holds KV cache in GPU memory and the scheduler stops admitting requests, or preempts running ones, once free blocks run out.How does LLM batching differ from batch inference?
Offline batch inference runs a model over a static dataset as a bulk job, which is what vLLM’s
LLMclass is for. Serving-time batching, including continuous batching, groups live requests on an online server so they share the weight load while users wait.