BLOG / BATCHING

Why batching has diminishing returns in LLM inference

Batching shares the cost of reading model weights. Each request still brings its own KV state. Context length determines how far that bargain goes.

Doubling a decode batch can improve aggregate throughput while making every user wait longer between tokens. Both outcomes can be correct. Batching spreads weight reads across more outputs, but each added sequence also brings attention state and work.

The useful question is how much shared cost remains to amortize. Once that fraction is small, another batch increase offers less traffic reduction while still spending memory and latency. Context length determines how soon you reach that point.

An illustrative memory-traffic model: shared weight reads shrink per output token, while each sequence retains its own KV read cost.
An illustrative memory-traffic model: shared weight reads shrink per output token, while each sequence retains its own KV read cost.

What one decode step reads

Consider a dense decoder with full attention, one GPU, and one output token per active sequence per step. Exclude speculative decoding, shared prefixes, and sliding windows for now.

Let W be the bytes of model weights read in a step, B the number of sequences, and K the KV bytes read for one sequence at its current context length. A deliberately simple traffic estimate is:

Bytes per step ≈ W + B × K
Bytes per output token ≈ W / B + K

This assumes ideal weight reuse within the batch and one read of each sequence's required KV state. Real kernels may reread data, benefit from on-chip caches, and incur additional traffic. Treat the expression as a reasoning model, not a hardware performance prediction.

The useful part is the shape. Doubling the batch halves the weight term per token. It does not halve K.

How much does the next doubling buy?

Take a hypothetical decoder that reads 16 GiB of weights per step and stores 128 KiB of KV per context token. These are illustrative inputs, not measurements of a serving engine. At 8,192 tokens, each sequence has 1 GiB of KV state.

Active sequencesWeight bytes per output tokenKV bytes per output tokenTotal in this model
116 GiB1 GiB17 GiB
82 GiB1 GiB3 GiB
161 GiB1 GiB2 GiB
320.5 GiB1 GiB1.5 GiB

At B = W / K, the weight and KV terms are equal. Doubling from that point reduces traffic per output token by 25%, not 50%: half the original traffic was KV state, which the larger batch does not amortize.

More generally, the fractional traffic reduction from doubling B is:

Reduction = W / (2 × (W + B × K))

If KV already accounts for 80% of the modeled traffic, doubling the batch removes only 10% of the total. This is a screening calculation for the remaining opportunity, not a throughput prediction.

Now extend every context to 32,768 tokens. K becomes 4 GiB, and that crossover moves from 16 sequences to four. Increasing concurrency still amortizes weights, but attention state becomes significant much earlier. Some larger batches may not fit in memory at all.

At that longer context and batch 16, doubling to 32 moves the total from 5 to 4.5 GiB per output token: only 10% less traffic. The same concurrency change has a different value because the requests carry more state.

Memory is only one boundary

The linear layers also do more arithmetic as B increases. At sufficient arithmetic intensity, their kernels can become compute-bound. NVIDIA's matrix multiplication guide explains this relationship between reused data and computational work.

Attention has its own kernel efficiency and traffic pattern. Adding their bytes together does not make the entire model one perfectly overlapping roofline operation. Sequential kernels, communication, launch overhead, and scheduler work all remain.

There is a latency boundary too. If a decode step takes longer, every participating sequence waits longer for its next token. Aggregate output throughput can rise while each user receives tokens more slowly. A throughput increase is therefore useful only within the product's latency requirements.

Shared-prefix implementations may reuse some memory or computation, and attention architectures such as MLA change the state representation. Those changes require a different K; they do not justify dropping the state term altogether.

Use the model to choose the next experiment

First estimate the weight share, W / (W + B × K), at the active batches the engine actually reaches. A configured maximum says little if arrivals never fill it. Use context-length buckets rather than a single mean, since a few long sequences can dominate the state budget.

If weights dominate, increasing the batch has a substantial traffic opportunity. If KV dominates, investigate whether the workload permits shorter retained contexts, prefix reuse, or a more compact cache representation. Each changes different assumptions and may carry a quality or implementation cost.

Then sweep offered load with input and output distributions held fixed. Record throughput alongside first-token latency, individual token gaps, KV occupancy, and preemptions. Stop treating a throughput gain as a capacity gain when the required latency objective fails.

If measured throughput flattens while the model still predicts a large traffic reduction, look beyond memory bytes: compute saturation, kernel selection, or scheduling may explain the discrepancy. If the traffic opportunity is already small, a flattening curve is expected. That distinction tells you where to investigate next.

What to remember

  • Batching amortizes weight traffic; per-sequence attention state remains a cost.
  • At the weight/KV crossover, doubling the batch cuts modeled traffic by 25%; if KV is 80% of traffic, it cuts only 10%.
  • Longer contexts can make KV traffic significant at much smaller batches.
  • Use the remaining weight share to choose an experiment, then accept an operating point only within the latency budget.

← Back to Blog