-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change implementation of BackoffScheduler to match egg. #249
base: ale/3.0
Are you sure you want to change the base?
Conversation
… Removed duplicate statement. Removed comment.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## ale/3.0 #249 +/- ##
===========================================
- Coverage 81.17% 80.26% -0.92%
===========================================
Files 19 18 -1
Lines 1503 1535 +32
===========================================
+ Hits 1220 1232 +12
- Misses 283 303 +20 ☔ View full report in Codecov by Sentry. |
src/EGraphs/saturation.jl
Outdated
inform!(scheduler, rule_idx, i, n_matches) | ||
eclass_matches = rule.ematcher_right!(g, rule_idx, i, rule.stack, ematch_buffer) | ||
n_matches += eclass_matches | ||
inform!(scheduler, rule_idx, i, eclass_matches) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For bidirectional rules, the LHS and RHS may both match the same eclass. In this case inform! would be called twice for the same rule index and the same eclass in the same iteration. None of the implemented schedulers uses this, but it could be unexpected for people implementing their own scheduler.
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
…les in the report correctly.
Explanation for the longer runtimes in the benchmark: before the fix the BackoffScheduler quickly blocked all rules because it was informed with the sum of number of matches over all rules. In the fixed version, the BackoffScheduler blocks rules later (and individually), which leads to larger graph and therefore longer runtime. We should compare the sizes of the egraphs for all implementations in the benchmark. When the scheduler parameters are the same and the rules are the same then the egraphs (using egg and MT) should be the same after saturation. Otherwise comparing the runtimes is not particularly useful. I changed the egg-benchmark and MT benchmark script below to produce egraph sizes. |
Further investigation shows that the implementation of BackoffScheduler in MT differs significantly from the implementation in egg. In egg, the It is easy to add something similar to MT but requires a change to the interface for
|
…ode in class when using type predicates in dynamic rules.
For future reference,
Differences in the number of eclasses produced by egg and MT to be investigated. |
… index for eclass predicates.
… of inform! and cansearch!)
@gkronber thanks for all these contributions! 🫶 I will take a look after work |
This PR is a bit messy, because I became aware of an issue in the ematch compiler and the benchmarking code after starting to work on the issue I observed initially. In the meanwhile I strongly support moving the matching code into the Schedulers (refactoring cansearch, inform). I believe it would be important to fix this and introduce the match limit parameter for the ematchers. I'm happy to split this PR up into several smaller cleaner PRs if this makes it easier for reviewing. |
Ok, it seems that #252 did not really fix issues with the CAS integration tests. More matches are detected because rules are not disabled all together by the backoffscheduler anymore. The additional matches and unifications mean that the issues in the CAS tests pop up again. The CAS test has several rules which seem problematic with divison by zero, I suspect that these are the problem. We might need to add semantic analysis to finally fix them. @0x0f0f0f is there source for the CAS tests and rules that we could compare to? |
For valid performance comparisons, with egg we should produce egraphs that have comparable sizes to the egraphs produced by egg. Currently, this is not the case because MT has a bug when using BackoffScheduler (informed with incorrect number of matches). Additionally, the implementation of BackoffScheduler is different to egg, leading to different egraph sizes (for the same rules, and saturation timeout).
egg allows to limit the number of matches in the ematcher to the threshold calculated from the BackoffScheduler which has additional performance advantages.
Fixes #248.