-
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 issue/12311 with fractional gate in basis #12511
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 9381719291Details
💛 - Coveralls |
Pull Request Test Coverage Report for Build 9385447583Details
💛 - Coveralls |
@@ -782,15 +782,15 @@ def _replace_parameterized_gate(op): | |||
def is_supercontrolled(gate): | |||
try: | |||
operator = Operator(gate) | |||
except QiskitError: | |||
except (QiskitError, TypeError): # TypeError: parametrized gate |
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.
What is the source of a TypeError
here? Is it coming from __array__
?
I ask because I'm wondering if this is the correct fix, if it's coming from __array__
because the gate is parameterized in the target, I'm wondering if we should instantiate it with a fixed angle instead. Basically update _replace_parameterized_gate
to handle RZZ
too, or instead maybe try to generalize it. A parameterized gate in the target represents that any angle value is valid input so we're free to evaluate the matrix at a fixed angle if we want.
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.
Yes this seems to be the cause. I assigned it as done in _replace_parameterized_gate
for now. I don't love the idea of implicitly making that choice here but at least there's precedence. c45d02d
Pull Request Test Coverage Report for Build 10082610521Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - 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, I just have a small nit in the tests for future proofing (since I just had to deal with related failures caused by it on a different PR). I'll just apply that and enqueue this for merge.
* linting * linting...relax check for 3-qubit circuit * update test docstrings * black update * bind RZZ to pi/2 if Rzz(theta) in basis * Apply suggestions from code review --------- Co-authored-by: Matthew Treinish <[email protected]> (cherry picked from commit aaaf107)
* linting * linting...relax check for 3-qubit circuit * update test docstrings * black update * bind RZZ to pi/2 if Rzz(theta) in basis * Apply suggestions from code review --------- Co-authored-by: Matthew Treinish <[email protected]> (cherry picked from commit aaaf107) Co-authored-by: ewinston <[email protected]>
* linting * linting...relax check for 3-qubit circuit * update test docstrings * black update * bind RZZ to pi/2 if Rzz(theta) in basis * Apply suggestions from code review --------- Co-authored-by: Matthew Treinish <[email protected]>
Summary
This fixes an issue where an exception would be raised if transpiling a unitary gate to a backend with an RZZGate in its basis however transpiling with only
basis_gates
specified would transpile fine.fixes #12311
Details and comments
In this case, where RZZ is the only entangling gate in the basis, decomposition of a 2q unitary gate wouldn't get synthesized in the
UnitarySynthesis
pass but would instead be synthesized in theHighLevelSynthesis
pass because this would call the instruction's_define
method which callstwo_qubit_cnot_decompose
. A subsequentBasisTranslator
pass ultimately maps the cx to the rzz basis. I'm not sure whether this indirect path to unitary synthesis is intentional.This pr resolves the specific example posed in the issue.