Summary
A kernel must perform arithmetic and move data. Count both for the same operation before choosing an optimization.
Consider 120 GFLOPs and 12 GB transferred across the measured memory boundary. Assume hypothetical ceilings of 20 TFLOP/s at the operation’s precision and 100 GB/s across that boundary. Use decimal units: one GB is bytes. Which could help: twice the compute throughput, or half the traffic?
The compute and bandwidth lower bounds are seconds and seconds. Even perfect overlap cannot finish below the larger bound:
Here counts FLOPs, counts transferred bytes, is a compute ceiling, and is a bandwidth ceiling. Keep units consistent; a multiply-add conventionally counts as two FLOPs.
| Change | Compute bound | Traffic bound | Combined lower bound |
|---|---|---|---|
| Original | s | s | s |
| Double | s | s | s |
| Halve | s | s | s |
Halving traffic improves the lower bound; it does not prove a measured twofold speedup.
Arithmetic intensity
Arithmetic intensity is work per transferred byte, at a stated memory boundary:
The fixture has intensity FLOPs/byte and ridge FLOPs/byte. Its bandwidth roof is lower than its compute roof:
The lower roof identifies a first-order limit, not every possible bottleneck.
Same operation, two resource limits
Halving memory traffic raises this example's ceiling from 1 to 2 TFLOP/s
Derivation
Does a doubled memory ceiling prove an observed throughput doubled?
Model references: original Roofline report, NERSC Roofline documentation, and NVIDIA matrix-multiplication guide.
Change reuse or local capacity
1. Reuse weights across a batch
New task: small-batch decode repeatedly reads the same BF16 weights.
Picture and change: one multiply-add per two-byte weight gives about one FLOP per weight byte. Reusing each weight across 64 tokens gives about 64, counting weight traffic alone.
Check: include activations, outputs and each sequence’s KV reads. Batching also consumes memory and can increase waiting time.
Use when: measured weight traffic limits small-batch throughput.
2. Reject a tile that cannot stay on chip
New task: two BF16 input tiles require bytes. The kernel also needs a FP32 accumulator: another 65536 bytes.
Picture and change: those arrays cannot all reside in a hypothetical 96 KiB local budget. Choose smaller tiles or a different staging plan. Registers and shared memory have separate constraints; this combined check is only a necessary fit test.
Check: count spills, occupancy, synchronization, output traffic and compiled storage use before claiming reuse.
Use when: local capacity invalidates the proposed traffic reduction.
A faster compute ceiling can leave the limit unchanged
Predicting decode speedup from peak tensor throughput alone ignores bytes and launch costs. Record shapes, dtype, FLOP convention, memory boundary, traffic, attainable rates and measured runtime. Compare the same operation and distinguish useful arithmetic from executed or recomputed work.
Try finding the missing limit
Why might measured runtime exceed both simple lower bounds?
Check your answer
Launch overhead, dependencies, low occupancy, contention, inefficient instructions or uncounted traffic can add limits. The roofline is not a complete runtime simulator.
The hierarchy
| Tier | Typical role | Constraint to inspect |
|---|---|---|
| Registers | Per-thread values and accumulators | Register allocation, spills, occupancy |
| Shared memory / L1 | On-chip staging and cached values | Distinct APIs and architecture-specific partitioning |
| L2 | Cache shared across multiprocessors | Actual hit rate and traffic boundary |
| HBM | Weights, activations, KV storage | Capacity and achieved bandwidth |
| PCIe / accelerator links | Host or peer transfers | Link, topology and synchronization |
Capacities and rates vary by device, precision, sparsity mode and power settings. SRAM is a storage technology, not one universally managed tier. Measure the target machine and kernel.
Other intensity calculations
For square BF16 matrix multiplication, and two input reads cost bytes. Ignoring outputs gives ; output reads, writes or repeated loads lower that estimate. At , this input-only estimate is 1024 FLOPs/byte.
The separate illustrative 989 TFLOP/s, 3 TB/s device has ridge about 330 FLOPs/byte. It is not the fixture device or a measured kernel result.
Implications for LLMs
Large matrix multiplications can approach a compute roof; small operations, communication and elementwise kernels can face other limits. Decode can become limited by weights or KV reads, depending on batch, context and implementation. FlashAttention reduces materialized attention traffic through tiling; it can also change executed work through recomputation.
Common pitfalls
Peak figures do not replace profiling. Include output traffic, spills, cache behavior and the specific boundary at which bytes were measured.
Related
- Accelerator network topology. Extend the hierarchy across devices and nodes.
- Transformer compute and memory accounting. Convert a model configuration into bytes and FLOPs.
- Profiling distributed ML workloads. Compare a trace with roofline limits.