Inference Engineeringestimator

Token throughput estimator

Generating text one token at a time is mostly a memory problem. Every decode step reads all of the model’s weights, and the KV cache of every sequence in the batch, from GPU memory. The arithmetic for one token is small by comparison, so a single user rarely keeps the GPU’s compute busy.

Memory-bound

2,037 tokens/s across 16 sequences (127 tokens/s each) on 1 × NVIDIA H100 SXM. Memory-bound at every batch size.

Aggregate throughput2,037 tokens/s127 tokens/s per user
0102030100200300Batch size (sequences)Time per decode step (ms)Batch 16
Memory time (weights and cache)Compute time

Model, hardware and workload

8B parameters, all used for every token.

Weights
KV cache

80 GB, 3.35 TB/s, 989 dense TFLOPS (16-bit)

Modelled as ideal: bandwidth and FLOPS add up, communication costs nothing.

Our assumption, not a measured figure: real kernels fall short of the datasheet peak.

Our assumption. For scale, Pope et al. measured 76% on large-batch prompt processing with a tuned TPU setup.

The rest is left for activations and runtime overhead. vLLM’s default is 90%.

Speed and memory

Aggregate throughput2,037 tokens/s16 sequences, memory-bound
Time to first token662.4 ms1K-token prompt, batch of 16
Inter-token latency7.85 msOne decode step
Per user127 tokens/sSpeed one reader sees
Compute-bound above batchNeverCache reads outgrow the arithmetic. Weights alone cross at 169
Memory per GPUFits18.7 GB of 72 GB usable
Memory-bound

Each step reads 18.4 GB per GPU, which takes 7.85 ms. The arithmetic needs only 647 µs. A bigger batch adds tokens almost for free until the two meet.

Where one decode step spends its time, per GPU
Per decode stepBytes readTime
Weights16 GB6.82 ms
KV cache at 1.2K tokens2.4 GB1.03 ms
Arithmetic, 256B FLOPsn/a647 µs

Request time: 2.66 s for 1K tokens in and 256 out.

What it shows

This estimator uses a roofline model: a step takes as long as the slower of reading its bytes and doing its arithmetic. Pick a model, a GPU, a precision and a batch size to see the step time, the speed each user sees, the total tokens per second, and whether memory or compute sets the limit.

It is an estimate for planning, not a benchmark. Real servers lose time to scheduling, sampling, communication between GPUs and kernels that don’t reach peak speed. The two percentage inputs stand for that loss, and you should replace the defaults with numbers you measure.

How to read it

  • Inter-token latency is one decode step: the longer of memory time and compute time. Memory time reads the weights and the average KV cache; compute time is 2 × active parameters × batch.
  • “Per user” is one divided by the step time. Aggregate throughput multiplies it by the batch, so it grows until compute takes over.
  • Time to first token is the prefill: 2 × active parameters × prompt tokens × batch of arithmetic, never faster than one read of the weights.
  • The chart plots memory time (solid) and compute time (dashed) against batch size. Where they cross, decode becomes compute-bound.
  • “Never” in “Compute-bound above batch” means cache reads outgrow the arithmetic, so a bigger batch only saves the shared weight reads.
  • The two percentages are our assumptions, not measured. For scale, Pope et al. measured 76% on large-batch prompt processing with a tuned TPU setup.
  • Multi-GPU is modelled as perfect scaling, so treat it as an upper bound. For mixture-of-experts models, bytes use all experts and arithmetic only the active ones.

Questions

Why is LLM decoding memory-bound?

A decode step produces one token per sequence but must read every weight (and the KV cache) from GPU memory. Each weight is used for only a couple of floating-point operations per sequence, so the GPU waits on memory long before its arithmetic units are busy. Batching reuses each weight read for more sequences, which is why total throughput rises with batch size.

What is the roofline model?

It says a computation takes at least as long as moving its data and at least as long as doing its arithmetic, so its speed is capped by whichever is slower. The ratio of arithmetic to bytes moved decides which limit applies. Williams, Waterman and Patterson introduced it in 2009, and Pope et al. apply the same reasoning to transformer inference.

What are good values for bandwidth efficiency and MFU?

There is no universal figure. Good kernels reach a large share of peak bandwidth, but the share depends on the GPU, the kernel and the batch. Pope et al. report model FLOPS utilisation of 76% for prefill on their setup. Measure your own stack and replace the defaults.

Why does the estimate differ from my benchmark?

The model leaves out scheduling, sampling, tokenisation, attention arithmetic, communication between GPUs and the cost of padding or fragmentation. It also reads the KV cache at the average context length. Use it to see which resource limits you and by how much, then check it against a real run.

Does quantising the weights make decoding faster?

When decode is memory-bound, yes: fewer bytes per weight means a shorter read, so the step gets shorter in proportion. The gain shrinks as the KV cache grows, because the cache is not reduced by weight quantisation. If your kernels have to dequantise on the fly, they may not reach the same bandwidth efficiency, so lower the efficiency to match.

Sources

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.