TL;DR
This paper introduces a robust methodology for performing hierarchical Roofline analysis on NVIDIA GPUs, specifically tailored for the complexities of deep learning. By extending the Empirical Roofline Toolkit (ERT) to support mixed-precision and Tensor Cores, and leveraging NVIDIA’s Nsight Compute for granular profiling, the authors provide a roadmap for developers to pinpoint exactly where their models are bottlenecked—whether it's at the L1 cache, L2 cache, HBM, or the compute cores themselves.
What Problem Does This Paper Address?
The classic Roofline model is a staple of performance engineering, plotting computational throughput against arithmetic intensity to show if an application is limited by memory bandwidth or peak compute. However, modern deep learning (DL) has outpaced the simple version of this model.
DL applications often use mixed precision (FP16, FP32) and specialized hardware like Tensor Cores, which have vastly different performance ceilings. Furthermore, a single "memory bandwidth" figure is no longer enough; GPUs have complex hierarchies (L1, L2, and HBM), and a kernel might be bound by one level while appearing efficient at another. The authors tackle the challenge of accurately measuring and visualizing these multi-level bottlenecks in a way that accounts for the unique hardware features of modern GPUs.
Methods
The authors propose a two-pronged methodology:
- Machine Characterization (ERT Extensions): They updated the Empirical Roofline Toolkit (ERT) to move beyond double-precision (FP64). They implemented micro-kernels to find the empirical peaks for FP32, FP16 (on standard CUDA cores), and Tensor Cores. This involved significant optimization, such as using
half2vector types anduint32_tindexing to hit the hardware's theoretical limits. - Application Characterization (Nsight Compute): They developed a mapping between specific NVIDIA Nsight Compute metrics and the Roofline model's components. Since Nsight Compute doesn't provide a single "FLOP" counter, the authors show how to aggregate various hardware counters (add, mul, fma) across different precisions and pipe types (like the Tensor Core pipe) to calculate total work and data movement across the L1, L2, and HBM levels.
Datasets
The methodology was validated using DeepCAM, a state-of-the-art deep learning benchmark for climate image segmentation (based on the ResNet-50 architecture).
- The authors compared two distinct implementations of DeepCAM: one in TensorFlow 1.15 and one in PyTorch 1.5.0.
- This allowed them to analyze how different framework backends utilize the same underlying hardware.
Key Insights and Ideas
- The "Zero-AI" Tax: A surprising 40-50% of kernel invocations in these DL frameworks are "zero-AI" kernels—operations like data reformatting or precision casting that perform no floating-point math at all. While they might be short, their sheer volume adds significant launch overhead.
- Tensor Core Saturation: Achieving the theoretical peak of Tensor Cores (107.5 TFLOP/s on a V100) is difficult with manual code. The authors found that
cuBLASreached 96.5% of the peak, while a hand-optimizedwmma(Warp Matrix Multiply Accumulate) implementation only hit 54%, highlighting the value of highly tuned vendor libraries. - Framework Personalities:
- TensorFlow tended to utilize Tensor Cores more aggressively in the forward pass but showed poorer L1 cache locality.
- PyTorch showed better cache utilization in its forward pass, with kernels often sitting closer to the single-precision ceiling rather than the Tensor Core ceiling.
- AMP is a "Free Lunch": The Automatic Mixed Precision (AMP) tools provided by NVIDIA were shown to be highly effective, automatically moving kernels to the Tensor Core pipeline and matching the performance of tedious, manual FP16 implementations.
Key Results
- Empirical Peaks: On an NVIDIA V100, the authors established empirical ceilings of 7.7 TFLOP/s (FP64), 15.2 TFLOP/s (FP32), 29.2 TFLOP/s (FP16 on CUDA cores), and 103.7 TFLOP/s (Tensor Cores).
- Hierarchical Visualization: The hierarchical plots (Fig 3-6) clearly show "triplets" of dots for each kernel. A large gap between the L2 and HBM dots indicates high L2 data locality, a common trait in optimized DL kernels.
- Optimization Impact: Using the O1 optimization level in PyTorch's AMP significantly reduced kernel runtimes and shifted many operations from the standard CUDA pipes to the high-throughput Tensor Core pipes.
Limitations and Future Work
- Multi-GPU Scaling: The current work focuses on single-node, single-GPU performance. The authors acknowledge the need to extend this to cross-node communication (MPI/NCCL) for true "Exascale" DL analysis.
- Profiling Overhead: Nsight Compute serializes multi-stream execution during profiling. This means the model might overlook performance gains from kernel overlapping that happen during normal execution.
- Architectural Breadth: While focused on NVIDIA V100s, the authors plan to adapt the methodology for newer architectures (like A100/H100) and non-NVIDIA hardware.
Summary updated