All glossary terms

Efficiency

Roofline model

A rule for guessing a kernel's speed: the smaller of what its math could reach and what memory bandwidth allows. Where your workload sits says what to cut.

Every operation on a GPU has two limits: the compute ceiling (peak FLOPs) and the memory ceiling (bandwidth). Which one applies depends on arithmetic intensity, the number of FLOPs performed per byte moved. Plot intensity on the horizontal axis, achievable FLOPs on the vertical, and you get a roof: a sloped line where bandwidth runs out, then a flat line at compute peak. The corner of the two is the ridge point.

The practical use is diagnosis. Work under the ridge point on the sloped line is memory-bound: more FLOPs will not help, fewer bytes will. Work near the flat top is compute-bound: the bandwidth is not the problem, the math is. In serving, decode of a big model is the classic memory-bound case, since each step reads every weight to produce one token, while prefill over a long prompt is compute-bound.

That split shapes the optimizations you choose. Memory-bound work rewards 8-bit quantization (half the bytes), batching (amortize one read across many users), and keeping a KV cache small. Compute-bound work rewards shorter sequences, fused kernels, and mixed precision where it helps. Applying the wrong fix is the failure interviewers hunt for: batching helps a memory-bound decode but a compute-bound prefill may just queue.

The model is a first-order estimate, not a simulator: it ignores cache hierarchy, occupancy and overlap. Say that out loud in an interview and then use it anyway - a back-of-envelope roofline on the weights, the bandwidth and the batch size usually lands within a useful distance of the measured truth.

A worked example

Decode on one H100: about 989 TFLOPs/s of dense 16-bit compute and 3.35 TB/s of bandwidth. A 70B model held in 16-bit decodes one token per step.

  1. Ridge point: 989 TFLOPs/s / 3.35 TB/s = 295 FLOPs per byte.
  2. Decode intensity: one step reads 140 GB of weights and performs 2 x 70B = 140 GFLOPs, so 140 GFLOPs / 140 GB = 1 FLOP per byte.
  3. 1 is nowhere near 295, so decode rides the memory line: 3.35 TB/s / 140 GB = 23.9 tokens per second.
  4. Prefill of a 2,000-token prompt does 2,000 x 140 GFLOPs per 140 GB read: intensity about 2,000 FLOPs per byte, well past the ridge, so prefill runs near the compute peak.

Decode buys bandwidth, prefill buys FLOPs. The roofline tells you which budget each phase is spending, and so which fix can work.

Where this shows up

Test yourself

Related terms