Frontier

The roofline model

One chart places every kernel by arithmetic intensity; Qwen3.8-27B prefill sits above the ridge point as compute-bound while batch-1 decode and its DeltaNet layers sit far to the left, bandwidth-bound.

Updated

01 · Concept

Concept

A profiling report lands on your desk. The decode kernel for Qwen3.8-27B achieves three tenths of one percent of the GPU’s peak floating-point rate. The obvious reading is that somebody wrote a terrible kernel and a rewrite will recover two orders of magnitude. The roofline model exists to tell you, in about thirty seconds and without touching the code, that this reading is almost certainly wrong and that the kernel may already be perfect.

Williams, Waterman, and Patterson published the model in 2009 to make exactly this judgement cheap. It compresses a machine into two numbers and a kernel into one. The machine contributes its peak arithmetic rate and its peak memory bandwidth. The kernel contributes its arithmetic intensity, the operations it performs per byte it must move from memory. Attainable performance is then the smaller of what the arithmetic units can deliver and what the memory system can feed:

Pattainable(I) = min(Ppeak, βI),P_{\text{attainable}}(I) \ =\ \min\left(P_{\text{peak}},\ \beta \cdot I\right),

where β\beta is bandwidth in bytes per second and II is intensity in operations per byte. Plotted with intensity on the horizontal axis and performance on the vertical, both on logarithmic scales, this draws a slanted line of slope one that stops abruptly at a horizontal ceiling. The bend is the ridge point, the intensity at which the two limits are equal:

I = Ppeakβ.I^{*} \ =\ \frac{P_{\text{peak}}}{\beta}.
ridgebatch-1 decodeprefill 8k
0.11101001,000
0.11101001,00010,000

Arithmetic intensity (FLOP/byte)

Attainable performance (TFLOP/s)

  • Bandwidth roof
  • Compute roof
View this figure’s data
Arithmetic intensityBandwidth roofCompute roof
0.10.335
13.35
295.224989989
8,192989
10,000989
The rooflineAttainable performance is the lower of two ceilings. Left of the ridge a kernel is bandwidth-bound and only more arithmetic per byte helps; right of it, only more compute does. Decode sits far to the left, which is why it is a different machine from prefill.

Using the vendor-reported H100-class figures from lesson 9.1, roughly one thousand teraflops of dense bf16 against 3.35 TB/s of HBM3, the ridge point lands near 300 operations per byte, as of Aug 2026 and subject to every hedge those numbers carry. Left of the ridge, the memory system is the constraint. Right of it, arithmetic is. That is the entire model, and it is enough to price most optimization proposals before anyone writes code.

Place Qwen3.8-27B on it. Prefill of an 8,192-token prompt carries the intensity established in lesson 7.3, about 8,192 operations per weight byte, because each weight fetched serves all prompt positions simultaneously. That is roughly 27 times past the ridge point, so prefill rides the flat compute roof. Its attainable performance is PpeakP_{\text{peak}}, and the honest engineering questions there are about tensor-core occupancy, tiling, and numeric format, because those are what move you along a ceiling you are actually pressed against. Time to first token responds to arithmetic. Buying FLOPs for prefill is a defensible purchase.

Batch-1 decode carries an intensity near one. Its attainable performance is therefore

Pattainable = 3.35×1012 Bs×1 opB = 3.35 TFLOP/s,P_{\text{attainable}} \ =\ 3.35\times10^{12}\ \frac{\text{B}}{\text{s}} \times 1\ \frac{\text{op}}{\text{B}} \ =\ 3.35\ \text{TFLOP/s},

which against a thousand-teraflop ceiling is about 0.34 percent of peak. So the profiling report describes a kernel sitting exactly on its roofline. It is not inefficient. It is on a different roof. Nothing in the instruction stream can be reordered to fix it, because the arithmetic units were never the scarce resource, and this is the correction that saves teams from months of kernel micro-optimization that recovers single-digit percentages. Batching to 32 sequences moves the point to intensity 32 and allows about 107 teraflops, roughly a thirty-twofold gain, still an order of magnitude short of the ridge, still on the slanted roof, and obtained entirely by changing the workload rather than the kernel.

