- 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: 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 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: 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: 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:
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: 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: 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:
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).