Bolt: Bridging the Gap between Auto-tuners and Hardware-native Performance

Jiarong Xing, Leyuan Wang, Shang Zhang, Jack Chen, Ang Chen, Yibo Zhu

Abstract

Today's auto-tuners (e.g., AutoTVM, Ansor) generate efficient tensor programs by navigating a large search space to identify effective implementations, but they do so with opaque hardware details. Thus, their performance could fall behind that of hardware-native libraries (e.g., cuBLAS, cuDNN), which are hand-optimized by device vendors to extract high performance. On the other hand, these vendor libraries have a fixed set of supported functions and lack the customization and automation support afforded by auto-tuners. Bolt is based on the recent trend that vendor libraries are increasingly modularized and reconfigurable via declarative control (e.g., CUTLASS). It enables a novel approach that bridges this gap and achieves the best of both worlds, via hardware-native templated search. Bolt provides new opportunities to rethink end-to-end tensor optimizations at the graph, operator, and model levels. Bolt demonstrates this concept by prototyping on a popular auto-tuner in TVM and a class of widely-used platforms (i.e., NVIDIA GPUs). Bolt improves the inference speed of common convolutional neural networks by 2.5x on average over the state of the art, and it auto-tunes these models within 20 minutes.

Introduction: The Performance Gap

In the world of Deep Neural Network (DNN) deployment, engineers face a frustrating trade-off between the flexibility of auto-tuners and the blistering speed of hand-optimized vendor libraries. Auto-tuners like Ansor are flexible but often treat hardware as a "black box," failing to utilize specialized features like NVIDIA’s Tensor Cores effectively. Conversely, vendor libraries like cuBLAS offer native performance but are rigid, supporting only a fixed set of functions and making custom operator fusions nearly impossible.

Normalized speed comparison between Ansor and cuBLAS, demonstrating the performance gap.

Bolt identifies this as a "performance gap" and aims to bridge it by treating vendor libraries not as rigid black boxes, but as reconfigurable templates.

Bolt introduces a novel approach called hardware-native templated search. Instead of searching a massive, unconstrained space of possible code implementations, Bolt utilizes high-performance templates from libraries like NVIDIA’s CUTLASS. The framework operates across three distinct levels:

  1. Graph Level (Persistent Kernel Fusion): Bolt introduces "persistent kernels" that keep intermediate data in the GPU’s fastest memory (registers or shared memory) between layers, avoiding the latency of global memory trips.
  2. Operator Level (Automated Code Generation): By understanding hardware constraints, Bolt's light-weight performance profiler only needs to evaluate a few dozen high-potential configurations rather than thousands of random ones.
  3. Model Level (System-Model Codesign): Bolt optimizes models by aligning tensor shapes to specific bit-boundaries (e.g., 128-bit) to maximize memory throughput.
The Bolt optimization pipeline, spanning graph-level and tensor-level optimizations.

Key Insights and Ideas

  • The "White-box" Advantage: By treating vendor libraries as "white-box" templates, Bolt can inject custom logic directly into high-performance CUDA code.
  • Threadblock Residence: For fusion to be effective, data must reside in the same physical memory space. Bolt manages this through Register File (RF) and Shared memory-resident fusion strategies.
  • Search Space Reduction: Traditional auto-tuners can take days to tune. Bolt’s hardware-aware profiler slashes this time by orders of magnitude by filtering out illegal or inefficient hardware configurations.
  • Strategic Padding: Bolt automatically pads unaligned tensors to 8-element boundaries, enabling 128-bit vectorized loads which significantly outperform unaligned access.

Key Results

Evaluation on NVIDIA Tesla T4 GPUs using FP16 data types across architectures like ResNet, VGG, and RepVGG yielded significant performance gains:

  • Speedup: Bolt improved inference speed by 2.5x on average over Ansor, with specific VGG models reaching up to 4.2x speedup.
  • Tuning Efficiency: While Ansor required roughly 12 hours to tune models, Bolt completed the task in under 20 minutes.
  • Hardware Utilization: For FP16 GEMMs on an A100 GPU, Bolt reached over 95% of the theoretical hardware limit (300 TFLOPS).
  • Fusion Gains: Persistent kernel fusion alone provided a 1.1x to 2.0x speedup for back-to-back convolutional layers.

Limitations and Future Work

Bolt currently focuses primarily on memory-bound operators for its fusion strategies. Fusing compute-bound operators remains complex due to potential hardware resource contention. While the current prototype is tied to the NVIDIA/CUTLASS ecosystem, the underlying principles of templated search are generalizable to other backends like Intel’s oneDNN or AMD’s ROCm.

Summary updated

Abstract

Today's auto-tuners (e.g., AutoTVM, Ansor) generate efficient tensor programs by navigating a large search space to identify effective implementations, but they do so with opaque hardware details. Thus, their performance could fall behind that of hardware-native libraries (e.g., cuBLAS, cuDNN), which are hand-optimized by device vendors to extract high performance. On the other hand, these vendor libraries have a fixed set of supported functions and lack the customization and automation support afforded by auto-tuners. Bolt is based on the recent trend that vendor libraries are increasingly modularized and reconfigurable via declarative control (e.g., CUTLASS). It enables a novel approach that bridges this gap and achieves the best of both worlds, via hardware-native templated search. Bolt provides new opportunities to rethink end-to-end tensor optimizations at the graph, operator, and model levels. Bolt demonstrates this concept by prototyping on a popular auto-tuner in TVM and a class of widely-used platforms (i.e., NVIDIA GPUs) -- both in large deployment in our production environment. Bolt improves the inference speed of common convolutional neural networks by 2.5x on average over the state of the art, and it auto-tunes these models within 20 minutes.
BibTeX
@inproceedings{xing2022bolt,
  author = {Jiarong Xing and Leyuan Wang and Shang Zhang and Jack Chen and Ang Chen and Yibo Zhu},
  title = {{Bolt: Bridging the Gap between Auto-tuners and Hardware-native Performance}},
  booktitle = {MLSys},
  year = {2022},
  url = {https://openreview.net/forum?id=qmIETUd83c},
}
Figure