Adapters for Model explorer to visualize egraph and rvsdg#7
Conversation
|
For some reason when I try to use this, I see that the model-explorer loads 10 adapters (the default 8 + the 2 newly registered adapters), but the new adapters appear as duplicates of the MLIR adapter: I'm currently trying to trace where this is happening. |
|
To clarify, I see the problem when I try to load the visualizer using the Python API. If I load it from the command line, I can specify the |
|
OK, I think I finally figured out the root cause, which I'll brain dump here for posterity. The extension mechanism of Module Explorer ("adapters" are a type of extension) relies on a temporary metaclass side effect in order to discover extension classes. In order to work correctly, the system requires that:
The third condition is what was failing for me when testing this PR. I haven't chased down the sequence that causes the rvsdg and egraph adapter Python modules to be imported early, but that's what is happening. The result is that those adapters fail to be registered properly (in fact, the code erroneously re-registers the last successful adapter 2 more times instead). Now you might wonder why does this happen? The reason is that the Python extension discovery mechanism in Model Explorer is very "unusual":
As might be obvious, this approach has a lot of fundamental problems. The indirection is really confusing, and the mechanism is extremely fragile. It breaks if there are multiple classes in one module or a module is imported early. Some of this needs to be fixed in Model Explorer itself, but I'll see if we can workaround this in this PR somehow. |
|
OK, I believe the reason I tripped over this issue in the first place is that my test notebook imported code from the unit tests, which in turn imported the extension main modules directly. I'm going to merge this as-is, and we can try to upstream some fixes to model explorer. |
Uses https://github.com/google-ai-edge/model-explorer