Papers
Topics
Authors
Recent
Search
2000 character limit reached

LLM-Guided Strategy Synthesis for Scalable Equality Saturation

Published 19 Apr 2026 in cs.AI, cs.MA, and cs.PL | (2604.17364v1)

Abstract: Equality saturation (EqSat) is a powerful optimization paradigm that compactly represents many equivalent programs in an e-graph and delays commitment until extraction selects a lowest-cost program. Making EqSat effective, therefore, requires not only domain-specific rewrite rules but also domain-specific strategies. Today, much of this strategy design is still manual, making it a major obstacle to automating e-graph-based compilers. Recent rule-synthesis frameworks can automatically infer large rewrite vocabularies from semantic specifications, but they also enlarge the rewrite space and further exacerbate e-graph explosion. Although LLMs make automated strategy synthesis plausible, directly evolving backend code remains ineffective in practice. The search lacks reusable strategy abstractions and actionable feedback, and can easily trigger e-graph explosion or converge to poor designs. We present EggMind, an LLM-guided, end-to-end framework for synthesizing reusable EqSat strategies. At its core, EggMind introduces a domain-specific language, EqSatL, to represent EqSat strategies as explicit and inspectable artifacts. It then proposes an LLM-guided agentic workflow, equipped with novel techniques including proof-derived rewrite motif caching and tractability guidance, to search efficiently for high-quality strategies while keeping synthesis stable under e-graph growth. Evaluation shows that EggMind substantially improves the resource-quality trade-off on vectorization benchmarks, reducing final cost by 45.1% and peak RAM by 69.1% relative to full EqSat. We further show that the same methodology transfers effectively to an XLA-based tensor compiler, and demonstrate its practical potential in a logic-synthesis case study with augmented rewrite spaces.

Summary

  • The paper introduces EggMind, a novel LLM-guided framework with the EqSatL DSL that automates strategy synthesis to control e-graph expansion and optimize rewrite searches.
  • It employs proof-derived motif caching and dependency-driven phase partitioning to provide compact, reusable feedback that stabilizes the synthesis process in complex rewrite spaces.
  • Empirical evaluations reveal up to an 11.89× runtime speedup along with significant cost and memory reductions, outperforming traditional hand-crafted EqSat strategies.

LLM-Guided Strategy Synthesis for Scalable Equality Saturation

Introduction and Motivation

The paradigm of equality saturation (EqSat) achieves program optimization by symbolically exploring an exponential number of equivalent expressions via e-graphs, decoupling rewrite search from extraction-based optimization. While EqSat routinely finds deep, nonlocal rewrites missed by destructive or sequential approaches, it frequently suffers from intractable state-space explosion, with memory and runtime scaling exponentially as rewrite spaces and ruleset cardinality grow. Practical EqSat, therefore, fundamentally depends not just on the rewrite vocabulary but critically on search strategies: the orchestration of how, when, and in what order rewrites interact, and how e-graph contraction is effected.

Despite the progress in automatic rule synthesis [nandi_rewrite_2021, pal_equality_2023], strategy design remains largely manual and brittle, representing the bottleneck for automation, scalability, and reuse in e-graph compilers. Naive LLM-driven code synthesis is hampered by a lack of reusable abstractions, coarse or unusably large feedback, and unconstrained or myopic search trajectories that rapidly exhaust computational resources.

The paper "LLM-Guided Strategy Synthesis for Scalable Equality Saturation" (2604.17364) systematizes EqSat strategy synthesis via LLM-guided agents and a domain-specific strategic DSL, EqSatL, that exposes strategic structure as a first-class artifact. The EggMind framework stabilizes synthesis through compact feedback (proof-derived motif caching) and domain-aware tractability guidance, enabling automated, amortizable design of high-quality, reusable strategies.

Background: Controlling EqSat with Strategies

EqSat systems, implemented in tools such as egg and egglog, manage search by controlling the construction and simplification of e-graphs. Unlike destructive rewriting, EqSat avoids premature commitment, representing all possible rewrite sequences within equivalence classes. Figure 1

Figure 1: Resource–quality trade-off between full EqSat, strategic EqSat, and destructive rewriting on a typical optimization instance.

(Figure 1) demonstrates that while full EqSat affords maximum optimization capability, it typically exceeds resource budgets. Hand-crafted strategies, by partitioning rewrite sets, sequencing phases, and inserting simplification, trade off between quality and tractable resource consumption. Poor strategies might over-prune profitable paths or fail to control e-graph blow-up.

Manual approaches (e.g., Isaria [thomas_automatic_2024]) require significant expert effort and neither scale nor generalize as rulesets and target domains evolve. Automated strategies via MCTS or guide-based systems exist, but generally lack offline artifact reuse and amortization.

Methodological Innovations: EqSatL and EggMind Overview

