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

Equality Saturation for Tensor Graph Superoptimization

Yichen Yang, Phitchaya Mangpo Phothilimthana, Yisu Remy Wang, Max Willsey, Sudip Roy, Jacques A. PienaarMLSys 2021

TL;DR

This paper introduces TENSAT, a novel framework for optimizing deep learning computation graphs. By employing "equality saturation," TENSAT explores a vastly larger space of equivalent graphs than previous methods, achieving up to 16% speedup on inference tasks while optimizing 48x faster. This approach promises to integrate into standard compilation flows for more efficient AI.

What Problem Does This Paper Address?

Deep learning models are represented as computation graphs, and optimizing these graphs is crucial for performance. Current optimization techniques, used in production frameworks, rely on heuristics to apply "rewrite rules" (transformations that preserve semantic equivalence). While research has shown that searching for optimal sequences of these rules is better than heuristics, existing methods apply rules sequentially. This sequential approach is sensitive to the order of application and can get stuck in local optima, exploring only a tiny fraction of the exponentially large space of possible equivalent graphs. This leads to sub-optimal performance and inefficient optimization times.

Methods

TENSAT tackles this "phase-ordering problem" by using equality saturation. Instead of applying rules one by one, equality saturation applies all possible rules simultaneously. This is achieved through an e-graph, a data structure that compactly represents all equivalent forms of a program. The optimization process has two phases:

  1. Exploration: The e-graph is built by applying all applicable rewrite rules until saturation (no new information can be added) or a timeout. TENSAT extends this by supporting multi-pattern rewrite rules, which can significantly grow the e-graph but also lead to more powerful optimizations. To manage this growth, a cycle-filtering mechanism is introduced during exploration to prevent the e-graph from becoming too large and complex for the next phase.
  2. Extraction: Once the e-graph is built, an optimal graph is selected from the e-graph. TENSAT explores two extraction strategies: a greedy approach and an Integer Linear Programming (ILP)-based approach. The ILP approach, when combined with cycle filtering during exploration, can guarantee finding the globally optimal acyclic graph.

Datasets

The paper evaluates TENSAT on the inference graphs of seven well-known deep learning models: BERT, ResNeXt-50, NasNet-A, NasRNN, Inception-v3, VGG-19, and SqueezeNet. These models cover both computer vision and NLP tasks, including both human-designed and neural architecture search-discovered models.

Key Insights and Ideas

  • Equality Saturation for Graph Optimization: Applying all possible rewrites simultaneously, rather than sequentially, is key to exploring a much larger space of equivalent graphs and finding better optimizations.
  • E-graphs as Compact Representations: E-graphs are powerful data structures that can represent an exponential number of equivalent program forms compactly, enabling efficient exploration.
  • Multi-Pattern Rewrite Rules are Crucial: These rules, which match multiple subgraphs simultaneously, are essential for significant optimization in deep learning graphs, though they require careful management to avoid explosive e-graph growth.
  • Cycle Filtering is Essential for Scalability: Preventing cycles in the e-graph during exploration is critical for making the ILP extraction phase feasible and scalable to larger graphs.
  • Global Optimality is Achievable: The combination of equality saturation and ILP extraction can guarantee finding the globally optimal solution, unlike heuristic or purely sequential search methods.

Key Results

  • TENSAT achieves up to 16% speedup in runtime compared to state-of-the-art methods like TASO.
  • Optimization time is drastically reduced, with TENSAT spending on average 48x less time optimizing than TASO.
  • For some benchmarks, TENSAT is up to 379x faster than TASO's total search time.
  • The ILP extraction method, when combined with efficient cycle filtering, is shown to be crucial for finding optimal graphs, especially for complex models.

Limitations and Future Work

  • E-graph Size Explosion: While multi-pattern rules are powerful, they can lead to rapid e-graph growth, limiting the depth of exploration. The authors suggest future work could involve using machine learning to selectively apply rules to manage this growth.
  • Cost Model Accuracy: For complex hardware, the current cost model (sum of operator costs) might not fully capture performance. Future work could explore more sophisticated cost models or learned extraction approaches.
  • ILP Solver Bottleneck: While cycle filtering significantly improves ILP performance, it can still be a bottleneck for very large graphs.
  • Hardware Specificity: The paper notes that for some hardware (like the T4 GPU), certain rewrite rules from TASO did not yield speedups, highlighting the need for hardware-aware optimization.

Summary updated

BibTeX
@inproceedings{yang2021equality,
  author = {Yichen Yang and Phitchaya Mangpo Phothilimthana and Yisu Remy Wang and Max Willsey and Sudip Roy and Jacques A. Pienaar},
  title = {{Equality Saturation for Tensor Graph Superoptimization}},
  booktitle = {MLSys},
  year = {2021},
}

Loading related content...

Figure