Batching and throughput optimization represents the operational discipline of aggregating disparate inference requests into synchronized parallel tensor operations, amortizing fixed memory-loading costs across multiple input streams to maximize hardware compute utilization. In standalone single-sequence generation, modern high-density GPUs (such as the NVIDIA H100) operate at less than 5% of their peak arithmetic capacity during autoregressive decoding: because each generated token requires reading every single layer weight from high-bandwidth memory (HBM) into on-chip SRAM just to compute a single vector-matrix product, execution is ruthlessly memory-bandwidth bound. Batching transforms these memory-bound vector-matrix multiplications ($y = Wx$) into compute-bound matrix-matrix multiplications ($Y = WX$), allowing the GPU's thousands of Tensor Cores to reuse loaded weights across $B$ concurrent sequences. Modern production serving architectures have evolved through four distinct generations: rigid static batching (padding requests to a uniform length and stalling until all sequences finish), dynamic batching (accumulating requests within a temporal timeout window), continuous or iteration-level batching (evicting completed sequences and inserting new prompts on every single decoding iteration), and disaggregated chunked-prefill architectures that physically isolate compute-bound prompt encoding from memory-bound autoregressive decoding. At a systems engineering level, the dynamic lifecycle of request scheduling, iteration-level slot allocation, and memory paging functions like this:
A few principles are essential for understanding how batching dictates serving economics, why iteration-level scheduling eliminates execution bubbles, and how physical memory paging prevents catastrophic allocation failures:
Static batching wastes hardware capacity through sequence padding and execution bubbles. In legacy static batching frameworks, requests arriving within a brief time window are grouped into a fixed-dimension tensor $[B, S_{\text{max}}]$. Because real-world user queries exhibit extreme length heterogeneity (e.g., a 50-token query mixed with a 1,500-token document extraction), all sequences must be padded with dummy tokens to match the longest sequence. This structural rigidity introduces two catastrophic sources of efficiency collapse:
1. *Memory Padding Waste:* The GPU must compute attention matrices and store empty KV cache states for padding tokens, wasting up to 60% of available high-bandwidth memory on meaningless zeros.
2. *Execution Bubbles:* When shorter sequences generate an end-of-sequence (`<EOS>`) token early, their execution slots sit completely idle while the GPU continues running iterations for the single longest remaining sequence. New incoming queries cannot enter the batch, forcing GPU utilization to decay monotonically until the entire batch concludes. The timeline of this bubble waste is contrasted below:
Continuous batching and PagedAttention resolve memory fragmentation. Pioneers of continuous batching (introduced in Orca and productionized by vLLM) recognized that token generation occurs incrementally step-by-step. Instead of scheduling requests at the coarse granularity of entire conversations, the serving engine executes scheduling decisions at each individual forward iteration:
- *Iteration-Level Scheduling:* As soon as a request generates an `<EOS>` token, its computational slot is vacated immediately, and an incoming prompt waiting in the queue is seamlessly spliced into the batch on the very next token iteration.
- *Virtual Memory KV Cache Paging:* In traditional serving, memory for a request's maximum potential sequence length (e.g., 4,096 tokens) had to be allocated contiguously in HBM upfront. Because actual sequence lengths cannot be predicted in advance, up to 70% of memory was locked in over-allocated internal fragmentation. PagedAttention borrows the classic operating system concept of virtual memory with page tables: KV cache states are partitioned into small, fixed-size physical blocks (typically 16 or 32 tokens per block). Logical pages map to physical blocks dynamically allocated on demand from a global block pool, slashing memory fragmentation to below 4% and enabling identical prefix prompt sharing across users:
The operational trade-offs of serving configurations. Choosing a batching strategy requires navigating the fundamental trade-off between batch throughput (tokens per second per GPU) and individual user latency (Time-to-First-Token and Inter-Token Latency):
| Batching Framework | Scheduling Granularity | Memory Management | GPU Hardware Utilization | Typical Serving Throughput (Tokens/sec) | Average Inter-Token Latency (ITL) |
|---|---|---|---|---|---|
| Single-Request Serving | Request-level (FIFO) | Static contiguous array | Poor ($<10\%$ Tensor Core utilization) | 50–85 tokens/sec | 15–20 ms/token (Fastest) |
| Static Batching ($B=8$) | Request-level batch | Padded contiguous matrix | Sub-optimal ($20–35\%$) due to idle bubbles | 250–400 tokens/sec | 35–45 ms/token |
| Dynamic Batching ($B=16$) | Temporal timeout window | Padded contiguous matrix | Moderate ($40–50\%$) | 500–750 tokens/sec | 50–65 ms/token |
| Continuous Batching ($B=32$) | Iteration / token level | Fixed chunk allocations | High ($65–80\%$) | 900–1,400 tokens/sec | 45–60 ms/token |
| PagedAttention + vLLM ($B=64+$) | Dynamic iteration step | Non-contiguous virtual paging | Maximum ($85–95\%$) | 1,800–2,800 tokens/sec | 55–75 ms/token |
Disaggregated prefill and chunked execution. Modern frontier serving architectures resolve the interference between the compute-heavy prompt encoding phase (prefill) and the memory-bandwidth-bound token generation phase (decode):
- *The Prefill-Decode Clash:* A long 4,096-token prefill computation requires large matrix multiplications that saturate all SM ALUs for hundreds of milliseconds. If scheduled alongside active decoding streams, it causes severe jitter and spikes Inter-Token Latency (ITL) for streaming users.
- *Chunked Prefills and Prefill-Decode Disaggregation:* Frameworks like Sarathi-Serve and modern vLLM split incoming prompt prefills into discrete chunks (e.g., 512 tokens). These chunks are co-scheduled with ongoing decode steps, flattening compute surges. In bleeding-edge clusters, prefill and decode are physically disaggregated onto separate GPU worker pools connected via high-speed RDMA networks: dedicated prefill nodes process initial prompts at maximum compute density, then stream the completed KV cache states across InfiniBand to dedicated decoding nodes optimized purely for memory bandwidth.
Read batching through a *memory-bandwidth-amortization* lens rather than a *simple-concurrency* lens: on modern AI silicon, the cost of fetching model weights from HBM to SM registers is identical whether generating a token for 1 user or 32 users simultaneously. Batching is the operational lever that shifts execution from being throttled by the memory bus to being fully accelerated by arithmetic Tensor Cores. Without continuous batching and virtual memory paging, even the most powerful datacenter accelerator spends over 80 percent of its time waiting on idle memory lines; with them, the exact same hardware serves an order of magnitude more concurrent requests at a fraction of the cost per token.