Inferensys

Glossary

Roofline Model

The Roofline Model is an analytical performance model that visualizes the attainable performance of a computational kernel as a function of its operational intensity, bounded by either peak compute throughput or memory bandwidth.
ML engineer working on model compression and quantization, laptop showing performance benchmarks, technical workspace.
PERFORMANCE MODEL

What is the Roofline Model?

An analytical performance model that visualizes the attainable performance of a computational kernel as a function of its operational intensity.

The Roofline Model is an analytical performance model that visualizes the attainable performance of a computational kernel as a function of its operational intensity, bounded by either peak compute throughput or memory bandwidth. It plots performance (in FLOPs/second) against operational intensity (FLOPs/byte) on a log-log scale. The model's characteristic "roofline" consists of a memory-bound slope, where performance is limited by data movement, and a flat compute-bound ceiling, where performance is limited by processor arithmetic units.

For inference optimization, the model identifies whether a workload or a specific operator (like a matrix multiplication or convolution) is bottlenecked by memory bandwidth or compute capacity. A kernel's performance is plotted as a point below the roofline; its vertical distance from the line indicates potential optimization headroom. This analysis directly informs techniques like operator fusion to increase operational intensity or mixed precision to leverage higher compute ceilings, guiding engineers toward the most impactful latency reductions.

ANALYTICAL PERFORMANCE MODEL

Key Components of the Roofline Model

The Roofline Model is a visual performance model that plots attainable performance (FLOP/s) against operational intensity (FLOPs/byte). It identifies whether a computational kernel is limited by peak compute or memory bandwidth.

01

Operational Intensity

Operational Intensity is the primary x-axis of the Roofline Model, measured in FLOPs per Byte. It quantifies the amount of useful computational work performed per byte of data transferred from main memory.

  • Definition: Operational Intensity = Total FLOPs / Total Bytes Transferred.
  • High Intensity (>10-100 FLOPs/byte): Kernels are compute-bound (e.g., dense matrix multiplication).
  • Low Intensity (<1 FLOPs/byte): Kernels are memory-bound (e.g., vector addition, element-wise operations).
  • This metric determines which of the model's two fundamental limits applies.
02

Attainable Performance

Attainable Performance is the y-axis of the model, measured in Floating-Point Operations Per Second (FLOP/s). It represents the actual performance a kernel can achieve on a given hardware platform.

  • The model plots a kernel's measured or theoretical performance point based on its operational intensity.
  • The position of this point relative to the 'roofline' determines the performance ceiling and the primary limiting factor.
  • The goal of optimization is to move this point as close as possible to the roofline, maximizing hardware utilization.
03

Peak Compute (Flat Roof)

The Peak Compute limit is a horizontal line representing the maximum theoretical floating-point performance of the hardware, measured in FLOP/s.

  • Applies to: Kernels with high operational intensity (compute-bound).
  • Defined by: The processor's maximum theoretical throughput (e.g., GPU's Tensor Core FP16 FLOPs).
  • Example: An NVIDIA H100 GPU has a peak FP16 Tensor Core performance of ~1979 TFLOPS. This forms the flat, upper ceiling of the roofline.
  • Kernels whose performance points fall near this line are efficiently using the computational units.
04

Peak Memory Bandwidth (Sloped Roof)

The Peak Memory Bandwidth limit is a diagonal line representing the maximum rate at which data can be transferred between the processor and memory, measured in Bytes/s.

  • Applies to: Kernels with low operational intensity (memory-bound).
  • Defined by: The hardware's memory subsystem specs (e.g., HBM2e bandwidth).
  • Slope Calculation: Attainable GFLOP/s = (Bandwidth GB/s) * (Operational Intensity FLOP/byte).
  • Example: An H100 SXM has ~3.35 TB/s memory bandwidth. This forms the sloped portion of the roofline.
  • Kernels on this slope are bottlenecked by data movement, not computation.
05

Ridge Point

The Ridge Point (or knee) is the critical operational intensity value where the sloped memory-bound roof and the flat compute-bound roof intersect.

  • Calculation: Ridge Point = Peak Compute (FLOP/s) / Peak Bandwidth (Bytes/s).
  • Interpretation: It is the minimum operational intensity required for a kernel to become compute-bound. Kernels with intensity below this value are memory-bound; those above are compute-bound.
  • Example: For a system with 1000 GFLOP/s peak compute and 500 GB/s peak bandwidth, the ridge point is 2 FLOPs/byte.
  • This is a key hardware characteristic for determining the suitability of an architecture for a given workload.
06

Performance Gap & Optimization

The vertical distance between a kernel's actual performance point and the roofline represents the performance gap—the potential performance left on the table.

  • Memory-Bound Optimization: To raise a point on the sloped roof, you must:
    • Increase operational intensity via kernel fusion or improved data reuse.
    • Improve effective bandwidth via memory access coalescing or better cache utilization.
  • Compute-Bound Optimization: To raise a point on the flat roof, you must:
    • Increase hardware utilization via better parallelization or vectorization.
    • Use mixed-precision or specialized units (e.g., Tensor Cores).
  • The model provides a clear, visual target for algorithmic and system-level tuning.
ROOFLINE MODEL CLASSIFICATION

Compute-Bound vs. Memory-Bound Workloads

This table contrasts the defining characteristics of workloads limited by computational throughput versus those limited by memory bandwidth, which is the core analytical distinction of the Roofline performance model.

CharacteristicCompute-Bound WorkloadMemory-Bound Workload

Primary Limiting Factor

Processor FLOPs (Compute Throughput)

