-
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
Fix circuit drawer returning qubit[register] names for input #11096
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 6761670924Warning: This coverage report may be inaccurate.We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report.
💛 - Coveralls |
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.
The change looks good to me after reading the discussion in #11038. @SoranaAurelia, we would need a release note documenting the fix. Let me know if you need help with that.
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.
We would also benefit from a unit test to help catch any regression in the future (thx @jakelishman for pointing this out to me). We have visual unit tests that check the output of the circuit drawer. You could add a new test to test/visual/mpl/circuit/test_circuit_matplotlib_drawer.py
that draws a circuit reproducing the fixed bug (this one would work) and compares it to a reference png with the correct/expected output (that you would have to save in test/visual/mpl/circuit/references).
Okk thank you a lot for pointing it out! I'll add the changes as soon as possible! |
qc = QuantumCircuit(3) | ||
qc.cx(0, 1) | ||
qc.cx(1, 2) | ||
qc.cx(2, 0) | ||
circuit = transpile(qc, backend, basis_gates=["rz", "sx", "cx"], optimization_level=1) | ||
|
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.
You might want to pin the layout_method
to Sabre here, just to be sure we're always testing it if the pipelines change in the future. We also should seed the transpiler, since there's the possibility of randomness changing the result.
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.
This looks right to me now, thanks both. Assuming it passes the test, it looks correct now.
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.
And thank you very much @SoranaAurelia, I ended up taking care of the reno and test myself because this is a very useful fix and we wanted to make sure it was included in today's release.
Thanks for that! I was a bit busy at uni and work today, so thanks for taking care of it! |
The test also fails locally for me. Does this happen to you as well @ElePT ? |
That's ok, we'll push it from the release today in the interest of timing (even if the fix is completely trivial, it'll take ~2 hours to reach the release branch from now), and squash it in a 0.45.1 patch release soon after. It's not a critical blocking bug, just annoying that we found it during the release candidate period and didn't quite have time to get it fixed before the final release. |
I think changing the image from the reference folder fixed it. The difference that was 0.98.. is now passing the assert. Should I commit it? |
If you're able to hold off til tomorrow, it'd help out a shade with our CI throughput while we're trying to manage the release tonight? No big deal if not, though - we can just postpone its CI run til tomorrow. |
No problem! Tomorrow it is |
Head branch was pushed to by a user without write access
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.
Thanks for your help re-generating the image, I am not sure why my environment generated the wrong pixel size. I'll re-approve :)
* added registers to layout in sabre_layout pass * Add reno and test * Fix layout method in test * Set transpiler seed * modified reference circuit for test --------- Co-authored-by: Elena Peña Tapia <[email protected]> Co-authored-by: Elena Peña Tapia <[email protected]> (cherry picked from commit 179d9ab)
…#11199) * added registers to layout in sabre_layout pass * Add reno and test * Fix layout method in test * Set transpiler seed * modified reference circuit for test --------- Co-authored-by: Elena Peña Tapia <[email protected]> Co-authored-by: Elena Peña Tapia <[email protected]> (cherry picked from commit 179d9ab) Co-authored-by: SoranaAurelia <[email protected]>
…11096) * added registers to layout in sabre_layout pass * Add reno and test * Fix layout method in test * Set transpiler seed * modified reference circuit for test --------- Co-authored-by: Elena Peña Tapia <[email protected]> Co-authored-by: Elena Peña Tapia <[email protected]>
Summary
Circuit drawing included the full Qubit[register] label rather than just nameIndex (ex q0). This fixes #11038
Details and comments
In sabre_layout, qubit registers weren't added to the layout, resulting in the virtual qubit not being found in the registers of the layout. From here, when draw was called, the wire_label was set to qubit[register] rather then only the name and index.