Roofline model

On this page 7

The roofline model is a visual performance model that bounds the attainable throughput of a computational kernel by two hardware limits: peak compute rate and peak memory bandwidth. In AI hardware analysis, it plots achievable operations per second against arithmetic intensity, the number of operations performed per byte moved, and shows at a glance whether a workload is memory-bound or compute-bound.

Introduced by Samuel Williams, Andrew Waterman and David Patterson in 2009, the model became a standard tool for evaluating data-center GPUs, TPUs and NPUs. It explains why a chip advertised at thousands of TFLOPS can deliver only a small fraction of that figure on large language model inference, and it tells engineers which optimization will actually help.

How the roofline model bounds performance

The model rests on one inequality: attainable performance equals the minimum of peak compute and the product of memory bandwidth and arithmetic intensity. On a log-log chart, the bandwidth term forms a sloped line rising from the left, and the compute limit forms a horizontal ceiling. Together they look like a roof, which gives the model its name.

The two lines meet at the ridge point, also called the machine balance. Its x-coordinate equals peak compute divided by peak bandwidth. A kernel whose arithmetic intensity lies left of the ridge point cannot saturate the compute units, no matter how well it is scheduled, because data cannot arrive fast enough.

The following table defines the quantities that appear on every roofline chart.

QuantityUnitMeaning
Arithmetic intensityFLOP per byteWork done per byte of memory traffic
Peak computeFLOP/s or TOPSHorizontal ceiling of the chart
Peak bandwidthBytes per secondSlope of the diagonal roof
Ridge pointFLOP per byteIntensity needed to reach peak compute
Attainable performanceFLOP/sMinimum of the two limits
Core quantities of the roofline model

Ridge points of modern AI accelerators

Accelerator compute has grown much faster than memory bandwidth, so ridge points keep moving to the right. This trend is a direct expression of the memory wall. The values below are approximate dense figures for low-precision tensor math and vary with clock speed, precision and product variant.

Accelerator classDense low-precision computeMemory bandwidthApproximate ridge point
NVIDIA Hopper H100 SXMAbout 990 TFLOPS in bfloat16About 3.35 TB/s HBM3About 295 FLOP per byte
NVIDIA Blackwell B200About 2,250 TFLOPS in bfloat16About 8 TB/s HBM3eAbout 280 FLOP per byte
Laptop NPUTens of TOPS in INT8About 100 GB/s shared DRAMSeveral hundred ops per byte
Server CPU socketA few TFLOPS in FP32About 300 to 600 GB/sAbout 5 to 15 FLOP per byte
Approximate machine balance of representative accelerators

A ridge point near 300 FLOP per byte means a kernel must reuse each loaded byte hundreds of times to reach peak throughput. Only well-tiled large matrix multiplications achieve that, while most other operations in a neural network fall far to the left.

Where typical AI workloads land

Different stages of a transformer occupy very different positions on the roofline. Batch size, sequence length and numeric precision are the main levers, because they change how many operations each weight or activation byte supports.

OperationTypical intensityUsual bound
Large training GEMMHundreds to thousands FLOP per byteCompute-bound
Prefill with long promptsHigh, grows with prompt lengthMostly compute-bound
Decode at batch size 1About 1 to 2 FLOP per byteStrongly memory-bound
Elementwise ops and normalizationBelow 1 FLOP per byteMemory-bound
Attention over a long KV cacheLow without fusionMemory-bound
Typical arithmetic intensity of AI operations

The decode phase of LLM inference illustrates the model clearly. At batch size one, every weight is read once to produce a single token, so throughput is set by memory bandwidth, not TFLOPS. Raising the batch size, quantizing weights to FP8 or FP4, and fusing kernels all move the workload to the right along the slope.

Extensions and hierarchical rooflines

The basic model has one bandwidth line, but real chips have a memory hierarchy. The hierarchical roofline draws a separate slope for each level, such as HBM, L2 cache and shared memory, and computes intensity relative to the traffic at that level. A kernel may be bound by HBM even though its cache traffic is comfortable.

  • Additional ceilings: lower horizontal lines show the peak without tensor cores, without fused multiply-add or at higher precision.
  • Interconnect rooflines: for distributed training, the slope uses NVLink or network bandwidth and intensity counts FLOP per byte communicated.
  • Energy rooflines: the same idea applied to joules per operation and per byte, which relates to TOPS per watt.
  • Latency-aware variants: add terms for kernel launch overhead and synchronization, which dominate very small operations.

Using the model in practice and its limits

Performance engineers place each measured kernel on the chart using profiler counters for FLOP executed and bytes transferred. The vertical gap between the point and the roof shows how much performance is left, and the horizontal position shows which resource to attack.

Kernel positionDiagnosisRecommended action
Far below the slopePoor bandwidth useFix access patterns and coalescing
On the slope, left of ridgeTruly memory-boundRaise reuse with tiling, fusion or batching
Near the ridge pointBalancedTune both data movement and compute
Below the flat ceilingCompute underusedUse tensor cores and lower precision
Choosing an optimization from roofline position

The roofline is an upper bound, not a prediction. It ignores latency, load imbalance, synchronization and contention among concurrent kernels. Vendor peak figures often assume structured sparsity or ideal clocks, so a sound analysis uses measured bandwidth and dense compute. Benchmarks such as MLPerf complement the roofline by reporting end-to-end results.

A plain-language summary

Think of a kitchen with very fast cooks and a narrow door for groceries. If the dishes need few ingredients per minute of cooking, the cooks stay busy. If the dishes need many ingredients, the cooks wait at the door.

The roofline model draws this as a simple chart. One line shows how fast the cooks can work. Another shows how fast groceries arrive. Whichever limit is lower decides real speed.

For AI chips, the cooks are the math units and the door is memory. The chart tells engineers whether to buy faster memory or reorganize the work.

An example from practice

An inference team serves a 70-billion-parameter language model on accelerators with about 3.35 TB/s of memory bandwidth. Users complain about slow token generation, and the team first suspects insufficient compute.

A roofline analysis shows that the decode kernels run at roughly 2 FLOP per byte, far left of the ridge point near 300. With 16-bit weights, each token requires reading about 140 GB, so bandwidth caps a single stream at roughly 24 tokens per second per accelerator before parallelism across chips. Compute utilization sits below 5 percent.

The team quantizes weights to FP8, halving the bytes read, and increases batching so that several requests share each weight load. Measured throughput per accelerator rises more than fivefold, and the roofline chart confirms that the kernels moved up the bandwidth slope toward the ridge point.