-
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 UnitarySynthesis
pass bug when target contains global gates
#13651
Conversation
…using target with global gates.
One or more of the following people are relevant to this code:
|
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.
Looks good to me, but just one small code comment
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Pull Request Test Coverage Report for Build 12743897780Details
💛 - 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.
Good catch! Thanks!
releasenotes/notes/fix-unitary-synthesis-global-gates-19b93840b28cfcf7.yaml
Outdated
Show resolved
Hide resolved
|
||
// Filter out non-2q-gate candidates | ||
if op.operation.num_qubits() != 2 { | ||
continue; |
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.
it's the same behavior both for 1-qubit and n-qubits gates (n>2)?
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, the gate matrix needs to be 4x4 in this part of the code, any n!=2 qubit gate causes the dimension mismatch panic
…3651) * Confirm 2q basis gate candidates are in fact 2-qubit gates. Add test using target with global gates. * Add reno * Apply Matt's suggestion Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Add semicolon * Apply Shelly's suggestion --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> (cherry picked from commit d041d5b)
…3651) (#13656) * Confirm 2q basis gate candidates are in fact 2-qubit gates. Add test using target with global gates. * Add reno * Apply Matt's suggestion Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * Add semicolon * Apply Shelly's suggestion --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org> (cherry picked from commit d041d5b) Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
Summary
While working on #12850 I realized that the
UnitarySynthesis
Rust implementation would sometimes append non-2q-gates to the basis set and panic over the dimension mismatch. I had assumed thattarget.operation_names_for_qargs(Some(&qubits))
would only return gates whose number of qubits matchedlen(qubits)
, but this assumption is incorrect. It will return any gate with some overlap with the provided qargs, independently of the number of qubits of the gate. This bug would come up often when the target contained global gates.I believe that the fix is as simple as making sure the 2q basis contains only 2q gates, at least for the cases I found.
Details and comments