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

Learning Compiler Pass Orders using Coreset and Normalized Value Prediction

Youwei Liang, Kevin Stone, Ali Shameli, Chris Cummins, Mostafa Elhoushi, Jiadong Guo, Benoit Steiner, Xiaomeng Yang, Pengtao Xie, Hugh James Leather, Yuandong Tian

Abstract

Optimizing compiler pass sequences is a critical yet challenging task due to the astronomical search space of possible transformations. Traditional approaches rely on manual heuristics like LLVM’s -Oz or complex Reinforcement Learning (RL) agents that often struggle with sparse rewards and poor generalization. This paper presents a novel two-stage pipeline that combines coreset optimization with Normalized Value Prediction (NVP). By identifying a representative "coreset" of 50 high-performing pass sequences and utilizing a Graph Edge Attention Network (GEAN) to predict their performance on unseen code, the proposed method achieves a 4.7% average reduction in code size over -Oz. The approach demonstrates superior out-of-domain generalization and efficiency, reaching peak performance within only 45 compilation calls.

Introduction

Compilers such as LLVM utilize a series of optimization passes to transform source code into efficient machine instructions. However, the order in which these passes are applied significantly impacts the final output size and execution speed. With over 120 available passes and sequences extending dozens of steps, the search space is estimated at $10^{94}$—a scale that renders exhaustive search impossible.

Currently, the industry relies on two primary paradigms: manual heuristics and machine learning. Manual flags like -Oz provide a reliable baseline but lack the specificity required for diverse codebases. Conversely, Reinforcement Learning (RL) approaches attempt to navigate the search space dynamically but frequently suffer from training instability, slow convergence, and a failure to generalize to code domains outside their training set (e.g., transitioning from mathematical libraries to operating system kernels).

Methodology

1. Coreset Optimization

To simplify the optimization problem, the researchers shifted the objective from searching an infinite space to selecting from a high-quality subset. They identified a "coreset" of 50 universal pass sequences. This was achieved by executing random policies across thousands of programs and applying a greedy algorithm to select a subset of sequences that provided the maximum collective coverage and size reduction across the training corpus. This coreset acts as a representative sample of the most effective optimization strategies.

2. Normalized Value Prediction (NVP)

Rather than using RL to generate sequences step-by-step, the authors framed the problem as a supervised learning task. For any given program, the model predicts the relative performance of each of the 50 coreset sequences. This "Normalized Value Prediction" provides the model with dense labels, making the training process significantly more stable and data-efficient than traditional RL rewards.

3. Graph Edge Attention Network (GEAN)

To effectively represent program structure, the pipeline utilizes a Graph Edge Attention Network (GEAN). Programs are converted into ProGraML graphs, which capture both control and data flow. A key innovation in this architecture is the introduction of "Type Graphs." By decomposing complex user-defined data structures (such as C++ structs) into their primitive components, the model gains a deeper understanding of data layout, preventing it from being confounded by unfamiliar types in new codebases.

Experimental Setup

The methodology was evaluated using the CompilerGym framework across 14 diverse datasets. These included:

  • Uncurated Datasets: Over 700,000 programs sourced from the Linux Kernel, TensorFlow, OpenCV, and GitHub crawls for large-scale training.
  • Curated Datasets: Hand-picked benchmark suites such as Cbench, MiBench, CHStone, and NPB. These were strictly held out during training to evaluate the model’s ability to generalize to "real-world," out-of-domain code.

Key Results and Insights

Performance and Efficiency

The GEAN-NVP model achieved a 4.7% average reduction in code size compared to the standard LLVM -Oz flag. Notably, the model reaches this level of optimization within a budget of 45 compilation calls, making it highly practical for production environments where compilation time is a constrained resource.

Generalization and the Power of the Coreset

The study revealed that a small coreset of 50 sequences is remarkably "rich." An "Oracle" analysis (selecting the best of the 50 perfectly) showed a potential 5.8% improvement over -Oz, suggesting that the coreset captures the vast majority of available optimization gains. Unlike RL-based methods like Autophase, which often underperformed -Oz on held-out data, the NVP approach consistently delivered positive improvements across all tested domains.

The Importance of Type Graphs

Ablation studies highlighted that the inclusion of Type Graphs was the most critical factor for performance. Understanding how data is structured—rather than just how logic flows—is essential for the compiler to make informed decisions about pass ordering.

Conclusion and Future Work

This research demonstrates that framing compiler optimization as a selection problem over a curated coreset is more effective and efficient than open-ended RL search. By combining GNN-based program representations with normalized value prediction, the authors achieved state-of-the-art results in code size reduction.

Future research directions include expanding this framework to optimize for execution speed (throughput and latency), which presents additional challenges due to hardware-dependent performance metrics. Additionally, exploring dynamic coresets that evolve as the model encounters new types of software could further push the boundaries of automated compiler optimization.

Summary updated

BibTeX
@inproceedings{liang2023learning,
  author = {Youwei Liang and Kevin Stone and Ali Shameli and Chris Cummins and Mostafa Elhoushi and Jiadong Guo and Benoit Steiner and Xiaomeng Yang and Pengtao Xie and Hugh James Leather and Yuandong Tian},
  title = {{Learning Compiler Pass Orders using Coreset and Normalized Value Prediction}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=DwEU2zXeHG},
}
Figure