-
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
Bug fix in ElidePermutations #13186
Bug fix in ElidePermutations #13186
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 10941526894Details
💛 - 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.
This LGTM, it was clearly a mistake like this because we ended up using the elision permutation tracking instead of the actual circuit index. I just had one small inline question about the test assertions, otherwise I think this is good to merge.
expected.cx(4, 3) | ||
|
||
res = self.swap_pass(qc) | ||
self.assertEqual(res, expected) |
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.
Should we add some assertions on the permutation tracking too to make sure it's correct and reverses to the original circuit?
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 is a good idea. I have extended the test in 6791002. Do you think it's a good idea to add more "random circuits" tests, with swaps and permutations?
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.
Adding more tests wouldn't hurt. I think the one you added here provides sufficient coverage to prevent a regression here. But if you wanted to add more that would give us more coverage against potential future issues.
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.
LGTM, thanks for updating the tests. If you want to add more test coverage in the future I think you can do that in a standalone PR. It'll be an easy PR to review/merge if all it does is expand the test coverage.
perm = pass_.property_set["virtual_permutation_layout"].to_permutation(qc.qubits) | ||
res.append(PermutationGate(perm), [0, 1, 2, 3, 4]) | ||
self.assertEqual(Operator(res), Operator(qc)) |
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.
TBH, I'm surprised you didn't just use Operator.from_circuit
here, but adding a permutation gate like this works fine too.
* elide permutations fix * extending the test to check the final permutation (cherry picked from commit adf55e1)
* elide permutations fix * extending the test to check the final permutation (cherry picked from commit adf55e1) Co-authored-by: Alexander Ivrii <[email protected]>
* elide permutations fix * extending the test to check the final permutation (cherry picked from commit adf55e1) Co-authored-by: Alexander Ivrii <[email protected]>
Summary
A bug fix for the
ElidePermutations
pass where the internal qubit mapping was not updated correctly after aPermutationGate
. This fix was already present in #13094, however we have decided to separate it to an independent PR as to allow backport.