-
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 wrong relative phase of MCRZ #9836
Conversation
Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com>
Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com>
This reverts commit c1ceaf6.
This reverts commit 7c75611.
This reverts commit 100a690.
This reverts commit b762b39.
This reverts commit fab1c80.
I think this could be discussed in another PR, because these points are also present in the main branch. |
|
@ShellyGarion and @Cryoris thanks for the review. |
I looked at the qpy test failures locally (fwiw all you need is to have gnu parallel installed and run |
# pylint: disable=cyclic-import | ||
from qiskit import transpile | ||
|
||
self = transpile(self, basis_gates=["p", "u", "cx"], optimization_level=0) |
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.
I don't think this is quite correct, sorry if I didn't express it correctly before. With this code, the whole circuit will get transpiled to the specified basis -- but we only want the newly added mcrz to be in that basis 🙂 maybe we can just change mcsu2_real_diagonal
to return the MCRZ subcircuit and then transpile that?
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.
Hi @Cryoris , I removed the transpile call.
I think that we should not transpile the MCRZ circuit here, because of the transpile cost with a higher number of controls.
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.
I agree it's not the most efficient way, but we should ensure that use_basis_gates=True
will still behave as it did before 🙂 If we want to avoid transpiling, would it be possible to express mcsu2
in the P U CX
basis?
I pushed a small change to accomodate the |
Thanks @Cryoris. Your modifications LGTM. |
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 too
* efficient multicontrolled su2 gate decomposition Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> * removed optimization flag Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> * tox -eblack * updated docstrings * Adds `MCSU2Gate` to `__init__` * fixed circular import * defined control and inverse methods * changed MCSU2Gate from Gate to ControlledGate * adjusted some tests for controlled gates * reformatting * Fix regarding the integer `ctrl_state` parameter * Tests to check the CX count upper bound * Gate's `label` in the `control` function * Upd. Qiskit tests to include cases for MCSU2Gate * Upd. Qiskit tests to include cases for MCSU2Gate * Revert "Upd. Qiskit tests to include cases for MCSU2Gate" This reverts commit c1ceaf6. * Revert "Upd. Qiskit tests to include cases for MCSU2Gate" This reverts commit 7c75611. * Revert "Tests to check the CX count upper bound" This reverts commit 100a690. * Update test_controlled_gate.py * Update test_circuit_operations.py * remove mcsu2gate class * remove mcsu2gate class * fix mcry * lint * fix mcrx * add reference * Create `s_gate` directly * Revert "Create `s_gate` directly" This reverts commit b762b39. * review * release notes * review 2 * backwards compat * function signature and number of controls * fix mcrz * Update multi_control_rotation_gates.py * review * Update test_qpy.py * Revert "Update test_qpy.py" This reverts commit fab1c80. * Update test_qpy.py * Update multi_control_rotation_gates.py * Fix `use_basis_gates=True` case * lint --------- Co-authored-by: rafaella-vale <26910380+rafaella-vale@users.noreply.github.com> Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Rafaella Vale <rfv@cin.ufpe.br> Co-authored-by: Julien Gacon <gaconju@gmail.com> (cherry picked from commit 7b677ed) # Conflicts: # qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py
* efficient multicontrolled su2 gate decomposition Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> * removed optimization flag Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> * tox -eblack * updated docstrings * Adds `MCSU2Gate` to `__init__` * fixed circular import * defined control and inverse methods * changed MCSU2Gate from Gate to ControlledGate * adjusted some tests for controlled gates * reformatting * Fix regarding the integer `ctrl_state` parameter * Tests to check the CX count upper bound * Gate's `label` in the `control` function * Upd. Qiskit tests to include cases for MCSU2Gate * Upd. Qiskit tests to include cases for MCSU2Gate * Revert "Upd. Qiskit tests to include cases for MCSU2Gate" This reverts commit c1ceaf6. * Revert "Upd. Qiskit tests to include cases for MCSU2Gate" This reverts commit 7c75611. * Revert "Tests to check the CX count upper bound" This reverts commit 100a690. * Update test_controlled_gate.py * Update test_circuit_operations.py * remove mcsu2gate class * remove mcsu2gate class * fix mcry * lint * fix mcrx * add reference * Create `s_gate` directly * Revert "Create `s_gate` directly" This reverts commit b762b39. * review * release notes * review 2 * backwards compat * function signature and number of controls * fix mcrz * Update multi_control_rotation_gates.py * review * Update test_qpy.py * Revert "Update test_qpy.py" This reverts commit fab1c80. * Update test_qpy.py * Update multi_control_rotation_gates.py * Fix `use_basis_gates=True` case * lint --------- Co-authored-by: rafaella-vale <26910380+rafaella-vale@users.noreply.github.com> Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Rafaella Vale <rfv@cin.ufpe.br> Co-authored-by: Julien Gacon <gaconju@gmail.com> (cherry picked from commit 7b677ed) # Conflicts: # qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py
* Fix wrong relative phase of MCRZ (#9836) * efficient multicontrolled su2 gate decomposition Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> * removed optimization flag Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> * tox -eblack * updated docstrings * Adds `MCSU2Gate` to `__init__` * fixed circular import * defined control and inverse methods * changed MCSU2Gate from Gate to ControlledGate * adjusted some tests for controlled gates * reformatting * Fix regarding the integer `ctrl_state` parameter * Tests to check the CX count upper bound * Gate's `label` in the `control` function * Upd. Qiskit tests to include cases for MCSU2Gate * Upd. Qiskit tests to include cases for MCSU2Gate * Revert "Upd. Qiskit tests to include cases for MCSU2Gate" This reverts commit c1ceaf6. * Revert "Upd. Qiskit tests to include cases for MCSU2Gate" This reverts commit 7c75611. * Revert "Tests to check the CX count upper bound" This reverts commit 100a690. * Update test_controlled_gate.py * Update test_circuit_operations.py * remove mcsu2gate class * remove mcsu2gate class * fix mcry * lint * fix mcrx * add reference * Create `s_gate` directly * Revert "Create `s_gate` directly" This reverts commit b762b39. * review * release notes * review 2 * backwards compat * function signature and number of controls * fix mcrz * Update multi_control_rotation_gates.py * review * Update test_qpy.py * Revert "Update test_qpy.py" This reverts commit fab1c80. * Update test_qpy.py * Update multi_control_rotation_gates.py * Fix `use_basis_gates=True` case * lint --------- Co-authored-by: rafaella-vale <26910380+rafaella-vale@users.noreply.github.com> Co-authored-by: thiagom123 <thiagomdazevedo@hotmail.com> Co-authored-by: IsmaelCesar <leamscesar@gmail.com> Co-authored-by: Israel F. Araujo <israelferrazaraujo@hotmail.com> Co-authored-by: Rafaella Vale <rfv@cin.ufpe.br> Co-authored-by: Julien Gacon <gaconju@gmail.com> (cherry picked from commit 7b677ed) # Conflicts: # qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py * fix conflicts --------- Co-authored-by: Adenilton Silva <7927558+adjs@users.noreply.github.com> Co-authored-by: Julien Gacon <gaconju@gmail.com>
Summary
This PR is on top of PR #9688 and fixes #9202.