The core methodological advances are:

  • EqSatL DSL: A compositional strategic DSL that promotes explicit, inspectable artifacts, delineating ruleset partitioning, schedule construction, and simplification control. Figure 2

    Figure 2: EqSatL syntax and a representative strategy, capturing high-level phased control and repeated local interaction.

EqSatL enables LLMs to reason and operate at a higher semantic level, facilitating cross-case reuse and robust lowering into backend execution scripts. Key elements include semantic tagging of rules, structured phase scheduling (including nested repeats), and explicit simplification directives—enabling both fine-grained phase interaction and aggressive contraction.

  • EggMind Agentic Workflow: A structured, iterative synthesis agent, mixing candidate generation, evaluation under resource constraints, motif caching from EqSat proof objects, and dependency-driven phase partitioning. Figure 3

    Figure 3: EggMind architecture, decoupling offline strategy synthesis via LLMs from online EqSat application across cases.

  • Compact Feedback via Proof Motifs: Instead of entire proof traces or scalar metrics, feedback consists of succinct, tag-abstracted chains (motifs) mined from proof objects of successful EqSat executions, enabling the LLM to adapt strategies based on observed, reusable transformation subgraphs. Figure 4

    Figure 4: Proof-derived motif caching: local subtrees are abstracted into reusable tag chains, then curated for reuse.

  • Tractability Guidance: Agent-support via dependency-based phase assignment heuristics, scoring partitions by enablement or back-flow risk, complemented by LLM-mediated simplification hints at phase granularity, which bias the contraction within the search without losing critical forms.

Empirical Evaluation: Strategy Quality and Resource Efficiency

The system is evaluated over vectorization (Isaria), tensor optimization (XLA), and technology mapping (logic synthesis with EqMap/Enumo-augmented rules), targeting both quality of extracted solutions (cost models) and resource metrics (runtime, memory peak).

Vectorization: On the vectorization suite, strategies synthesized by EggMind demonstrate:

  • 45.1% mean cost reduction and 69.1% mean memory reduction versus full EqSat.
  • 20.6% mean cost reduction and 2.21× runtime speedup over the hand-crafted Isaria baseline. Figure 5

    Figure 5: Vectorization case comparison — EggMind achieves clear benefits in both cost and resource usage.

Ablation reveals that removing motif caching or repeated phase interaction substantially degrades both cost and runtime, supporting the claim that strategic motif memory and structured schedule iteration are necessary for robust and efficient EqSat. Figure 6

Figure 6: Component attribution — cost and runtime ratios worsen with the removal of motif reuse or strategic constructs.

Simplification control (including phase-aware, hint-driven pruning) is especially critical in settings with high-risk or coarse-grained phase composition, and the DSL’s explicit simplify node allows for precise bias and penalty modulation. Figure 7

Figure 7: Trade-off curve for simplification controls; phase-local hints enable aggressive contraction without loss of optimality.

Cross-Domain Generality: The XLA-based tensor compiler testbed, augmented for higher combinatorial complexity, shows measurement-consistent cost and up to 11.89× speedup across 17 tasks versus unguided EqSat. This substantiates the transferability of synthesized strategies.

Logic Synthesis: In an EqMap-based logic synthesis study, EggMind achieves:

  • 33.76% cost reduction over baseline and 51.94% memory peak reduction over unguided search under augmented rule spaces.
  • Stability across instance size, contrasting with the resource collapses observed for brute-force or high-budget unguided EqSat. Figure 8

    Figure 8: Logic synthesis, carry chain comparison — EggMind dominates cost efficiency while keeping runtime within feasible bounds.

Practical and Theoretical Implications

Practically, EggMind enables routine amortization of LLM-based strategic synthesis, generalizing across cases, and making large rule vocabularies tractable in EqSat-based compilers and synthesis flows. As ruleset discovery is automated, EqSat quality will increasingly depend on strategic search, not rule expressivity; EggMind provides an enabling missing automation primitive that can close this bottleneck.

Theoretically, explicit strategic DSLs and compact, reusable feedback may afford new RL or sequence modeling formulations for program search, and motivate compositional, semantically tractable abstractions for LLM-driven code evolution tasks. The motif abstraction, in particular, suggests structural units for future meta-guided search in e-graph spaces.

Future AI research might fuse motif-based feedback with differentiable optimization (as in Smoothe [cai2025smoothe]), integrate symbolic and neural components for local strategy improvement, or extend the agentic workflow to incorporate direct interaction with global objective landscapes or domain-specific theorem provers.

Conclusion

EggMind advances the automation of EqSat strategy synthesis by coupling LLM-guided agentic workflows with a strategic DSL and compact, actionable feedback, resulting in robust, reusable strategies that systematically improve EqSat search quality and tractability. These techniques facilitate scaling EqSat to larger rewrite spaces and more complex domains, contributing to the ongoing automation and theoretical grounding of e-graph-based optimizers, with implications for compiler and synthesis research at large (2604.17364).

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Collections

Sign up for free to add this paper to one or more collections.