-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Introduces PassManager drawer #2445
Conversation
…n their flow controllers
The fact that this relies on pydot, and thus GraphViz, means the ability for the end user to execute this code is beyond our packaging capacbilities; It requires the user to go and install binaries themselves. Is it not possible to use Matplotlib here? The flow of a pass manager looks like a directed, possibly cyclic, graph. |
pydot and GraphViz are already used by the DAG drawer, so I don't think this should be an issue. I can have a look at doing it using matplot if that would be preferable, but as it is drawing a graph structure I think that GraphViz is a good choice. |
I would argue the dag drawer should go to mpl as well. However, others probably have different opinions. |
Yes matplotlib is preferable since it does not introduce non-python dependencies. However drawing graphs such as the DAG is a not a very easy task. Graphviz uses a non-trivial algorithm for finding good coordinates for the nodes such that the output is visually appealing. |
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.
Nice feature!
I think this is nice. I dont mind it using GraphViz as @ajavadia says this is not a simply algorithm to draw. How does it error if I dont have it installed. |
@jaygambetta it raises an |
great. |
This commit fixes the graphviz check in the pass manager visualization added recently in Qiskit#2445. The check was added to determine if the dot command was in the default PATH by trying to subprocess out and run 'dot -V' however the way in which subprocess was called results in both the dot version string and a blank line being printed if graphviz is actually installed. This happens on import time which we definitely don't want to do (and breaks test discovery in stestr).
This commit fixes the graphviz check in the pass manager visualization added recently in #2445. The check was added to determine if the dot command was in the default PATH by trying to subprocess out and run 'dot -V' however the way in which subprocess was called results in both the dot version string and a blank line being printed if graphviz is actually installed. This happens on import time which we definitely don't want to do (and breaks test discovery in stestr).
* First go at pass manager drawer - draws the passes into boxes based on their flow controllers * Added in comments and coloring the nodes * Added in drawing the arguments * Added in testing * Refactoring * Fixed cyclic import * Made filename non optional * CHANGELOG * Added in checks to see if GraphViz is installed - will skip tests if not * Renames pss to pass_ and moved an import basedon review * Moved import to fix lint
This commit fixes the graphviz check in the pass manager visualization added recently in Qiskit#2445. The check was added to determine if the dot command was in the default PATH by trying to subprocess out and run 'dot -V' however the way in which subprocess was called results in both the dot version string and a blank line being printed if graphviz is actually installed. This happens on import time which we definitely don't want to do (and breaks test discovery in stestr).
Summary
Fixes #2317
This introduces a drawer for the PassManager. It takes the pass manager to be drawn, a filename to write to and optionally a style dictionary.
Details and comments
The drawer creates a box for each flow controller and labels it with the name of the controller. It then adds any passes belonging to this controller into the box. The colour of the box for each pass is decided from the style dict, with the default being different colours for analysis and transformation passes. Any inputs to the pass are then added in circles, with any optional parameters having a dashed edge.
This is an example, taken as a subsection of the graph created when the level1 pass manager is drawn.