-
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
Add test for 6350 #6369
Add test for 6350 #6369
Conversation
|
||
def test_skip_target_basis_equivalences_1(self): | ||
"""Test that BasisTranslator skips gates in the target_basis - #6085""" | ||
from qiskit.test.mock import FakeAthens |
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.
Is there a reason to do this as a runtime import vs just putting it at the top and importing it with the module?
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.
Not really. ;-) Done in 0cb1626.
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 LGTM, I think you're going to need to run black
(tox -eblack
will do this in a venv for you) to update the code formatting. But other than that I think this is good to go. (there was 1 comment inline but it's not a blocker)
circ_transpiled = transpile( | ||
circ, | ||
backend=FakeAthens(), | ||
basis_gates=["id", "rz", "sx", "x", "cx"], |
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 line is a bit redundant because FakeAthens
already has this basis set, but it doesn't hurt anything.
Thanks. I think I got the formatting done. Just getting used to using black. |
This commit updates the basis translator test: test_skip_target_basis_equivalences_1 to be more speific to the case it was designed to test. It was originally added in Qiskit#6369 as a dedicated reproduce test to validate we fixed issue Qiskit#6350 where the basis translator was trying to translate a gate already in the basis set which resulted in a less than ideal (but still valid) output circuit. However, this test was written to just mirror the original issue which was part of a larger workflow and is too broad for a dedicated test case. This is primarily because it was running a full transpile against a backend with the sabre swap routing pass instead of only running the basis translator (which is what we're testing). To fix this issue with the test this commit extracts the qasm from the transpilation into the basis translator when running the full reproduce from the original issue and uses that as the input circuit, then the test is updated to only run basis translation and optimization instead of the full transpilation against a backend. This makes the test more targetted to what it's specifically for and stable against unrelated changes to the sabre swap pass.
This commit updates the basis translator test: test_skip_target_basis_equivalences_1 to be more speific to the case it was designed to test. It was originally added in #6369 as a dedicated reproduce test to validate we fixed issue #6350 where the basis translator was trying to translate a gate already in the basis set which resulted in a less than ideal (but still valid) output circuit. However, this test was written to just mirror the original issue which was part of a larger workflow and is too broad for a dedicated test case. This is primarily because it was running a full transpile against a backend with the sabre swap routing pass instead of only running the basis translator (which is what we're testing). To fix this issue with the test this commit extracts the qasm from the transpilation into the basis translator when running the full reproduce from the original issue and uses that as the input circuit, then the test is updated to only run basis translation and optimization instead of the full transpilation against a backend. This makes the test more targetted to what it's specifically for and stable against unrelated changes to the sabre swap pass. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
Details and comments
This PR adds a test to the changes in #6350 which was merged as part of 0.17.2.