The hybrid layout puts two distinct dots on the chart for one model, which is what makes Qwen3.8-27B interesting to profile. The 16 full-attention layers read a key-value history that grows at 64 KiB per token, the figure derived in lesson 7.2, while the arithmetic each new query performs against that history grows at the same rate. Their intensity is roughly constant and low, but the absolute bytes per step climb, so as context lengthens these layers consume a rising share of the step time on the bandwidth roof. The 48 Gated DeltaNet layers behave differently. They read and update a fixed recurrent state of roughly 3 MiB per layer, about 144 MiB in total in the reference float32 path, no matter how long the conversation has run. Their dot does not move. Three quarters of the model’s depth therefore contributes a constant, bounded cost to every decode step while a quarter contributes a growing one, which is the architectural bargain restated in roofline terms.

Turning this from a sketch into evidence requires real counters, not estimates. Kernel profilers report achieved bandwidth and achieved arithmetic separately and can place a measured kernel on a measured roofline, including secondary roofs for L2 and shared memory. That distinction matters because the estimated intensity you derive on paper and the intensity a kernel actually exhibits diverge whenever caching, padding, or memory layout differ from the idealization.

The payoff is a habit. Before optimizing, estimate intensity, compare it to the ridge point, and let the chart tell you whether you are shopping for bytes or for operations. Lesson 9.4 applies that habit to specific silicon, where a newer part changes both roofs at once and the capacity underneath them.

02 · Analogy

Analogy

A cargo bike has a maximum speed and a maximum load, and a route has a fixed number of deliveries per kilometre. Plot deliveries per kilometre on one axis and you can read off, without riding, whether the trip is limited by how fast you pedal or by how often you stop. Dense routes are pedal-limited; sparse routes are stop-limited, and buying a faster bike helps only one of them. The roofline is that plot for kernels, with arithmetic intensity as deliveries per kilometre.

03 · Teach it back

Teach it back

State the roofline formula, compute the ridge point for an H100-class GPU, and place Qwen3.8-27B prefill, batch-1 decode, and the DeltaNet layers on the resulting chart.

Minimum: 80 characters and 15 words. Your writing stays only in this browser.

Waiting for your explanation.

Compare with a model answer

Attainable performance is the minimum of the machine's peak arithmetic rate and its memory bandwidth multiplied by the kernel's arithmetic intensity, so the chart is a slanted bandwidth roof that meets a flat compute roof at the ridge point, where intensity equals peak FLOPs divided by bandwidth. For an H100-class part with vendor-reported figures near one thousand teraflops and 3.35 TB/s, the ridge point is around 300 operations per byte. Prefill on an 8,192-token prompt has an intensity near 8,192, far right of the ridge, so it rides the flat compute roof and is limited by arithmetic. Batch-1 decode has an intensity near one, so it sits on the slanted roof at roughly 3.35 teraflops, about three tenths of one percent of peak, and is limited by bandwidth. The 16 full-attention layers hold a roughly fixed low intensity as context grows, because each new query reads 64 KiB more history per token and performs proportionally more arithmetic against it — the ratio barely moves, but the absolute bytes per step climb, so these layers take a growing share of step time on the bandwidth roof. The 48 Gated DeltaNet layers hold both position and cost, because their roughly 144 MiB of reference float32 state neither grows nor shrinks with context.

04 · Check your understanding

Check your understanding

01A decode kernel achieves 0.3 percent of an H100's peak FLOPs. What does the roofline model conclude?
Answer and explanation

The kernel may already be at 100 percent of its attainable roofline; only raising arithmetic intensity or bandwidth can help — At an intensity near one operation per byte the bandwidth roof allows only about 3.35 teraflops; hitting that is perfect efficiency, and the fix is intensity, not instruction scheduling.

02Lesson 7.2 derived 64 KiB of key-value cache per token for Qwen3.8-27B. As a conversation grows, how do the 16 full-attention layers move on the roofline chart?
Answer and explanation

They barely move, because bytes read and arithmetic both grow with context — but their absolute cost per step rises, taking a growing share of time on the bandwidth roof — Each new query attends over an ever-larger history AND does proportionally more arithmetic against it, so intensity stays roughly constant and low. What grows is the absolute bytes moved per step, which is why these layers dominate a long-context decode without ever drifting left.

Complete the teach-back and answer the quiz correctly to finish this lesson.

◎ · Evidence marker

Sources

  1. Samuel Williams, Andrew Waterman, and David Patterson (2009). Roofline: An Insightful Visual Performance Model for Multicore Architectures.
  2. NVIDIA Corporation (2026). Nsight Compute Documentation.
  3. Qwen Team (2026). Qwen3.8-27B Model Card.