Zenaique

The roofline model in plain language, without the chart, what is it saying?

Flashcard·Easy·4.0 · 0·~30s·Asked atJane StreetQdrantSourcegraph·Relevant atNVIDIA
Attempt it
TL;DR

Roofline plots achievable FLOP/s against arithmetic intensity. Two ceilings (peak compute, peak bandwidth) cap performance. Where a kernel sits shows compute-bound or bandwidth-bound.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a factory has two limits. The first is how many workers it has (compute). The second is how fast trucks can deliver raw materials (bandwidth). If your product needs only a few materials but tons of assembly work, workers are the bottleneck. If it needs tons of materials but barely any assembly, the trucks are the bottleneck. The roofline is a picture that puts both limits on one chart and lets you see at a glance which one is slowing your factory. For LLM inference, prefill is worker-bound (compute), and decode is truck-bound (bandwidth).

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The roofline model is one of the most useful performance frameworks an LLM systems engineer can use. Every optimization decision in inference (quantization, KV-cache compression, batching, speculative decoding, tensor parallelism) can be traced back to its effect on a kernel's position relative to the roofline. Engineers who reason about performance without it often choose the wrong optimizations.

Prefill and decode sit on opposite sides of the knee, which is why they need different optimizations. Memory-hierarchy effects such as FlashAttention's SRAM tiling add more ceilings to the same picture.

Arithmetic intensity and the two ceilings

Define arithmetic intensity I as the ratio of useful FLOPs a kernel performs to the bytes it moves from off-chip memory (HBM on a GPU). It is a property of the kernel and the data access pattern, measured in FLOPs per byte.

A GPU has two hard limits on what it can do.

  • Peak compute P_c, measured in FLOP/s. For H100 BF16 this is around 1000 TFLOPS and for FP8 about 2 PFLOPS. For B200 it is about 9 to 10 PFLOPS dense NVFP4.
  • Peak bandwidth P_b, measured in bytes/s. For H100 HBM3 this is roughly 3 TB/s. For B200 HBM3e, it is 8 TB/s.

Achievable performance for a kernel with intensity I is bounded by

Perf(I)=min⁡(Pc,Pb⋅I)\text{Perf}(I) = \min(P_c, P_b \cdot I)

The knee is where the two terms balance: I_knee = P_c / P_b. For H100 BF16, I_knee is around 330 FLOPs per byte. Kernels with intensity above the knee are limited by peak compute. Kernels below the knee are limited by peak bandwidth.

Why two ceilings

Whichever resource (FLOPs or bandwidth) runs out first causes the bottleneck. The roofline model captures both in one picture so you can see at a glance which one limits the kernel and how much headroom remains.

Applying the roofline to LLM inference
Optimization levers by regime, with examples
Where the simple roofline breaks down, and how the framework extends
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • H100 has roughly 1000 TFLOPS BF16 peak compute and roughly 3 TB/s HBM3 bandwidth, putting the knee around 330 FLOPs per byte.
  • B200 raises both numbers (about 2.25 PFLOPS dense BF16 per GPU in HGX B200, 8 TB/s HBM3e), so its BF16 knee is about 281 FLOPs per byte. Dense FP8 doubles compute and NVFP4 doubles it again.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow does FlashAttention's SRAM tiling change a kernel's position on the roofline?
A

Naive attention is HBM-bandwidth-bound because each softmax read/write hits HBM. FlashAttention tiles QKV blocks into SRAM, reusing them across the softmax pass. Effective intensity rises because bytes from HBM drop sharply. The kernel moves closer to or onto the compute roof. The achieved win on H100 is 2-4x on long sequences.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Confusing high FLOP/s with good performance. Hitting the bandwidth ceiling means you cannot go faster regardless of how many FLOPs your kernel does.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Define arithmetic intensity.

  • Name the two roofline ceilings and what each represents.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy