egraphs-good / egglog

egraphs + datalog!
https://egraphs-good.github.io/egglog/
MIT License
400 stars 45 forks source link

Add combined rulesets to egglog #362

Closed oflatt closed 4 months ago

oflatt commented 4 months ago

This PR adds combined rulesets to egglog, allowing rulesets to be collected and run together. We plan to use this feature in eggcc, since we declare a ruleset per optimization. We want all our optimizations to run together each iteration.

The PR also cleans up the main loop of egglog, breaking it into functions. Finally, it deletes the backoff scheduler functionality, which nobody uses as far as I can tell.

saulshanabrook commented 4 months ago

Seems to make sense to me to add this kind of feature. I was curious if this could be added as a schedule constructor instead to keep the change smaller?

oflatt commented 4 months ago

Great question. I would have liked to add this as a schedule constructor, but it doesn't compose with other schedule constructors. In other words, it has to be a leaf node of schedules.

What combined rulesets do is:

  1. Run the searchers for all rules in all of the rulesets
  2. Run the appliers for all of these rules

You can't run multiple iterations here as sub-schedules do: you have to phase the searchers and the appliers.

saulshanabrook commented 4 months ago

I would have liked to add this as a schedule constructor, but it doesn't compose with other schedule constructors. In other words, it has to be a leaf node of schedules.

Yeah that makes sense. What if we just extended the run schedule to take multiple ruleset names instead of just one? With the semantics of this combined ruleset if you supply multiple names?

oflatt commented 4 months ago

I also considered that, but it's not very composable. My current implementation allows combined rulesets to be children of other combined rulesets, so you can give names to sets of optimizations.

oflatt commented 4 months ago

Updated with unstable- prefix