Module 3 · Lesson 4 of 5

Arithmetic intensity and roofline

Predict a limiting resource from units and assumptions, then ask what could falsify the prediction.

How much work per byte?

Arithmetic intensity connects a workload to a memory boundary. Count floating-point operations F and transferred bytes E, then divide. Always name whether those bytes cross HBM, L2, shared memory or another boundary.

I = F / E · units: FLOP/byte.
Example: 128 FLOPs / 320 bytes = 0.4 FLOP/byte for the tile-side-2 logical traffic from 3.3.

That 0.4 is not automatically an HBM intensity: cache hits can remove HBM reads. Below we explicitly assume bytes fetched from or written to device DRAM, using an optimistic one-read input/weight model.

Best-case projection traffic

For U [rrows × kinner] times W [kinner × ccols], F = 2rrowsccolskinner. If each input and weight is fetched once from DRAM and each output is written once, E = element bytes × (rrowskinner + kinnerccols + rrowsccols). This is an optimistic cold-data traffic assumption, not a promise that any kernel achieves it. Repeated loads can increase it; data already in cache can reduce it. Bias, old-output reads, conversions and workspace are excluded.

Two resource bounds, one roof

If a device sustains at most P FLOP/s and BW byte/s, execution needs at least enough time for both resources. No overlap of the two resources can beat the larger of the two times, so that is a lower bound however well the work is scheduled. Reaching it needs ideal overlap of arithmetic and transfers. Real time can be much larger.

time ≥ max(F/P, E/BW)
attainable FLOP/s ≤ min(P, BW × I)
ridge intensity = P/BW

Compute throughput is arithmetic work per second; memory bandwidth is bytes moved per second. Here 1 TFLOP/s means 10¹² FLOPs per second, and 1 TB/s means 10¹² bytes per second. A millisecond (ms) is one thousandth of a second.

For dense matrix products, P is the tensor-core rate (see 3.3) for the chosen precision: that is where the headline dense TFLOP/s figures in vendor spec tables come from. Because P is so large, the ridge is high, and most operations hit the bandwidth roof first.

The ridge is where the compute and bandwidth roofs meet. Below its intensity, the model is bandwidth-bound: moving bytes sets the larger time bound. Above it, the model is compute-bound: arithmetic sets the larger bound. At the ridge the two bounds are equal.

The chart uses logarithmic axes: each labeled tick is ten times the previous one, rather than a fixed amount larger.

Move a projection across the roofline

Hypothetical dense device: 100 TFLOP/s, 1 TB/s; ridge = 100 FLOP/byte. One row of a 4096×4096 two-byte projection has intensity about 1 FLOP/byte. With 512 rows, intensity is 409.6 FLOP/byte under the stated one-read assumption. Teaching numbers, not measurements.

Model boundaries

The roofline point sits on an ideal roof, not at a measured result, and the controls change a hypothetical device, not real hardware. The 4096 × 4096, 2-byte projection and its read-once traffic are assumptions of the lab.

Divide FLOPs by FLOP/s to obtain seconds, then multiply by 1,000 for milliseconds. Do not mix GB/s and GiB/s. Count a multiply-add as two FLOPs consistently in work and device throughput.

Select a ceiling matching precision, matrix instructions and dense versus sparse work. A sparse advertised tensor-core peak cannot be used as a dense FP32 ceiling. The sliders describe a hypothetical device, not any released GPU. They change rows, compute ceiling and bandwidth only; none changes bytes per value. On real hardware, precision changes both: fewer bytes per element and a different tensor-core rate (NVIDIA’s H100 page lists different TFLOP/s for FP8, FP16/BF16 and TF32).

Near the ridge both resources matter. A point below both ceilings may be limited by launch latency, dependency chains, occupancy, shape, synchronization or another memory level. A roofline label is a hypothesis about a chosen operation and boundary, not proof of the actual bottleneck.

Predict: Below the ridge, double compute ceiling while keeping bandwidth fixed. Lower ideal time?

A prediction you can disprove

Suppose the model says memory time dominates. Predict that reducing transferred bytes will matter more than raising peak math rate. Then try to disprove that prediction: if traffic falls but runtime does not, inspect the next limit.

  1. Fix the tensor shapes, precision, operation and memory boundary.
  2. Calculate work and traffic; state cache/reuse assumptions.
  3. Change one cause: rows, tile size, layout or bytes per value.
  4. Compare result correctness, measured time and transferred bytes.
  5. Explain disagreement; do not relabel the graph as a benchmark.

Without GPU access, complete steps 1–3 and write expected outcomes. Leave measured time and counters explicitly “not measured”. A CPU experiment can validate correctness and counting logic; it cannot establish CUDA performance.

Module 3 overview · Revisit KV memory