Memory Bandwidth (Data Transfer Speed)

Operational Intensity

High (> System Balance Point)

Low (< System Balance Point)

Typical Performance Metric

GFLOP/s or TFLOPS

GB/s or GiB/s

Dominant Hardware Pressure

ALU/Compute Cores

Memory Bus & Caches

Common Optimization Target

Arithmetic Efficiency, Kernel Fusion

Data Locality, Cache Reuse, Prefetching

Example in LLM Inference

Dense Matrix Multiplications (MatMul)

Attention Score Softmax, Loading Weights

Roofline Model Region

Attains the Flat, Compute Roof

Resides on the Sloped, Memory Roof

Improvement Strategy

Increase FLOP/s (e.g., Tensor Cores)

Increase Bandwidth (e.g., HBM) or Reduce Bytes/Op

PERFORMANCE ANALYSIS

Application in ML Inference Optimization

The Roofline Model is a foundational tool for performance analysis in ML inference. It provides a visual and quantitative framework to diagnose whether a computational kernel is limited by the processor's raw arithmetic capability (compute-bound) or by the speed of data movement to and from memory (memory-bound). This analysis is critical for targeting effective optimization strategies.

01

Core Principle: Operational Intensity

The model's central axis is operational intensity, measured in FLOPS/Byte. It is the ratio of floating-point operations performed to the volume of data moved between the processor and memory. For a given kernel:

  • High Intensity: Many computations per byte loaded (e.g., large matrix multiplications in dense layers).
  • Low Intensity: Few computations per byte loaded (e.g., element-wise operations, bandwidth-limited attention). Plotting a kernel's intensity determines its position on the roofline and thus its primary performance constraint.
02

Identifying the Performance Ceiling

The 'roofline' itself represents the absolute performance limit for a given hardware platform. It is defined by two key hardware characteristics:

  • Peak Compute (FLOPS): The theoretical maximum floating-point operations per second of the processor (e.g., GPU's tensor cores). This forms the flat, horizontal ceiling.
  • Peak Memory Bandwidth (Bytes/sec): The maximum sustainable data transfer rate between the processor and its memory (e.g., HBM2e bandwidth). This forms the diagonal, sloping ceiling. A kernel's attainable performance is the minimum of its operational intensity multiplied by memory bandwidth and the peak compute rate.
03

Diagnosing Compute vs. Memory Bounds

This is the primary diagnostic use case. By plotting a kernel's measured performance against its operational intensity:

  • Memory-Bound (Left of Ridge Point): The kernel lies on the diagonal slope. Performance scales with intensity and is limited by memory bandwidth. Optimizations focus on improving data locality, using caches effectively, and reducing memory traffic via kernel fusion or quantization.
  • Compute-Bound (Right of Ridge Point): The kernel lies on the horizontal plateau. Performance is limited by the processor's arithmetic units. Optimizations focus on improving instruction-level parallelism, using lower precision (FP16, INT8), and maximizing hardware utilization.
04

Quantifying Optimization Headroom

The vertical distance between a kernel's current performance point and the roofline ceiling represents the performance gap or available headroom. This gap quantifies the potential benefit of optimization:

  • A large gap for a memory-bound kernel suggests significant gains from memory-centric optimizations.
  • A kernel already near the roofline is highly optimized for that hardware; further gains require algorithmic changes to increase operational intensity or moving to new hardware with higher ceilings. It provides a data-driven answer to 'how much faster can this possibly get?'
05

Inference-Specific Analysis: Attention & KV Cache

The model is crucial for analyzing transformer inference, especially autoregressive decoding:

  • Prefill Phase: High-intensity matrix multirates often make it compute-bound, benefiting from tensor core optimization.
  • Decode Phase: Generating tokens one-by-one has very low operational intensity due to loading the large KV Cache for each step. This is severely memory-bound. The roofline model clearly shows why optimizing KV cache access (size, layout, bandwidth) is critical for improving Time Per Output Token (TPOT).
06

Guiding Hardware/Software Co-Design

The model informs decisions across the stack:

  • Algorithm Selection: Choosing kernels with higher inherent operational intensity for a given task.
  • Precision Choice: Quantization (e.g., FP16 -> INT8) reduces the memory traffic (bytes) for the same operations, effectively increasing operational intensity and potentially moving a kernel from the memory-bound slope to the compute-bound plateau.
  • Hardware Selection: Comparing rooflines for different processors (e.g., CPU vs. GPU vs. NPU) shows which is best suited for a specific model's operational intensity profile.
  • Compiler Optimization: Guides kernel fusion decisions—fusing memory-bound with compute-bound ops can create a new, higher-intensity kernel.
ROOFLINE MODEL

Frequently Asked Questions

The Roofline Model is a fundamental analytical tool for performance engineers and ML Ops professionals to diagnose and optimize inference workloads. It provides a visual framework for understanding the fundamental hardware limits of a system and identifying whether a computational kernel is limited by compute capacity or memory bandwidth.

The Roofline Model is an analytical performance model that visualizes the attainable performance of a computational kernel as a function of its operational intensity, bounded by either peak compute throughput or memory bandwidth. It creates a two-dimensional plot with operational intensity (operations per byte of data transferred) on the x-axis and attainable performance (in FLOPs/s) on the y-axis. The model's namesake 'roofline' is formed by two ceilings: a horizontal ceiling representing the system's peak compute performance and a diagonal ceiling representing the system's peak memory bandwidth. The attainable performance of any kernel is the minimum of these two ceilings at its specific operational intensity, providing an immediate visual diagnosis of its limiting factor.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.