Why grouping requests pays so well
This has to come first, or the rest of the page reads as a collection of engineering tricks.
Inference with a large language model (LLM) is limited by memory bandwidth, not by compute: to produce one token, the chip must first stream all the model's weights out of memory, and its arithmetic units spend most of their time waiting. The full argument is in Quantization: the concepts.
And here is the whole point: that stream of weights can serve several requests at once. Streaming 14 GB of weights to answer one request, or to answer fifty, is the same stream. The fifty requests split the bill.
Put a number on it, in two lines of arithmetic. On an 80 GB NVIDIA A100 graphics processing unit (GPU), the datasheet gives roughly 312,000 billion operations per second in 16-bit format and roughly 2,000 billion bytes read per second: the chip can therefore perform about 156 operations in the time it takes to read one byte. Each weight read (2 bytes in FP16) feeds two operations per request being processed. So:
- with 1 request: 1 operation per byte read. You are using under 1 % of the compute.
- with about 150 requests: you approach 156 operations per byte, and the chip stops waiting.
That is why batching is the highest-return lever in served inference: it does not make the chip faster, it stops leaving it idle. No other technique recovers so large a factor on total throughput, and it costs nothing in quality, the model is untouched.
Once the batch is well filled the chip no longer waits, and the techniques that exploited that waiting stop paying. That is exactly why speculative decoding and quantization deliver their finest gains at low load and much less at high load. Inference techniques do not simply add up: they compete for the same idleness.
Naive batching, and why it wastes
Picture a restaurant where the waiter waits for all eight diners at a table to finish before clearing anything. If one finishes a starter in five minutes and another takes forty-five, the first seven sit there. The waiter is stuck, the next tables go unserved.
That is precisely static batching. You group eight requests, process them together, and wait for the last one to finish. If one request produces 500 tokens and another 50, the GPU keeps computing for the seven already-finished requests until the longest one stops.
Technically the mechanism is padding: to process requests together they must be the same length, so the shorter ones get filled out with empty slots. The vLLM authors describe it this way: a straightforward batching technique pads the inputs and outputs to equalize their lengths, wasting both GPU computation and memory.
Two distinct wastes, then, worth naming separately:
- discarded computation for requests that are already done;
- occupied batch slots that could have held waiting requests.
What "continuous" adds
Instead of reasoning per whole request, you reason per iteration: one iteration produces exactly one token for each active request. The technical name for the idea, owed to the authors of the Orca system in 2022, is iteration-level scheduling.
At each iteration:
- produce one token for every request in the batch;
- as soon as a request finishes (it has produced its end-of-sequence token (EOS) or hit its length limit) remove it immediately;
- take a new request from the queue at once to fill the freed slot;
- the batch therefore stays constantly full.
The crucial point, in one sentence: you do not wait for the longest request to finish. An arriving request no longer waits for a whole batch to complete; at worst it waits for one iteration, the time of a single token. The restaurant clears plate by plate and seats the next diner right away.

The two phases: prefill and decode
Serving an LLM actually means alternating between two very different regimes, and that distinction explains half the engineering decisions in the field.
- Prefill: processing the user's prompt. Every token of the prompt is known in advance, so they can all be processed at once. Lots of computation, little weight-reading per unit of useful work: this phase is compute-bound.
- Decode: producing the answer, one token after another, each waiting on the previous one. Little computation, a full re-read of the weights per token: this phase is bandwidth-bound.
These are opposite problems, and that is fortunate: continuous batching mixes both in the same batch. While one request is in its compute-hungry prefill, others are in their memory-hungry decode. Each fills the other's slack.
Chunked prefill
An unpleasant consequence of the mixing: a very long prefill monopolizes the chip. An 8,000-token document processed in one block makes for an absurdly long iteration, and throughout it the other requests produce nothing. Their generation visibly freezes.
Hence chunked prefill: cut the long text into slices (say 512 tokens) and process one slice per iteration, mixed in with the decode tokens of other requests. The prefill is no faster overall, but it no longer blocks anyone.

Dynamic batching
A complementary variant, working on the batch's composition rather than its turnover:
- wait a little before starting: accumulate arriving requests for a few tens of milliseconds, so the first iteration runs on a well-filled batch rather than a nearly empty one;
- adjust the batch size according to the GPU memory still available and the estimated length of the answers.
The real ceiling: attention-cache memory
If the argument stopped there, you would fill the batch to 150 requests and call it a win. That is not what happens, and the reason is memory.
The attention cache, or key-value cache (KV cache), holds the attention keys and values already computed for each request, so they need not be recomputed at every new token. There are two tensors to keep, not three: why the queries are not stored is explained in KV cache.
Let us do the arithmetic in the open, for a 7-billion-parameter model with 32 layers and an internal dimension of 4,096, in FP16:
The factors, one at a time. The 2 on the left is because there are two tensors to keep, keys and values. The 32 is the number of layers: each layer has its own cache. The 4,096 is the model's internal dimension. The 2 bytes on the right is the cost of one number in FP16 (16 bits ÷ 8 = 2 bytes). That comes to about 0.5 MB per token, and therefore:
| Quantity | Cache memory |
|---|---|
| 1 token | about 0.5 MB |
| one 4,096-token request | about 2.1 GB |
| 32 requests of that size | about 69 GB |
Sixty-nine gigabytes, on an 80 GB A100 that already has 14 taken up by the model weights. Thirty-two requests are enough to saturate the card, a long way short of the 150 the bandwidth arithmetic allowed. The ceiling is not compute, it is memory.
The calculation above assumes each attention head has its own keys and values. Recent models share one set of keys and values across several heads, which divides this cache directly, that is the subject of Grouped-query attention. A good share of the architectural effort of recent years goes precisely into pushing back the ceiling in that table.
How much to reserve when you do not know?
The next problem is nastier: you do not know in advance how many tokens the answer will run to. Three ways to handle it:
- Reserve the maximum for each request the moment it arrives. Simple, and very expensive: the vLLM authors measured that in the systems of the day, only 20 % to 38 % of cache memory was actually holding tokens. The rest was reserved for nothing.
- Allocate in small pages, on demand, that is PagedAttention, now the standard way. Waste is confined to the last partially filled page. The mechanism, and the analogy with an operating system's virtual memory, is explained in PagedAttention and vLLM.
- Organize the caches as a prefix tree to share common beginnings across requests automatically, useful when every request starts with the same system instructions.

