TpuGraphs: A Performance Prediction Dataset on Large Tensor Computational Graphs

Phitchaya Mangpo Phothilimthana, Sami Abu-El-Haija, Kaidi Cao, Bahare Fatemi, Michael Burrows, Charith Mendis, Bryan Perozzi

TL;DR

TpuGraphs is a massive new open-source dataset designed to train machine learning models to predict the execution time of full computational graphs on Tensor Processing Units (TPUs). By providing millions of graph-configuration pairs—with graphs up to 770x larger than previous benchmarks—it challenges the community to move beyond predicting small code "kernels" and toward optimizing entire end-to-end ML programs.

What Problem Does This Paper Address?

Modern machine learning compilers (like XLA) are responsible for translating high-level code (from frameworks like TensorFlow or PyTorch) into efficient hardware instructions. To do this well, they must make thousands of heuristic decisions: How should data be laid out in memory? Which operations should be fused together?

Currently, compilers use either hand-written rules, which are often sub-optimal, or "autotuners" that search through thousands of configurations. The catch is that autotuning is incredibly slow because it usually requires running each candidate configuration on real hardware to measure its speed.

The goal is to replace these slow hardware measurements with a learned cost model—an ML model that can analyze a computational graph and its configuration to instantly predict its runtime. However, existing datasets for this task only covered tiny sub-programs (basic blocks or small kernels), leaving a massive gap in predicting the performance of full, complex programs.

Methods

The authors treat machine learning programs as Directed Acyclic Graphs (DAGs), where nodes represent operations (like convolution or matrix multiplication) and edges represent data tensors.

To predict performance, they employ Graph Neural Networks (GNNs), specifically GraphSAGE and GCN. They explore two primary ways to incorporate "configuration" data (the compiler settings being tuned):

  1. Early-join: Configuration features are attached to each node before the GNN runs, allowing the model to see how a setting affects local operations.
  2. Late-join: The GNN processes the graph structure first to create a "graph embedding," and the configuration features are only added at the very end.

Crucially, they found that ranking losses (like ListMLE) are far more effective than standard regression (Mean Squared Error). In compiler optimization, predicting the exact millisecond runtime is less important than correctly ranking that Config A is faster than Config B.

Datasets

The paper introduces TpuGraphs, which consists of two main collections:

  • Layout: 31 million pairs of graphs and configurations. These focus on how tensors are ordered in physical memory (e.g., is a 3D tensor stored as Height-Width-Channel or Channel-Height-Width?).
  • Tile: 13 million pairs focusing on "tiling" sizes for fused subgraphs.
Comparison of TpuGraphs scale against existing datasets

How it differs from existing benchmarks: * Scale: It provides 25x more graphs than MalNet (the previous largest comparable dataset). * Complexity: The graphs are, on average, 770x larger than those in TenSet, the previous state-of-the-art for ML program performance. * Real-world relevance: The graphs are pulled from popular open-source architectures like ResNet, EfficientNet, Mask R-CNN, and various Transformers.

Key Insights and Ideas

  • The Scalability Wall: Training a GNN on a graph with 44,000 nodes (the upper limit in this dataset) often exceeds the memory of a single GPU. This forces researchers to think about "Graph Segment Training" or more memory-efficient architectures.
  • Context is King: For "Tile" configurations, the "early-join" method was significantly better. This suggests that the model needs to understand the interaction between a specific node's settings and its immediate neighbors to predict performance accurately.
  • Ranking > Prediction: Teaching a model to rank configurations is a more robust task than teaching it to predict absolute time, especially when hardware noise or system overhead can make absolute timings jittery.
  • Data Redundancy: Many samples share the same core graph but have different configurations. Efficient training pipelines must find ways to avoid re-processing the static graph structure repeatedly.

Key Results

  • Speed: The learned models are 94x to 2400x faster than running the actual code on a TPU. This enables much more exhaustive autotuning in a fraction of the time.
  • Accuracy: On the "Layout" task, the best baseline model achieved a Top-1 error of roughly 10-20% on unseen graphs. This means if you use the model to pick the "best" configuration, you'll be within 10-20% of the true optimal speed—a massive improvement over manual heuristics.
  • Generalization: Models trained on the "NLP" collection (Transformers) generalized better than those on the "XLA" collection, likely because the NLP collection was more architecturally homogeneous.

Limitations and Future Work

  • Hardware Specificity: Currently, the dataset only covers TPU v3. Performance characteristics on GPUs or CPUs would likely require different datasets or sophisticated transfer learning.
  • Data Imbalance: The dataset contains more samples of common architectures (like ResNet) than niche ones. This skew can make models perform poorly on unusual graph structures.
  • Static vs. Dynamic: The dataset focuses on static computational graphs. Handling programs with dynamic control flow (like loops or conditional branching) remains an open challenge.
  • The "Black Box" of Hardware: Even with this data, the complex interactions between the XLA compiler and the underlying TPU hardware remain difficult to model perfectly, suggesting that hybrid models (combining analytical physics-based models with ML) might be the next step.

Summary updated

BibTeX
@inproceedings{phothilimthana2023tpugraphs,
  author = {Phitchaya Mangpo Phothilimthana and Sami Abu-El-Haija and Kaidi Cao and Bahare Fatemi and Michael Burrows and Charith Mendis and Bryan Perozzi},
  title = {{TpuGraphs: A Performance Prediction Dataset on Large Tensor Computational Graphs}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=plAix1NxhU},
}
Figure