-
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
Make plot_gate_map generic for any backend #7814
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously the plot_gate_map() family of visualization functions only worked with a fixed hard coded list of number of qubits. The function made the assumption if the backend had a matching number of qubits it was an IBM backend that had the same number of qubits (and fell into a fixed connectivity topology) and would use the manually set graph layout to visualize the function. This was problematic because it didn't actually work for any backend, and if a backend had the same number of qubits as an IBM backend but a different connectivity it would use a potentially nonoptimal layout. This also required us to update the hard coded list whenever a new IBM backend was released to support visualizing them. Additionally the functions only worked with BackendV1 and BaseBackend based backends and would fail if a BackendV2 object were passed to the function. This commit address these issues by making 4 key changes to the function, first it adds a new qubit_coordinates kwarg to all the methods which if specifed can be used to manually specify a graph layout to use for the visualization. The second is that the hardcoded list for layouts are only used if it's an IBM backend (or a fake backend) so that we're using them where appropriate (the 127q layout for ibm_washington is also added). The third change is that if a graph layout isn't provided and it's not an ibm backend with a hardcoded entry, retworkx's spring_layout() function is used to create a layout. In the future we can use a more appropriate planar_layout() function after its available in retworkx (see Qiskit/rustworkx#438 ). Finally the last change is that BackendV2 support is added to the function to make sure we're able to use the visualization function regardless of what type of backend is passed in.
mtreinish
added
the
Changelog: New Feature
Include in the "Added" section of the changelog
label
Mar 24, 2022
Pull Request Test Coverage Report for Build 2068750718
💛 - Coveralls |
This commit updates the logic around when we use the default hard coded graph layouts for ibm backends. Previously there was a bug in the if condition which would cause the hard coded layout to be unconditionally used for an ibm backend, even if the user specified their own layout. This fixes this by only using the hard coded layouts when qubit_coordinates is not set.
Co-authored-by: Kevin Hartman <[email protected]>
Previously the offset detection was looking for values < 0 which was needlessly triggering an offset loop for values >=0 and < 1. We only need to correct for negative values if there are any negative values in the 2d coordinates being used for the graph layout.
kevinhartman
approved these changes
Mar 30, 2022
Closed
mtreinish
added a commit
to mtreinish/qiskit-core
that referenced
this pull request
Apr 4, 2022
In Qiskit#7814 we updated the plot_error_map() error to be more general and also work with BackendV2 instead of assuming it's a BaseBackend or BackendV1 backend. However, as part of that refactor 2 errors were accidently introduced preventing the function from being used. First in the BackendV2 path we were incorrectly handling the backend name to use for the plot title. Secondly, in the BaseBackend/BackendV1 path the readout error array loop was incorrectly constructed resulting in the array being larger than expected causing an error. This commit fixes both conditions so that we can correctly plot the result. Fixes Qiskit#7879
mergify bot
pushed a commit
that referenced
this pull request
Apr 4, 2022
* Fix plot_error_map In #7814 we updated the plot_error_map() error to be more general and also work with BackendV2 instead of assuming it's a BaseBackend or BackendV1 backend. However, as part of that refactor 2 errors were accidently introduced preventing the function from being used. First in the BackendV2 path we were incorrectly handling the backend name to use for the plot title. Secondly, in the BaseBackend/BackendV1 path the readout error array loop was incorrectly constructed resulting in the array being larger than expected causing an error. This commit fixes both conditions so that we can correctly plot the result. Fixes #7879 * Add tests for plot_error_map This commit adds test coverage for plot_error_map. The reason the issues around this function slipped in was a complete lack of test coverage. This adds some basic tests with both the BackendV1 and BackendV2 test paths to ensure we have some coverage for the function. * Add release note
mergify bot
pushed a commit
that referenced
this pull request
Apr 4, 2022
* Fix plot_error_map In #7814 we updated the plot_error_map() error to be more general and also work with BackendV2 instead of assuming it's a BaseBackend or BackendV1 backend. However, as part of that refactor 2 errors were accidently introduced preventing the function from being used. First in the BackendV2 path we were incorrectly handling the backend name to use for the plot title. Secondly, in the BaseBackend/BackendV1 path the readout error array loop was incorrectly constructed resulting in the array being larger than expected causing an error. This commit fixes both conditions so that we can correctly plot the result. Fixes #7879 * Add tests for plot_error_map This commit adds test coverage for plot_error_map. The reason the issues around this function slipped in was a complete lack of test coverage. This adds some basic tests with both the BackendV1 and BackendV2 test paths to ensure we have some coverage for the function. * Add release note (cherry picked from commit d430e4d)
mergify bot
added a commit
that referenced
this pull request
Apr 4, 2022
…7887) * Fix plot_error_map In #7814 we updated the plot_error_map() error to be more general and also work with BackendV2 instead of assuming it's a BaseBackend or BackendV1 backend. However, as part of that refactor 2 errors were accidently introduced preventing the function from being used. First in the BackendV2 path we were incorrectly handling the backend name to use for the plot title. Secondly, in the BaseBackend/BackendV1 path the readout error array loop was incorrectly constructed resulting in the array being larger than expected causing an error. This commit fixes both conditions so that we can correctly plot the result. Fixes #7879 * Add tests for plot_error_map This commit adds test coverage for plot_error_map. The reason the issues around this function slipped in was a complete lack of test coverage. This adds some basic tests with both the BackendV1 and BackendV2 test paths to ensure we have some coverage for the function. * Add release note (cherry picked from commit d430e4d) Co-authored-by: Matthew Treinish <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Previously the plot_gate_map() family of visualization functions only
worked with a fixed hard coded list of number of qubits. The function
made the assumption if the backend had a matching number of qubits it
was an IBM backend that had the same number of qubits (and fell into a
fixed connectivity topology) and would use the manually set graph layout
to visualize the function. This was problematic because it didn't
actually work for any backend, and if a backend had the same number of
qubits as an IBM backend but a different connectivity it would use a potentially
nonoptimal layout. This also required us to update the hard
coded list whenever a new IBM backend was released to support
visualizing them. Additionally the functions only worked with BackendV1
and BaseBackend based backends and would fail if a BackendV2 object were
passed to the function. This commit address these issues by making 4 key
changes to the function, first it adds a new qubit_coordinates kwarg to
all the methods which if specifed can be used to manually specify a
graph layout to use for the visualization. The second is that the
hardcoded list for layouts are only used if it's an IBM backend (or a
fake backend) so that we're using them where appropriate (the 127q
layout for ibm_washington is also added). The third change is that if a
graph layout isn't provided and it's not an ibm backend with a hardcoded
entry, retworkx's spring_layout() function is used to create a layout.
In the future we can use a more appropriate planar_layout() function
after its available in retworkx (see
Qiskit/rustworkx#438 ). Finally the last change
is that BackendV2 support is added to the function to make sure we're
able to use the visualization function regardless of what type of
backend is passed in.
Details and comments