Linear algebra for LLMsPart 9: Numbers on real hardware
Arithmetic intensity
7 min
Two speed limits
An NVIDIA H100 SXM, from its datasheet (as of 2026). Every operation needs some math and some data read from memory; whichever takes longer sets its speed.
Arithmetic intensity
An operation that does fewer than about 295 FLOPs per byte it reads is memory-bound on this GPU: the math units sit idle waiting for data. Above that, it’s compute-bound.
Write
Matrix × vector: 1 FLOP per byte
Each weight is read once (2 bytes) and used once (a multiply-add, 2 FLOPs). Generating one token for one sequence is all matrix × vector products, so it’s about 300× below the ridge.
Write
Batching shares each weight read
sequences decoding together reuse every weight times per read. Intensity grows with the batch, until around a few hundred it reaches the ridge. That’s why serving systems batch many users together. Prefill (processing a prompt of tokens at once) has and is compute-bound.
Write
A decode speed limit
Llama 3 8B in BF16 reads 16 GB of weights per generated token (plus its KV cache). One H100 can’t generate faster than about 209 tokens per second for a single sequence, however many FLOPs it has.
Write
✏️ Your turn
Compute a ceiling
Roughly how many tokens per second at most, for one sequence? (Ignore the KV cache.)
Work it out on paper, then go to the next card to check.
Answer: about 840
Four times the BF16 ceiling: fewer bytes per weight is directly more tokens per second when you’re memory-bound.
What this explains
In a transformer
- Quantizing weights speeds up decoding even if the math is no faster.
- The KV cache (Part 5) is read every step too, so long contexts slow decoding down.
- Speculative decoding and batching both turn matrix × vector work into matrix × matrix work, raising intensity.
📌 Recap
Arithmetic intensity in one card
- = FLOPs per byte; compare with the GPU’s ridge (≈ 295 for an H100 in BF16).
- Matrix × vector: . Batch : .
- Decode speed ≤ bandwidth / bytes per token.
Write
Sources
- NVIDIA H100 Tensor Core GPU datasheet: H100 SXM, 80 GB HBM3, 3.35 TB/s; BF16 Tensor Core 1,979 TFLOPS with sparsity, so about 989 TFLOPS dense.