NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Generating GPU Compiler Heuristics using Reinforcement Learning

Ian Colbert, Jake Daly, Norm RubinarXiv 2021

In high-performance graphics, the compiler serves as a critical component, translating high-level shader code into machine instructions. This process involves making numerous heuristic decisions that significantly impact performance. Traditionally, these heuristics are hand-tuned by experts—a process that is labor-intensive, expensive, and often fails to generalize across diverse workloads. Researchers at AMD have proposed a scalable alternative: using Deep Reinforcement Learning (DRL) to automate "glass box" tuning within production GPU compilers.

The "Black Box" vs. "Glass Box" Challenge

A primary obstacle in compiler optimization is the gap between "black box" and "glass box" approaches. Most existing autotuners operate as black boxes, sitting outside the compiler and toggling high-level flags. While useful, this approach cannot adapt to novel code structures encountered during runtime. Conversely, a "glass box" approach integrates optimization logic directly into the compiler's decision-making process.

Comparison of Black Box and Glass Box compiler autotuning approaches.

Furthermore, production compilers are dynamic environments. Heuristics tuned for one version may become obsolete as the compiler's internal logic evolves. Standard "on-policy" RL, which requires constant interaction with the environment, is often too slow for production cycles where full graphics benchmarks can take several minutes to execute.

Methodology: Off-Policy Reinforcement Learning

To address these challenges, the researchers utilized Off-Policy Q-Learning. This choice allows the system to decouple data collection from model training, enabling the reuse of historical performance data even as the compiler changes.

Conceptual differences between Supervised Learning and Reinforcement Learning.

The framework is integrated into a Continuous Integration (CI) loop. It collects performance data, updates a Q-table representing state-action-reward mappings, and trains a Deep Neural Network (DNN) to approximate this table. The resulting model is remarkably compact—less than 20KB—allowing it to be embedded directly into the AMD Radeon™ Software compiler without significant overhead.

For their case study, the team focused on Wavefront Size selection (choosing between 32 or 64 work-items). The model's "state" includes 44 static features from the compiler’s Intermediate Representation (IR), such as instruction counts and register usage. The "reward" signal is based on the normalized change in global frame rate, ensuring the model optimizes for the actual end-user experience.

Key Results and Stability

The RL-based heuristic was evaluated against a suite of over 150 graphics benchmarks, including modern AAA titles. On the Radeon™ RX 6800 XT, the learned heuristic matched or outperformed expert-tuned defaults in 98% of cases. While the average performance gain was 1.6%, specific benchmarks saw improvements as high as 15.8%.

One of the most significant findings was the model's long-term stability. A model trained on a year-old compiler version maintained its performance without regressions even after a year of internal compiler updates. This resilience suggests that the learned features capture fundamental aspects of GPU performance that transcend specific compiler versions. Additionally, the researchers demonstrated successful transfer learning, using a model trained for one GPU architecture as a highly effective starting point for another.

Conclusion and Future Directions

This research demonstrates that small, well-designed neural networks can effectively replace complex, hand-tuned compiler heuristics. By integrating DRL into the "glass box" of the compiler, performance can be optimized automatically and maintained over time. Future work will explore incorporating dynamic performance counters into the state representation and expanding the action space to handle more granular optimization tasks.

Reference: Colbert, I., Daly, J., & Rubin, N. (2021). Generating GPU Compiler Heuristics using Reinforcement Learning. arXiv:2111.12055v1 [cs.LG].

Summary updated

BibTeX
@misc{colbert2021generating,
  author = {Ian Colbert and Jake Daly and Norm Rubin},
  title = {{Generating GPU Compiler Heuristics using Reinforcement Learning}},
  year = {2021},
  eprint = {2111.12055},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2111.12055},
}
Figure