At high load it is the attention cache, not the model weights, that decides how many requests can run at once. All the engineering of LLM serving revolves around managing that memory, which is why batching and PagedAttention arrived together and are best understood together.
When memory runs out anyway
The batch is full, one more request arrives, there is no room. Two ways out, both unpleasant:
- swapping: move one request's cache out to the computer's main memory (CPU RAM). The request is not lost, but bringing it back costs a slow transfer;
- recomputation: throw the cache away outright and rebuild it later when room frees up. You redo work already done, but you transfer nothing.
Which to choose depends on the ratio between the bandwidth of the link to main memory and the speed of recomputation, once again, a question of pipe versus compute.
You also have to arbitrate between requests. An interactive conversation wants an answer now; a background pass over a thousand documents can wait. Servers therefore schedule by priority, to honour different service level agreements (SLA) depending on the request type.
The three measures, and the trade-off they reveal
You cannot discuss inference performance without separating three quantities that are routinely conflated:
- time to first token (TTFT): how long the user stares at a blank screen. This is perceived responsiveness, and it depends mostly on prefill and queue waiting;
- time per output token (TPOT): the average interval between two words appearing. This is perceived smoothness;
- throughput: the total number of tokens per second the machine produces across all requests. This is what sets the cost.
And here is the page's central trade-off, stated without makeup: filling the batch raises total throughput and degrades every request's time per token. That is not an implementation flaw, it is arithmetic: an iteration handling fifty requests takes longer than one handling five, so each user sees their words arrive a little more slowly. You trade individual comfort for total cost.
For an interactive conversation you want a time per token giving at least twenty-odd words per second, faster than reading, hence imperceptible. For background processing, individual latency does not matter at all and you fill the batch to whatever memory allows. The same machine, with the same model, is tuned differently for each use: that is the scheduler's job, and it is a setting, not a property of the model.
What it looks like in practice
Anyscale published a measured comparison, and it deserves quoting with its conditions: OPT-13B, a single 40 GB A100 GPU, a simulated load of requests arriving at a fixed average rate. Against naive batching they measure:
- about 8× more throughput from continuous batching alone;
- up to 23× more throughput once paged cache-memory management is added;
- about 4× more throughput from an optimized model implementation without continuous batching.
Do not carry those factors elsewhere as they stand: they depend entirely on how variable the answer lengths are in the tested load. The more heterogeneous the lengths, the more static batching wastes, and the more the switch to continuous pays. On a load where every answer is the same length, the gain would be near zero.
For comparison, the vLLM authors measure 2× to 4× more throughput at equal latency against systems that already did continuous batching, such as Orca. The two figures do not contradict each other: they are not measured against the same baseline. That is the classic trap with announcements of this kind.
The last idle time: the scheduler itself
Once memory is well managed, a quieter waste remains. At every generation step, the central processor (CPU) decides which requests enter the batch, prepares the data, then launches the computation on the GPU. Done one after the other, the GPU waits while the CPU decides. With steps lasting a few milliseconds, that idle time is a noticeable share of the total. The fix is asynchronous scheduling: the CPU prepares the next step while the GPU computes the current one. SGLang popularized it in late 2024 as its "zero-overhead" scheduler, and the DeepInfer engine released by DeepSeek in 2026 enables it by default.
Support in serving engines
At the time of writing, the four most widespread serving engines (vLLM, TGI (Text Generation Inference, Hugging Face's), TensorRT-LLM (NVIDIA's) and SGLang) all implement continuous batching, chunked prefill and paged cache management. It is no longer a differentiator, it is the expected minimum; the comparison between them happens elsewhere, see Serving frameworks compared.
What to take away
Continuous batching has become indispensable in production, for one reason worth restating: inference leaves the chip idle waiting on memory, and grouping requests is the most direct way to fill that idleness. It is a purely systems-level optimization, it does not touch the model, it costs nothing in quality, and its ceiling is not compute but attention-cache memory. Hence the natural next lesson: PagedAttention, which attacks that ceiling head-on.
1. Why does grouping fifty requests into one batch multiply throughput, even though the chip computes no faster?
2. A static batch of eight requests is launched together. What exactly does continuous batching change about this?
3. The bandwidth arithmetic allowed about 150 simultaneous requests on an 80 GB A100. Why does practice top out around 32?
4. On an already busy machine, the operator doubles the batch size. What happens?
5. A server runs with permanently full batches. Speculative decoding, which promised to double speed, is added on top. What should you expect?