GPUs: one decoding step reads every weight once
A design with a language model in it needs one more estimate: how many GPUs.
An 8-billion-parameter model in bf16, on a GPU that reads 3 TB/s. About how long does one decoding step take to read the weights?
Assume 200 requests a second at peak, each generating 500 output tokens. That's 200 × 500 = 100,000 output tokens a second.
What one GPU can do is the number you shouldn't invent. Ask for it, or say you'd load-test it at your latency target. You can still reason about where it comes from:
Text comes out one token at a time for each sequence. The vLLM authors spell out the result: the work is bound by memory, so the GPU's compute sits underused and throughput is limited.
Each decoding step reads every weight from GPU memory once. The arithmetic for one sequence:
- The weights: 8 × 10^9 parameters × 2 bytes in bf16 = 16 GB.
- NVIDIA lists the H100 at 3 TB a second of memory bandwidth per GPU.
- One step: 16 × 10^9 bytes ÷ 3 × 10^12 bytes a second = 5.3 ms.
- One sequence: 1 ÷ 5.3 ms ≈ 190 tokens a second, at most.
The way out is batching: run many sequences together. One read of the weights serves every sequence in the batch, so a batch of 32 gets 32 new tokens for the same 5.3 ms. So throughput climbs with batch size, until the KV cache fills memory or compute runs out.
The KV cache keeps each sequence's attention keys and values for every token so far, so the next step doesn't recompute them. It grows with every token and every sequence in the batch.
A 2024 account of serving ChatGPT says GPU memory, not compute, was the most frequent bottleneck for LLM operations (1 source). The same account says the team's primary metric was batch size combined with KV cache utilization (1 source).
In the editor, write step_ms(params, bytes_per, bandwidth): the milliseconds one decoding step takes to read every weight. Then write tokens_per_s(params, bytes_per, bandwidth, batch), where one read serves every sequence in the batch. The print line runs the 8-billion-parameter model on the 3 TB/s GPU, at batch 1 and at batch 32.
- 1
Write
step_ms(params, bytes_per, bandwidth): the milliseconds to read every weight once. - 2
Write
tokens_per_s(params, bytes_per, bandwidth, batch): the tokens a second, when one read serves the whole batch.
Run your code to check it. Output shows here.