[Paper Review] Equality Saturation for Tensor Graph Superoptimization
This paper introduces Tensat, a tensor graph superoptimizer using equality saturation to apply all rewrites simultaneously via e-graphs, achieving up to 16% runtime speedup and up to 48x faster optimization than prior sequential methods.
One of the major optimizations employed in deep learning frameworks is graph rewriting. Production frameworks rely on heuristics to decide if rewrite rules should be applied and in which order. Prior research has shown that one can discover more optimal tensor computation graphs if we search for a better sequence of substitutions instead of relying on heuristics. However, we observe that existing approaches for tensor graph superoptimization both in production and research frameworks apply substitutions in a sequential manner. Such sequential search methods are sensitive to the order in which the substitutions are applied and often only explore a small fragment of the exponential space of equivalent graphs. This paper presents a novel technique for tensor graph superoptimization that employs equality saturation to apply all possible substitutions at once. We show that our approach can find optimized graphs with up to 16% speedup over state-of-the-art, while spending on average 48x less time optimizing.
Motivation & Objective
- Motivate the suboptimality of sequential rewrite strategies in tensor graph optimization.
- Introduce equality saturation with e-graphs to explore a larger space of equivalent graphs.
- Extend equality saturation to handle non-local and multi-pattern rewrites in tensor graphs.
- Demonstrate practical speedups on standard ML models and analyze optimization time.
- Provide scalable extraction techniques (ILP) and cycle-filtering strategies to maintain tractable search.
Proposed method
- Represent tensor graphs with an operator-based DAG extended for equality saturation.
- Apply a set of rewrite rules via an e-graph to generate all equivalent graphs without destructive replacements.
- Perform exploration that saturates the e-graph using multi-pattern rewrite handling with a canonical S-expression matching approach.
- Extract the lowest-cost graph from the root e-class using either a greedy method or an ILP-based formulation with topological constraints.
- Use a cost model based on operator runtimes on hardware (GPU) to guide extraction.
- In extraction, optionally solve an ILP to select optimal nodes, with a cycle-avoidance mechanism via topological ordering.
Experimental results
Research questions
- RQ1Can equality saturation overcome phase-ordering in tensor graph rewriting to find globally optimal graphs?
- RQ2How can e-graphs be effectively extended to accommodate non-local and multi-pattern tensor rewrites?
- RQ3What are practical extraction methods (greedy vs ILP) for tensor graphs to minimize runtime cost?
- RQ4What are the performance trade-offs (speedup vs optimization time) when applying multi-pattern rewrites?
- RQ5How does Tensat compare to state-of-the-art sequential search (TASO) across diverse models?
Key findings
- Tensat achieves up to 16% faster runtime compared to state-of-the-art TASO on evaluated models.
- Optimization time is dramatically reduced (up to 300x faster) due to the compact e-graph representation of many equivalent graphs.
- Equality saturation enables covering a much larger search space than sequential backtracking, yielding better speedups in most benchmarks.
- In some cases, increasing multi-pattern iterations further improves speedups but risks e-graph explosion and ILP timeouts; cycle filtering mitigates this.
- Tensat provides competitive tradeoffs between speedup and optimization time, with practical integration into compilation workflows.
- Evaluation across models like NasRNN, SqueezeNet, and Inception-v3 demonstrates broad applicability.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.