-
Notifications
You must be signed in to change notification settings - Fork 54
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
Add EGraph Visualizations #147
Conversation
Thanks! Worked for me |
Add the e-class ids to the tooltip in graphviz, to help with debugging output
What's the status on this? Does @mwillsey have time to review? |
@oflatt I saw that you opened your PR that also has its own IR for the graph. I would be happy to commit to merging our two IRs once both PRs are merged, if that's easier as well. In that merge, it might also be good to think about having a format we could expose in Python to allow other forms of extraction easily, like the work @philzook58 was experimenting with. |
Yep, I'm in favor of merging this and fixing it later then. |
After conversation with @oflatt, I really think we can use a common format for both this and the extraction gym. So I'm going to close this PR for now, as I do not intend to merge it in it's current state. Details about the format are coming soon! |
@mwillsey So would you recommend implementing this on top of the new common format and then re-opening? FWIW the Python bindings are already published with this fork and I will continue including this code in my fork and keeping it up to date, because I have been finding the graphviz helpful for education. |
Yes! I think the idea is that you’d use the egraph serialize library as a dependency. Egglog (and egg) will hopefully soon have support for exporting to the in-memory representation of that library, thereby supporting not only serialization but also hopefully visualization. So the Python bindings could use mainline and still have visualization. |
This adds a mapping of e-class id to class type to the format. One use case for this was in the visualizer in egglog (egraphs-good/egglog#147) to display the sort on each e-class.
* Add sorts/types/names to classes This adds a mapping of e-class id to class type to the format. One use case for this was in the visualizer in egglog (egraphs-good/egglog#147) to display the sort on each e-class. * Use local test files (#2) This changes the tests to use the local files instead of those in the extraction gym repo. I made this change so I could test the addition of classes. Feel free to disregard if you like. * Make class_data a separate object --------- Co-authored-by: Max Willsey <[email protected]>
My plan for following up with this work is as follows:
Let me know what you think! |
Yes, that sounds good! I would even go further and say that any "singleton" e-class (an e-class with just a single node, like all primitives) could be inlined directly into the parent for easier visualization. |
For things of type unit, what makes the most sense to me is to group by function name. So basically approach 1, but split up by function name; so all the path tuples in one box, edge tuples in another, and so on. I think we can just elide the actual For other primitives (i64, etc), I'd like to see what the inlining approach looks like for when the primitives are used as inputs to functions. A quick example:
Could become:
in the situation where |
That's a cool idea! It would definitely cut down on the number of nodes... We would still put collection primitives as nodes b/c they can point to e-classes...? For functions that return primitives, we could do |
Sure! We'll have to try it to see |
I have added these examples, along with the existing examples, to the e-graph serialize PR, so that we can see how inlining compares! https://github.com/saulshanabrook/egraph-serialize/tree/viz/tests-viz |
@mwillsey I have updated this PR to use the e-graph serialize graphviz implementation (egraphs-good/egraph-serialize#4 and #171). The changes seem out of date in the GitHub diff, even though I pushed them to the branch. Maybe if you re-open it they will be refreshed? EDIT: I opened a new PR since maybe that's simpler, with the same branch: #186 |
Adds the ability to visualize the state of an
EGraph
using Graphviz (addressing #144).Goals:
Features:
inner_values
method toSort
s--output-dot
and--output-svg
to visualize any programmake graphs
command to create SVG & dots of all examplesPossible next steps/follow-up issues:
lhead
to clip at the cluster edge. Currently we are doing a round-robin to point to nodes in each e-cluster.push
orsimplify
than that graph will not be included in the resulting graphviz.Examples
eqsat-basic
in web viewerIt will also transition between graphs smoothly:
Recording.mov
eqsat-basic
fibonacci
fibonacci-demand
map
rw-analysis
proofs
eqsat-basic in Python
I've also been working on some Python examples, though they're not part of this PR. I wanted to show them here to just give a sense of how that could work eventually:
note that these screenshots were taken at a @recursecenter presentation previously and don't reflect the current graphviz styles
In this notebook we can see how the graph changes before and after running:
In this other notebook we use
d3-graphviz
to animate the transitions between different graphs, doing one run in between each snapshot:Untitled.3.mov
TODO
Graph
to something more descriptive such asEGraphState
orExportedEGraph
Graph
structure private to this crate. This could later be useful for the Python bindings to use with other visualization formats like cytoscape.js.dot
as well as.svg
, instead of always emitting itmake test-graphs
)///
lhead
work with self arrows, seem to need a dummy point outside the cluster, which ends up looking odd, so leaving as is for now)