Skip to content
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

Merged
merged 3 commits into from
May 6, 2021
Merged

Add test for 6350 #6369

merged 3 commits into from
May 6, 2021

Conversation

enavarro51
Copy link
Contributor

Summary

Details and comments

This PR adds a test to the changes in #6350 which was merged as part of 0.17.2.

@enavarro51 enavarro51 requested a review from a team as a code owner May 6, 2021 17:47

def test_skip_target_basis_equivalences_1(self):
"""Test that BasisTranslator skips gates in the target_basis - #6085"""
from qiskit.test.mock import FakeAthens
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@mtreinish mtreinish left a 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"],
Copy link
Member

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.

@enavarro51
Copy link
Contributor Author

Thanks. I think I got the formatting done. Just getting used to using black.

@mergify mergify bot merged commit 48305a8 into Qiskit:main May 6, 2021
mtreinish added a commit to mtreinish/qiskit-core that referenced this pull request Jun 8, 2021
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.
mergify bot added a commit that referenced this pull request Jun 11, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants