-
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
Update plot_gate_map (and related visualization functions) to leverage rustworkx.visualization.graphviz_draw for unknown coupling maps #9031
Comments
For reference, the current from qiskit_ibm_provider import IBMProvider
from qiskit.visualization import plot_gate_map
backend = IBMProvider().get_backend('ibm_washington')
print(backend.num_qubits) # 127
plot_gate_map(backend) from qiskit.visualization import plot_error_map
plot_error_map(backend) |
Hey! Is this still available for UnitaryHack @1ucian0? I'd love to take a shot 💪 |
@husayngokal can collaborate with you, if you'd like? |
Sure! PM me on LinkedIn and we can work on this together: |
@1ucian0 @mtreinish I have a few questions:
|
@mtreinish can you please assign me to this issue? |
I think for the visualization just always using graphviz is probably easiest. I don't think we'll be able to fully remove matplotlib from the function though mostly because it will probably be needed to build a color map and also the graphs for
That comment is out of date, at the time I wrote it my thinking was that
Yeah, the only place this comes into play is the visualization functions in
Using rustworkx's graphviz draw the way you set custom colors is via node or edge attributes via the callback functions. In my example code in the OP these are the For all the values in the output from
The way I've typically done quantitative color maps with |
…10208) * Update gate_map.py Update the gate_map.py to migrate the visualization modules from matplotlib to rustworkx.graphviz * Removed has_rustworkx instances * Added release notes * Update test_gate_map.py Updated tests for the modified gate_map.py file * Formatted gate_map.py * Format test_gate_map.py * Added release notes for the fix of #9031 * Update gate_map.py * Update test_gate_map.py Test file updated so that all tests can be passed. * Update test_gate_map.py * Update gate_map.py for rerunning tests. * Update test_clifford.py * Update gate_map.py to reuse rx.draw_graphiz * Update test_gate_map.py to omit qubit_visualization * Update test_gate_map.py to fix formatting changes * Update gate_map.py * Update gate_map.py * Update gate_map.py * Update test_gate_map.py * Update test_gate_map.py * Update gate_map.py * Update gate_map.py * Update gate_map.py * Update gate_map.py * Update gate_map.py * Update gate_map.py * Update gate_map.py * Update test_gate_map.py * Update test_gate_map.py to add rx import * Update test_gate_map.py * Update test_gate_map.py * Update test_gate_map.py to fix imports * Update test_gate_map.py to add HAS_GRAPHVIZ to all tests * Update test_graph_matplotlib_drawer.py to have HAS_GRAPHVIZ * Update test_graph_matplotlib_drawer.py to add HAS_GRAPHVIZ import to test_font_color function * Update test_graph_matplotlib_drawer.py to add GRAPHVIZ check to the class * Update test_graph_matplotlib_drawer.py to add HAS_GRAPHVIZ to both gate_plot_map and test_gate_plot_map import to test_font_color function * Update test_graph_matplotlib_drawer.py * Update test_graph_matplotlib_drawer.py * Update test_graph_matplotlib_drawer.py * Fixed the `font_color` parameter in `gate_map.py/plot_gate_map()` The font_color parameter can now accept hex values as well. * Modify color_edge function to increase speed * Update gate_map.py to fix formatting * Update gate_map.py to shift seaborn import to `plot_error_map` * Add HAS_SEABORN to test_plot_error_map * Reformat gate_map.py * Fixed node autoscaling in `gate_map.py` graphs * Add return type to `test_from_gate_with_cyclic_definition ` in `test_clifford.py` * Update update-gate_map-visualizations-6ea907a0502fdc1a.yaml * Rename update-gate_map-visualizations-6ea907a0502fdc1a.yaml to update-gate-map-visualizations-6ea907a0502fdc1a.yaml * Update update-gate-map-visualizations-6ea907a0502fdc1a.yaml * Update update-gate-map-visualizations-6ea907a0502fdc1a.yaml * Update pauli_op.py to use np.prod `np.product` is deprecated and is causing test fails. * Update operator.py to use np.prod `np.product` is deprecated and is causing test fails. * Update pauli_sum_op.py to use np.prod `np.product` is deprecated and is causing test fails. * Update random.py to use np.product `np.product` is deprecated and is causing test fails. * Update chi.py to use np.prod `np.product` is deprecated and is causing test fails. * Replace np.product with np.prod `np.product` is deprecated and is causing test fails. * Update ptm.py to use np.prod `np.product` is deprecated and is causing test fails. * Update stinespring.py to use np.prod `np.product` is deprecated and is causing test fails. * Update superop.py to use np.prod `np.product` is deprecated and is causing test fails. * Update transformations.py to use np.prod `np.product` is deprecated and is causing test fails. * Update densitymatrix.py to use np.prod `np.product` is deprecated and is causing test fails. * Update random.py to use np.prod `np.product` is deprecated and is causing test fails. * Update statevector.py to use np.prod `np.product` is deprecated and is causing test fails. * Update local_readout_mitigator.py to use np.prod `np.product` is deprecated and is causing test fails. * Update unitary_synthesis.py to use np.prod `np.product` is deprecated and is causing test fails. * Update test_random.py to use np.prod `np.product` is deprecated and is causing test fails. * Update test_scalar_op.py to use np.prod `np.product` is deprecated and is causing test fails. * Update test_random.py to use np.prod `np.product` is deprecated and is causing test fails. * Update test_clifford.py to remove debugging code * Move matplotlib imports to occur at run time * Apply suggestions from code review * Move matplotlib_close_if_inline to runtime import too * Flatten parallel edges Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Fix 1 qubit backend handling * Fix qubit label and font sizes * new reference images * Adjust font scaling * Update reference images * Remove unrelated reference file update * Improve formatting * Adjust pixel scaling factor * Update reference images with formatting changes --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
What should we add?
Right now the
plot_gate_map()
visualization function (and similar functions likeplot_circuit_layout()
use rustworkx'sspring_layout()
function when there a backend is passed in and there isn't a hardcoded layout available and passes that to a mpl visualization. For moderate numbers of qubits this works reasonably well, but for large numbers of qubits the layout doesn't scale positions appropriately and the output is typically cluttered and not a useful visualization. Graphviz is particularly well suited for doing this type of graph visualization (as it is a specialized tool for doing graph visualization). So instead of trying to rebuild what we get from graphviz we should just call out to graphviz if it's available and leverage the rustwork function for graph visualization using graphivz to generate the visualization. The only potential issue is potentiallyplot_error_map
which has histograms and color bars built using matplotlib and integrating the two different visualization tools might prove difficult.Here is some example code I used to leverage
graphviz_draw()
to build a view likeplot_circuit_layout()
:which in this case output something like
The text was updated successfully, but these errors were encountered: