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

PERFOGRAPH: A Numerical Aware Program Graph Representation for Performance Optimization and Program Analysis

Ali TehraniJamsaz, Quazi Ishtiaque Mahmud, Le Chen, Nesreen K. Ahmed, Ali Jannesari

Abstract

Machine learning models for code optimization are heavily dependent on how source code is represented. Existing graph-based representations, such as ProGraML, often ignore critical numerical values and flatten complex data structures, limiting their effectiveness in performance-sensitive tasks. This paper introduces PERFOGRAPH, a novel representation that explicitly captures numerical information and aggregate data types from LLVM Intermediate Representation (IR). By incorporating "numerical awareness" via digit embeddings and maintaining the structural hierarchy of multi-dimensional arrays, PERFOGRAPH achieves state-of-the-art results across various optimization benchmarks, including device mapping and parallelism discovery.

Introduction

To leverage deep learning for compiler optimization, source code must be translated into a graph format. While current state-of-the-art representations like ProGraML effectively capture control and data flow, they possess a significant "blind spot": they treat all numerical constants as generic tokens (e.g., i32) and flatten aggregate types like multi-dimensional arrays. In the context of performance optimization, these details are paramount. Loop bounds determine unrolling strategies, and array dimensions dictate memory access patterns. Discarding this information limits the reasoning capabilities of downstream models.

The PERFOGRAPH Representation

PERFOGRAPH addresses these limitations by introducing three major structural enhancements to the standard program graph:

  1. Unified Variable Nodes: Instead of creating new nodes for every variable access, PERFOGRAPH uses a single, unified node for each local variable. Store instructions point directly to these nodes, simplifying the tracking of memory modifications for Graph Neural Networks (GNNs).
  2. Numerical Awareness: To handle the infinite variety of numerical values without an exploding vocabulary, PERFOGRAPH employs "Digit Embedding." Numbers are decomposed into digits and positional values, which are then embedded and aggregated.
  3. Aggregate Data Type Preservation: Multi-dimensional arrays are represented as dedicated node chains that preserve their structural hierarchy rather than being flattened into 1D blocks.
Evolution of the PERFOGRAPH representation showing the integration of local variables, store nodes, and numerical values.

Numerical Awareness and Aggregate Structures

The inclusion of numerical values allows the model to understand the magnitude of constants, which is critical for predicting execution time and identifying optimization opportunities. For instance, a loop bound of 10 versus 10,000 implies vastly different optimization strategies. Similarly, by representing a 3D array as a chain of nodes—each storing the length and type of a specific dimension—the GNN can reason about spatial locality and memory access patterns more effectively.

C source code and its corresponding PERFOGRAPH representation, highlighting how multi-dimensional arrays and numerical constants are preserved.

Experimental Evaluation

PERFOGRAPH was evaluated across several diverse benchmarks:

  • Device Mapping: Achieved state-of-the-art error rates of 6.0% on AMD and 10.0% on NVIDIA datasets, outperforming ProGraML by up to 10%.
  • Parallelism Discovery: Reached 99% accuracy in identifying parallelizable loops, a 9% improvement over previous methods.
  • Parallel Pattern Detection: Achieved 99% accuracy in classifying loop patterns such as Reductions and Stencils.
  • Algorithm Classification: Demonstrated robust performance on the POJ-104 dataset.

Ablation studies confirmed that both aggregate data nodes and digit embeddings contribute significantly to these gains. While aggregate data structures provided a larger boost in device mapping, numerical awareness was crucial for tasks involving complex loop logic.

Discussion and Future Work

PERFOGRAPH demonstrates that numbers and memory topology are semantic features, not just syntax. By reducing the "hop distance" for GNNs to understand state changes and injecting numerical meaning, the representation makes learning more efficient.

Currently, PERFOGRAPH is limited to compile-time constants and may struggle with very small datasets where pre-trained models have an advantage. Future work involves integrating runtime information (e.g., hardware performance counters) and developing a pre-trained version of PERFOGRAPH to improve generalization on small-scale downstream tasks.

Summary updated

BibTeX
@inproceedings{tehranijamsaz2023perfograph,
  author = {Ali TehraniJamsaz and Quazi Ishtiaque Mahmud and Le Chen and Nesreen K. Ahmed and Ali Jannesari},
  title = {{PERFOGRAPH: A Numerical Aware Program Graph Representation for Performance Optimization and Program Analysis}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=3jAsfo8x8k},
}
Figure