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

ProGraML: A Graph-based Program Representation for Data Flow Analysis and Compiler Optimizations

Chris Cummins, Zacharias V. Fisches, Tal Ben-Nun, Torsten Hoefler, Michael F. P. O'Boyle, Hugh Leather

Machine learning has revolutionized how computers process text, images, and audio, but teaching models to truly "understand" computer code remains a profound challenge. Presented at ICML 2021, ProGraML introduces a novel way for machine learning models to perceive programs. By representing code as a sophisticated, multi-layered graph, the authors successfully bridge the gap between traditional compiler theory and modern deep learning.

The Challenge of Understanding Code

Compilers are the unsung heroes of software engineering, responsible for translating high-level code into optimized machine instructions. To perform these optimizations effectively, compilers rely heavily on Data Flow Analysis (DFA)—algorithms that reason about how values move through a program. DFA answers critical questions like, "Is this variable still needed?" or "Has this mathematical expression already been calculated?"

Researchers have increasingly looked to Machine Learning (ML) to enhance these compiler optimizations. However, most ML models struggle with basic program reasoning because of how they are fed the code. Previous approaches often treated code like natural language text (sequences of tokens) or used simplified tree structures like Abstract Syntax Trees (ASTs).

Limitations of prior approaches

These legacy methods suffer from critical blind spots:

  • Sensitivity to Noise: Sequence-based models are easily fooled by superficial changes, such as variable renaming or the insertion of dead code, missing the underlying semantics.
  • Loss of Operational Detail: Simplified graphs often miss crucial details, such as the specific order of operands (failing to distinguish between $a - b$ and $b - a$), which is vital for correct mathematical analysis.

The ProGraML Approach

To solve these representation issues, the authors propose ProGraML (Program Graphs for Machine Learning). Instead of looking at the raw source code, ProGraML builds a directed multigraph directly from a compiler’s Intermediate Representation (IR).

ProGraML Compiler Pipeline

ProGraML distinguishes itself through a highly structured graph architecture:

  1. Three-Dimensional Flow: Unlike simpler models, ProGraML incorporates three distinct types of edges to capture the full lifecycle of a program:
  2. Control-flow: Dictates where the program execution goes next.
  3. Data-flow: Tracks where specific values are produced and consumed.
  4. Call-flow: Maps how the program transitions between different functions.
  5. Positional Attributes: A key innovation is the addition of "positional" attributes on edges. This allows the model to explicitly distinguish between the first and second arguments of an operation, or differentiate between the true and false branches of an if statement.
  6. Message Passing Neural Networks (MPNN): To process this graph, the authors employ a Gated-Graph Neural Network (GGNN). This architecture is a natural fit: the way information "flows" through the neural network during training perfectly mimics how traditional data flow algorithms propagate information through a program's control-flow graph.

Benchmarks and Key Results

To train and test ProGraML, the researchers introduced DeepDataFlow, a massive new benchmark comprising 461,000 programs derived from real-world sources and totaling 8.5 billion data flow classification labels. It covers five classic compiler analyses: Reachability, Dominance, Data Dependency, Liveness, and Common Subexpression detection.

ProGraML sets a new standard for ML-driven code analysis:

  • Near-Perfect Analysis: On the DeepDataFlow benchmark, ProGraML achieved an impressive F1 score of $\geq 0.939$ across all five analysis tasks, significantly outperforming previous graph-based and sequence-based models.
  • Optimization Gains: When applied to the downstream task of Heterogeneous Device Mapping (predicting whether code will run faster on a CPU or a GPU), ProGraML reduced the test error by 1.2x compared to the previous state-of-the-art.
  • Algorithm Identification: In algorithm classification (e.g., identifying if a snippet is a sort or a search), ProGraML reduced error by 1.35x. This proves that a better structural understanding of data flow directly translates to a better understanding of what the code actually does.
  • Unprecedented Vocabulary Coverage: By handling instructions and data types separately, ProGraML can describe 98.3% of unseen programs. For context, previous top models like inst2vec could only cover about 34%.

Why It Matters: Semantics Over Syntax

By operating at the IR level, ProGraML inherently ignores stylistic choices like variable names or indentation, forcing the model to focus entirely on the program's mathematical and logical structure. Furthermore, because it is based on IR, ProGraML is language-agnostic. The authors demonstrated this portability by providing implementations for both LLVM (used by C/C++/Rust) and XLA (used by TensorFlow/JAX).

Limitations and the Path Forward

The primary limitation of ProGraML is scalability. Traditional compiler algorithms iterate until they reach a stable state (a "fixed point"). MPNNs, however, use a fixed number of message passing steps ($T$).

If a program is exceptionally large or contains highly complex loops, the signal might need to travel further than $T$ steps to reach a correct conclusion. While ProGraML generalizes well to programs slightly larger than its training data, its performance eventually degrades on massive codebases. Future work will likely need to explore "dynamically-sparse" message passing to handle these larger graphs more efficiently, paving the way for ML to fully manage enterprise-scale compiler optimizations.

Summary updated

BibTeX
@inproceedings{cummins2021programl,
  author = {Chris Cummins and Zacharias V. Fisches and Tal Ben-Nun and Torsten Hoefler and Michael F. P. O'Boyle and Hugh Leather},
  title = {{ProGraML: A Graph-based Program Representation for Data Flow Analysis and Compiler Optimizations}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
}
Figure