Hierarchical Roofline Performance Analysis for Deep Learning Applications

Yunsong Wang, Charlene Yang, Steven Farrell, Thorsten Kurth, Samuel Williams

Abstract

This paper presents a practical methodology for collecting performance data necessary to conduct hierarchical Roofline analysis on NVIDIA GPUs. It discusses the extension of the Empirical Roofline Toolkit for broader support of a range of data precisions and Tensor Core support and introduces a Nsight Compute based method to accurately collect application performance information. This methodology allows for automated machine characterization and application characterization for Roofline analysis across the entire memory hierarchy on NVIDIA GPUs, and it is validated by a complex deep learning application used for climate image segmentation. We use two versions of the code, in TensorFlow and PyTorch respectively, to demonstrate the use and effectiveness of this methodology. We highlight how the application utilizes the compute and memory capabilities on the GPU and how the implementation and performance differ in two deep learning frameworks.

Introduction

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 sufficient; GPUs have complex hierarchies (L1, L2, and HBM), and a kernel might be bound by one level while appearing efficient at another. This paper addresses the challenge of accurately measuring and visualizing these multi-level bottlenecks to account for the unique hardware features of modern GPUs.

Methodology

Machine Characterization

The authors extended the Empirical Roofline Toolkit (ERT) to move beyond standard double-precision (FP64) measurements. Micro-kernels were implemented to find empirical peaks for FP32, FP16 (on standard CUDA cores), and Tensor Cores. This involved significant optimization, such as using half2 vector types and uint32_t indexing to hit the hardware's theoretical limits.

Empirical Roofline ceilings for various precisions on an NVIDIA V100 GPU.

Application Characterization

To characterize applications, the methodology maps specific NVIDIA Nsight Compute metrics to Roofline model components. Since Nsight Compute does not provide a single "FLOP" counter, the authors aggregate various hardware counters (add, mul, fma) across different precisions and pipe types (such as the Tensor Core pipe) to calculate total work and data movement across the L1, L2, and HBM levels.

Experimental Evaluation

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 study compared two distinct implementations: TensorFlow 1.15 and PyTorch 1.5.0. This comparison allowed for an analysis of how different framework backends utilize the same underlying hardware.

Results and Discussion

Empirical Peaks and Hierarchical Visualization

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). The hierarchical plots clearly show "triplets" of dots for each kernel, representing performance relative to L1, L2, and HBM. A large gap between the L2 and HBM dots indicates high L2 data locality, a common trait in optimized DL kernels.

Hierarchical Roofline analysis showing performance across L1, L2, and HBM memory levels.

Key Insights

  • 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. While short, their volume adds significant launch overhead.
  • Tensor Core Saturation: Achieving the theoretical peak of Tensor Cores is difficult with manual code. While cuBLAS reached 96.5% of the peak, a hand-optimized wmma (Warp Matrix Multiply Accumulate) implementation only hit 54%.
  • 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, with kernels often sitting closer to the single-precision ceiling rather than the Tensor Core ceiling.
  • Automatic Mixed Precision (AMP): NVIDIA's AMP tools were highly effective, automatically moving kernels to the Tensor Core pipeline and matching the performance of manual FP16 implementations.

Conclusion

This work provides a robust roadmap for developers to pinpoint bottlenecks in deep learning models across the GPU memory and compute hierarchy. Future work will focus on multi-GPU scaling for cross-node communication (MPI/NCCL) and adapting the methodology for newer architectures like the A100 and H100, as well as non-NVIDIA hardware.

Summary updated

BibTeX
@inproceedings{wang2021hierarchical,
  author = {Yunsong Wang and Charlene Yang and Steven Farrell and Thorsten Kurth and Samuel Williams},
  title = {{Hierarchical Roofline Performance Analysis for Deep Learning Applications}},
  booktitle = {SAI},
  year = {2021},
  doi = {10.1007/978-3-030-80126-7\_35},
}
Figure