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 says 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 choking 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 the single most important performance framework an LLM systems engineer can carry. 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 tend to chase the wrong levers.

This deep dive walks through the model from first principles, applies it to the prefill versus decode split that defines LLM serving, and shows how the framework extends to cover modern memory-hierarchy effects like FlashAttention's SRAM tiling.

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; for FP8 about 2 PFLOPS; for B200 FP4 about 4 PFLOPS or higher.
  • Peak bandwidth P_b, measured in bytes/s. For H100 HBM3 this is roughly 3 TB/s; for B200 HBM3e roughly 8 TB/s.

Achievable performance for a kernel with intensity I is bounded by

Perf(I)=min(Pc,PbI)\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; below the knee, by peak bandwidth.

Why this is the right framing

Performance bottlenecks are caused by whichever resource (FLOPs or bandwidth) runs out first. The roofline model captures both in one picture so you can see at a glance which is biting and how much headroom remains.

Applying the roofline to LLM inference
Optimization levers by regime, with 2026 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 (around 2.2 PFLOPS FP8, around 8 TB/s HBM3e) with the knee staying in a similar range; FP4 doubles compute 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 drops dramatically; 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

Conflating 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