The Roofline model is an intuitive visual performance model used to bound the maximum achievable performance of a computational kernel or loop nest based on its operational intensity and the hardware's peak compute throughput and memory bandwidth. It plots attainable performance (FLOPS/sec) against operational intensity (ops/byte) on a log-log scale, creating a characteristic 'roofline' that reveals whether a kernel is compute-bound or memory-bound. This model is a foundational tool for performance analysis and guiding compute graph optimizations like loop tiling and operator fusion.
Glossary
ROOF-Line Model

What is the ROOF-Line Model?
A visual performance model used to bound the maximum achievable performance of a computational kernel based on its operational intensity and hardware capabilities.
The model's ceiling is defined by two hardware limits: the memory bandwidth roof for low-intensity kernels and the peak compute roof for high-intensity ones. Kernels below the roofline have optimization headroom, indicating inefficiencies like poor cache utilization or lack of vectorization. By analyzing a kernel's position relative to the roofline, compiler engineers and performance architects can select targeted optimizations, such as improving data locality to shift a kernel rightward or applying SIMD instructions to lift it toward the compute roof.
Key Components of the Roofline Model
The Roofline model is a visual performance model that provides an upper bound on the performance of a computational kernel based on its operational intensity and the hardware's fundamental limits.
Operational Intensity
Operational Intensity (OI) is the primary algorithmic characteristic plotted on the x-axis. It is defined as the number of operations performed per byte of data transferred from main memory, measured in FLOPS/Byte. It determines whether a kernel is compute-bound or memory-bound.
- Low OI (< OI_peak): The kernel is memory-bound. Performance is limited by the time to move data, not by the processor's compute speed.
- High OI (> OI_peak): The kernel is compute-bound. Performance is limited by the processor's peak floating-point throughput.
- Example: A dense matrix multiplication has high operational intensity, while an element-wise vector addition has very low operational intensity.
Attainable GFLOP/s Ceiling
This is the performance (in Giga-FLOPS per second) plotted on the y-axis. It represents the actual achievable performance of a kernel. The Roofline model shows that this attainable performance is bounded by two fundamental hardware limits, forming a characteristic 'roofline' shape that kernels cannot exceed.
- The sloped roof (memory bandwidth bound) for kernels with low operational intensity.
- The flat roof (peak compute bound) for kernels with high operational intensity.
- A kernel's performance is optimal when its plotted point sits directly on the roofline, indicating it is fully utilizing the constraining resource.
Peak Memory Bandwidth (β)
Peak Memory Bandwidth (β), measured in GB/s, is a fundamental hardware limit. It defines the slope of the roofline. The sloped portion of the roof represents the maximum performance achievable for memory-bound kernels and is calculated as: Performance ≤ β × Operational Intensity.
- This limit is dictated by the memory subsystem (e.g., DRAM, HBM, cache hierarchy).
- It is the primary bottleneck for kernels with low operational intensity, such as stencils or BLAS1 operations.
- Optimization Target: For memory-bound kernels, performance improvements come from reducing data movement, improving cache locality (via loop tiling), or using more efficient data layouts.
Peak Computational Throughput (π)
Peak Computational Throughput (π), measured in GFLOP/s, is the second fundamental hardware limit. It defines the flat, horizontal portion of the roofline. This is the absolute maximum floating-point performance the processor can deliver, regardless of how much data is available.
- This limit is dictated by the number of functional units, clock speed, and SIMD width of the CPU, GPU, or NPU.
- It caps the performance of compute-bound kernels, such as dense matrix multiplication or convolution.
- Optimization Target: For compute-bound kernels, performance improvements come from maximizing instruction-level parallelism, ensuring full vectorization, and using specialized kernels (e.g., via kernel auto-tuning).
Ridge Point (OI_peak)
The Ridge Point is the operational intensity value where the sloped roof (memory-bound) and the flat roof (compute-bound) intersect. It is a critical hardware characteristic calculated as: OI_peak = π / β.
- Kernels with OI < OI_peak are memory-bound. Their performance on the roofline chart falls on the sloped line.
- Kernels with OI > OI_peak are compute-bound. Their performance on the roofline chart falls on the flat line.
- This point helps hardware architects and software developers understand the balance of a system. A higher ridge point indicates a more compute-centric architecture (e.g., a GPU), while a lower ridge point indicates a system more sensitive to memory bandwidth.
Application in Graph Optimization
The Roofline model is a vital tool for guiding compute graph optimization. By analyzing a kernel's position relative to the roofline, engineers can diagnose bottlenecks and select the most effective transformations.
- Below the Roofline? The kernel is inefficient. This indicates optimization opportunities like improving data layout for better cache use, applying operator fusion to reduce intermediate data writes, or using sparse tensor encoding for matrices with many zeros.
- Memory-Bound Kernel? Focus on loop tiling, static memory planning, and in-place operations to reduce DRAM traffic.
- Compute-Bound Kernel? Focus on ensuring vectorization, exploring low-rank factorization to reduce FLOP count, or using graph quantization folding to enable faster low-precision arithmetic.
Compute-Bound vs. Memory-Bound: Characteristics & Optimization Targets
A comparison of the defining characteristics, performance bottlenecks, and primary optimization strategies for compute-bound and memory-bound kernels, as analyzed through the Roofline performance model.
| Characteristic / Metric | Compute-Bound Kernel | Memory-Bound Kernel |
|---|---|---|
Primary Performance Limiter | Peak compute throughput (FLOPS) | Peak memory bandwidth (Bytes/sec) |
Operational Intensity | High (> Arithmetic Intensity Roof) | Low (< Arithmetic Intensity Roof) |
Typical Roofline Position | On the horizontal compute roof | On the diagonal bandwidth roof |
Arithmetic Intensity |
| < 1-10 Ops/Byte |
Optimization Priority | Increase FLOP efficiency & utilization | Reduce data movement & improve locality |
Key Optimization Techniques | Loop unrollingVectorizationKernel auto-tuning | Loop tilingData layout optimizationOperator fusion |
Hardware Stress | ALU/FPU units | Memory bus & cache hierarchy |
Performance Scaling with Clock Speed | Near-linear improvement | Minimal improvement |
Cache Miss Rate | Typically low | Typically high |
Example Operations | Large dense matrix multiplication | Element-wise operations, vector addition |
Application in Machine Learning & AI Systems
The Roofline model is a visual performance analysis tool used to bound the maximum achievable performance of a computational kernel or loop nest based on its operational intensity and the hardware's peak compute and memory capabilities.
Core Definition & Visual Model
The Roofline model is an intuitive, two-dimensional plot that visualizes the performance limits of a computational kernel. The x-axis represents Operational Intensity, measured in operations per byte of data transferred (Ops/Byte). The y-axis represents attainable performance in operations per second (Ops/sec). The model establishes two fundamental ceilings:
- Memory-Bound Ceiling: A diagonal line representing the maximum performance limited by memory bandwidth. Performance = Operational Intensity × Peak Memory Bandwidth.
- Compute-Bound Ceiling: A horizontal line representing the maximum performance limited by the processor's peak computational throughput. A kernel's performance is plotted as a point on this graph; its vertical distance from the roofline indicates optimization headroom.
Key Metric: Operational Intensity
Operational Intensity (OI) is the critical kernel characteristic measured by the Roofline model. It is defined as the ratio of total arithmetic operations (FLOPs) to total bytes of data movement between the processor and main memory (DRAM).
- High OI Kernels (e.g., dense matrix multiplication, convolution): Perform many operations on each loaded data byte. These kernels are typically compute-bound and their performance is capped by the processor's FLOP/s ceiling.
- Low OI Kernels (e.g., element-wise operations, vector addition): Perform few operations per data byte loaded. These kernels are memory-bound and their performance is limited by the system's memory bandwidth. Optimizing a kernel often involves increasing its operational intensity through techniques like loop tiling to improve data reuse from caches.
Application in AI Compiler Design
Compiler engineers use the Roofline model to guide compute graph optimizations for neural network inference. By analyzing different layers or fused subgraphs, they can identify bottlenecks and select optimal transformations.
- Fusion Decisions: The model helps decide whether to fuse operators. Fusing a low-OI operator (e.g., ReLU) with a high-OI operator (e.g., Conv) can reduce intermediate data writes to memory, effectively increasing the operational intensity of the combined kernel and moving it closer to the compute roof.
- Loop Transformations: Techniques like loop tiling and loop unrolling are evaluated for their impact on OI. Tiling aims to fit working sets into cache, reducing DRAM traffic and artificially increasing the effective OI for the kernel.
- Hardware Targeting: The model provides a clear comparison of the same kernel's potential on different hardware targets (e.g., CPU vs. GPU vs. NPU) by plotting their distinct rooflines (different bandwidth and compute ceilings).
Use Case: Analyzing Convolutional Layers
Convolutional layers (Conv) are classic subjects for Roofline analysis. Their operational intensity depends heavily on parameters:
- High Intensity Scenario: A large Conv layer with big input/output channels and filters that fit in cache can have very high OI, sitting near the compute-bound roof. Performance is limited by how fast the matrix multiplication units (e.g., Tensor Cores) can run.
- Low Intensity Scenario: A depthwise convolution or a small pointwise convolution has low data reuse, resulting in low OI, placing it on the memory-bound slope. The analysis directs optimization efforts:
- For a compute-bound Conv, focus on improving kernel efficiency (e.g., using Winograd algorithm, optimizing for tensor cores).
- For a memory-bound Conv, focus on data layout (NHWC vs. NCHW), operator fusion with adjacent layers, or quantization to reduce the bytes transferred.
Limitations and Practical Considerations
While powerful, the classical Roofline model has limitations that practitioners must account for:
- Cache Hierarchy Abstraction: The basic model uses DRAM bandwidth. In reality, modern systems have multi-level caches (L1, L2, L3). More advanced models use multiple "rooflines" or a cache-aware Roofline to model performance limits at each cache level.
- Kernel Overhead: It assumes perfect overlap of computation and memory access. Real kernels have overhead from control flow, instruction latency, and non-ideal memory access patterns not captured by OI alone.
- Multi-Core Systems: The model typically describes a single core or processing element. Scaling to multi-core/GPU requires considering concurrency and shared resource contention (e.g., memory controller saturation).
- Quantitative Guidance, Not Prescription: The model identifies the bottleneck type (compute vs. memory) and quantifies headroom, but does not specify how to optimize. It must be paired with profiling tools and a deep understanding of the hardware architecture.
Related Concepts & Tools
The Roofline model integrates with several other performance analysis and optimization techniques in the ML systems stack:
- Empirical Roofline: Generated by running micro-benchmarks (e.g., STREAM for bandwidth, LINPACK for compute) to measure the actual achievable peaks on a specific system, which are often lower than theoretical hardware specs.
- Profile-Guided Optimization (PGO): Runtime profiling data (actual OI and performance) can feed back into the compiler to make better optimization decisions, effectively creating a data-driven Roofline.
- Cost Models in Compilers: The analytical principles of the Roofline model are embedded in the cost models used by AI compilers (like TVM, MLIR, XLA) to automatically evaluate and select between different kernel implementations and graph schedules.
- Hardware-Aware Neural Architecture Search (NAS): NAS algorithms can use a Roofline-based performance predictor to quickly estimate the latency of candidate model architectures on target hardware, favoring those with higher operational intensity.
Frequently Asked Questions
The Roofline model is a foundational analytical tool for performance engineers and compiler developers. It provides a visual, intuitive bound on the maximum achievable performance of a computational kernel, guiding optimization efforts by revealing whether a workload is compute-bound or memory-bound on a given hardware platform.
The Roofline model is an intuitive visual performance model used to bound the maximum achievable performance of a computational kernel or loop nest based on its operational intensity and the hardware's peak compute throughput and memory bandwidth. It plots attainable performance (in FLOPS/sec) against operational intensity (in FLOPs/byte) on a log-log scale, creating a characteristic 'roofline' shape that reveals the fundamental hardware limits and the primary bottleneck for any given workload.
Key Components:
- Operational Intensity (I): The ratio of total floating-point operations (FLOPs) performed to total bytes transferred from main memory (Bytes). It's a measure of arithmetic reuse.
- Peak Performance (π): The maximum theoretical floating-point throughput of the hardware (e.g., CPU, GPU, NPU), measured in FLOPS/sec.
- Peak Bandwidth (β): The maximum sustainable memory bandwidth of the hardware platform, measured in Bytes/sec.
The model creates two performance regimes: a memory-bound slope where performance is limited by β * I, and a compute-bound ceiling where performance is limited by π. The point where these two lines intersect is the ridge point, defining the minimum operational intensity required to achieve peak compute performance.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Roofline model provides the theoretical performance bounds; these related techniques are the practical compiler and hardware optimizations used to achieve those bounds.
Kernel Auto-Tuning
An automated process that empirically searches for the optimal implementation parameters (e.g., tile sizes, thread block dimensions, unroll factors) for a computational kernel on specific hardware. It bridges the gap between the Roofline model's theoretical peak and actual achieved performance by finding the kernel variant that best utilizes the hardware's arithmetic intensity and memory bandwidth.
- Process: Generates and benchmarks many kernel variants.
- Goal: Maximize FLOPS/sec for compute-bound kernels or bytes/sec for memory-bound kernels.
- Use Case: Critical for libraries like cuBLAS, oneDNN, and TVM to achieve portable high performance.
Loop Tiling (Blocking)
A critical loop nest optimization that partitions loop iterations into smaller blocks or tiles to improve data locality. This transformation directly targets the memory-bound region of the Roofline model by reducing the working set size to fit within faster cache hierarchies (L1, L2, L3), thereby decreasing the required DRAM bandwidth and increasing effective operational intensity.
- Mechanism: Breaks large matrix operations into sub-matrices.
- Impact: Can shift a kernel's performance point vertically on the Roofline plot, moving it closer to the compute roof.
- Example: Essential for high-performance GEMM (General Matrix Multiply) implementations.
Vectorization
A compiler optimization that converts scalar operations (processing one data element per instruction) into vector operations using Single Instruction, Multiple Data (SIMD) units (e.g., AVX-512, NEON). This optimization directly increases peak compute throughput (the height of the compute roof in the Roofline model) by exploiting data-level parallelism.
- Effect: Raises the flat, compute-bound section of the Roofline.
- Requirement: Depends on data layout (e.g., contiguous memory access) and alignment.
- Hardware: Utilizes vector registers and execution units present in modern CPUs and GPUs.
Operator Fusion
A graph-level optimization that combines multiple sequential operations (e.g., Convolution → BatchNorm → ReLU) into a single, compound kernel. This optimization attacks the memory bandwidth bottleneck highlighted by the Roofline model by eliminating intermediate tensor writes and reads to slow memory, effectively increasing the operational intensity of the fused compound operation.
- Primary Benefit: Reduces kernel launch overhead and global memory traffic.
- Roofline Impact: Moves the performance point rightward (higher ops/byte) on the model.
- Example: Fusing element-wise activations with preceding linear layers is a standard inference optimization.
Data Layout Optimization
The transformation of a tensor's in-memory arrangement (e.g., from NCHW to NHWC) to better match the access patterns of computational kernels and the underlying hardware's memory subsystem. Optimal data layout is a prerequisite for achieving high memory bandwidth (the slope of the Roofline) and enabling efficient vectorization.
- Goal: Ensure contiguous, aligned memory accesses to maximize cache line utilization.
- Hardware-Specific: NPUs and GPUs often have preferred layouts for different operators.
- Trade-off: May involve transposition overhead, which must be amortized by faster compute.
Cost Model
An analytical or heuristic function within a compiler that estimates the computational cost (latency, memory traffic, energy) of executing a specific operation, subgraph, or schedule. Cost models are the decision engines that use principles from the Roofline model to guide automated optimizations like operator fusion, graph partitioning, and kernel selection.
- Function: Predicts the performance of a candidate optimized graph.
- Basis: Incorporates hardware parameters like peak FLOPS and memory bandwidth.
- Use: Drives the search in auto-tuning and automatic scheduler generation in compilers like Apache TVM.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us