Reinforcement Learning and Adaptive Sampling for Optimized DNN Compilation

Byung Hoon Ahn, Prannoy Pilligundla, Hadi EsmaeilzadeharXiv 2019

TL;DR

RELEASE (Reinforcement Learning Compiler with Adaptive Sampling for Efficiency) accelerates the process of optimizing deep neural network (DNN) code for specific hardware. By replacing traditional search methods with a Reinforcement Learning (RL) agent and using k-means clustering to minimize expensive hardware measurements, it achieves a 4.45× speedup in optimization time while improving final inference performance by 5.6%.

What Problem Does This Paper Address?

To run deep learning models efficiently on hardware like GPUs, compilers must perform "tuning"—finding the best combination of parameters (knobs) for tiling, loop unrolling, and memory binding. The search space for these knobs is astronomical, often exceeding $10^{10}$ possibilities.

Current state-of-the-art tools like AutoTVM rely on Simulated Annealing (SA) or Genetic Algorithms (GA) to navigate this space. However, these methods have two major drawbacks:

  1. Slow Convergence: They often start from scratch and require many iterations to find a good configuration.
  2. Costly Feedback Loops: To know if a configuration is actually fast, the compiler must run it on real hardware. These physical measurements are the primary bottleneck, often making the optimization of a single model like ResNet-18 take upwards of 10 hours.

Methods

The authors introduce RELEASE, which tackles the problem from two angles:

1. RL-Based Search Agent

Instead of stochastic search (like SA), RELEASE formulates compilation as an RL problem.

  • Algorithm: It uses Proximal Policy Optimization (PPO), an actor-critic style algorithm.
  • State & Action: The state represents the current configuration of tuning knobs. The agent takes actions to increment, decrement, or maintain the value of each knob.
  • Reward: Since hardware measurements are slow, the agent uses a "surrogate reward" from a boosted-tree cost model (learned from previous hardware runs) to predict the fitness of a configuration.

2. Adaptive Sampling Module

To reduce the number of times the compiler needs to touch real hardware, the authors noticed that high-performing configurations often "cluster" together in the design space.

High-performing configurations exhibit clustering in the design space for VGG-16 and ResNet-18 layers.
  • Clustering: RELEASE takes the trajectory of configurations suggested by the RL agent and applies k-means clustering.
  • The "Knee" Method: It automatically determines the optimal number of clusters ($k$) by finding the "knee" of the loss curve (the point where adding more clusters yields diminishing returns).
  • Representative Sampling: Only the centroids of these clusters are sent to the hardware for actual measurement. This ensures the search covers diverse, high-potential areas of the design space without redundant testing.

Datasets

The authors evaluated RELEASE using three standard image classification models: AlexNet, VGG-16, and ResNet-18. All models were tested on the ImageNet dataset using an NVIDIA Titan Xp GPU. The primary benchmark for comparison was AutoTVM, the industry-standard automated tuner.

Key Insights and Ideas

  • Learning vs. Searching: RL agents can learn underlying correlations between tuning dimensions (e.g., how tiling in the X-dimension affects the Y-dimension), whereas Simulated Annealing treats these dimensions as independent.
  • Subsuming the Subspace: By measuring only cluster centroids, the authors prove that you can represent an entire subspace of configurations with a single hardware trial. This effectively "denoises" the search trajectory.
  • Synergy: The RL agent localizes the search to meaningful areas (exploitation), while adaptive sampling ensures diversity (exploration) without wasting time on near-identical hardware tests.

Key Results

RELEASE achieves significant efficiency gains over existing methods. For ResNet-18, the optimization time dropped from over 9 hours to roughly 2 hours, largely due to overcoming the physical measurement bottleneck.

Breakdown of optimization time for ResNet-18 layers, showing that physical measurements account for the vast majority of tuning time.
  • Optimization Speedup: RELEASE is 4.45× faster than AutoTVM on average.
  • Better Inference: RELEASE improved inference time by 5.6% compared to AutoTVM.
  • Measurement Reduction: The adaptive sampling module reduced the number of required hardware measurements by 2.33× when paired with RL.
  • Convergence: The RL agent required 2.88× fewer steps to converge to a high-quality solution compared to SA.

Limitations and Future Work

  • Scope of Layers: Evaluation focused primarily on convolution kernels; future work could extend this to other operators like depthwise convolutions.
  • Hardware Diversity: Testing RELEASE on edge devices (like ARM CPUs or specialized DSPs), where hardware measurements might be even slower, would be a valuable next step.
  • Algorithm Exploration: Other RL architectures could potentially yield even faster convergence or better handling of discrete vs. continuous knob spaces.

Summary updated

BibTeX
@misc{ahn2019reinforcement,
  author = {Byung Hoon Ahn and Prannoy Pilligundla and Hadi Esmaeilzadeh},
  title = {{Reinforcement Learning and Adaptive Sampling for Optimized DNN Compilation}},
  year = {2019},
  eprint = {1905.12799},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1905.12799},
}
Figure