Skip to main content
QUICK REVIEW

[Paper Review] SPORES: Sum-Product Optimization via Relational Equality Saturation for Large Scale Linear Algebra

Yisu Remy Wang, Shana Hutchison|arXiv (Cornell University)|Feb 19, 2020
Parallel Computing and Optimization TechniquesComputer Science27 references11 citations
TL;DR

SPORES introduces a complete, relational algebra-based optimization framework for large-scale linear algebra workloads using equality saturation and E-Graphs to explore equivalent expressions. It integrates into SystemML, rediscovering all existing optimizations and discovering new ones, achieving up to 5x speedups on real machine learning workloads by leveraging sparsity and algebraic equivalences systematically.

ABSTRACT

Machine learning algorithms are commonly specified in linear algebra (LA). LA expressions can be rewritten into more efficient forms, by taking advantage of input properties such as sparsity, as well as program properties such as common subexpressions and fusible operators. The complex interaction among these properties' impact on the execution cost poses a challenge to optimizing compilers. Existing compilers resort to intricate heuristics that complicate the codebase and add maintenance cost but fail to search through the large space of equivalent LA expressions to find the cheapest one. We introduce a general optimization technique for LA expressions, by converting the LA expressions into Relational Algebra (RA) expressions, optimizing the latter, then converting the result back to (optimized) LA expressions. One major advantage of this method is that it is complete, meaning that any equivalent LA expression can be found using the equivalence rules in RA. The challenge is the major size of the search space, and we address this by adopting and extending a technique used in compilers, called equality saturation. We integrate the optimizer into SystemML and validate it empirically across a spectrum of machine learning tasks; we show that we can derive all existing hand-coded optimizations in SystemML, and perform new optimizations that lead to speedups from 1.2X to 5X.

Motivation & Objective

  • To address the limitations of heuristic-based compilers in optimizing complex linear algebra expressions across multiple optimization dimensions like sparsity, common subexpressions, and fusible operators.
  • To provide a complete and systematic search for equivalent, optimized linear algebra expressions by leveraging relational algebra as an intermediate representation.
  • To overcome the intractably large search space of equivalent expressions through equality saturation and E-Graphs, enabling scalable exploration without sacrificing completeness.
  • To integrate the optimizer into SystemML and empirically validate its ability to rediscover known optimizations and discover new ones that improve performance.

Proposed method

  • Transform linear algebra expressions into relational algebra expressions using a formal mapping, representing sum, product, and transpose operations as relational operators (e.g., joins, unions, aggregates).
  • Use a relational algebra framework over K-relations (bag semantics with numeric values) to ensure equivalence is decidable and completeness is achievable via isomorphism of unions of conjunctive queries.
  • Apply equality saturation with a set of standard relational identities to populate an E-Graph, compactly representing all equivalent expressions in the search space.
  • Leverage schema-aware class invariants to access attribute information and enable constant folding and accurate cost estimation during rule application.
  • Sample rewrite matches during equality saturation to balance exploration depth and convergence time, avoiding full saturation in large-scale programs.
  • Extract the optimal expression from the E-Graph using a cost-based constraint solver, then convert back to a linear algebra expression for execution.

Experimental results

Research questions

  • RQ1Can a relational algebra-based intermediate representation enable complete exploration of equivalent linear algebra expressions, including those missed by heuristic rules?
  • RQ2How can equality saturation and E-Graphs be adapted to manage the large search space introduced by unions, aggregates, and common subexpressions in sum-product expressions?
  • RQ3To what extent can this approach rediscover and surpass existing hand-coded optimizations in production compilers like SystemML?
  • RQ4What performance gains are achievable by discovering new, non-trivial optimizations through systematic search in real-world machine learning workloads?

Key findings

  • SPORES successfully rediscovered all existing hand-coded optimizations in SystemML, demonstrating completeness and practical applicability.
  • The optimizer discovered new, previously unknown optimizations that led to performance improvements ranging from 1.2× to 5× across diverse machine learning workloads.
  • By using relational algebra with bag semantics and canonical form equivalence, SPORES ensures that all equivalent expressions are systematically explored, achieving theoretical completeness.
  • The integration of class invariants enabled accurate cost estimation and effective constant folding, improving the quality of optimization decisions.
  • Sampling rewrite matches during equality saturation achieved good exploration efficiency without full saturation, making the approach scalable to large programs.
  • Empirical evaluation confirmed that constraint solvers, while theoretically optimal, introduced significant overhead; thus, sampling-based exploration was more effective in practice.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.