-
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
Allow mcrx, mcry and mcrz gate methods to accept angles of ParameterValueType #13507
base: main
Are you sure you want to change the base?
Conversation
One or more of the following people are relevant to this code:
|
The failing tests were added as part of #12752. |
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 looks great, I'm glad that we can support parameterized multicontrolled rotations!
I'm wondering whether we can consolidate the method you added with the existing _mcsu2_real_diagonal
to ensure we don't duplicate the logic. One option could be to take the unitary as Gate
instead of np.ndarray
:
def _mcsu2(gate: Gate, num_controls: int, use_basis_gates: bool) -> QuantumCircuit:
if isinstance(gate, RYGate):
s_gate = # ...
elif # the other Pauli rotation cases, RX and RZ
else:
unitary = gate.to_matrix()
s_gate = # compute s_gate
# common logic here
do you think that might work?
qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py
Outdated
Show resolved
Hide resolved
qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py
Outdated
Show resolved
Hide resolved
You refer to |
These are the failing tests, but all of them are failing (not only for RX / RY / RZ) |
Pull Request Test Coverage Report for Build 12251624511Warning: 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 |
qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py
Outdated
Show resolved
Hide resolved
releasenotes/notes/fix-multi-controlled-rotation-gates-with-parameter-12a04701d0cd095b.yaml
Outdated
Show resolved
Hide resolved
qiskit/synthesis/multi_controlled/multi_control_rotation_gates.py
Outdated
Show resolved
Hide resolved
else: | ||
mode = "noancilla" | ||
|
||
if mode == "basic": |
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 not something to fix in this PR: but do you know why we have this special case only for MCRY
and not for the others? If it's more efficient we could also use it there.
This is something we can fix very cleanly if we synthesize controlled gates via HLS, which knows the number of free auxiliaries.
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.
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.
after checking it seems that adding ancillas can improve mcry in certain cases (num_controls >= 7). This is an optimization that should be explored in a follow-up work.
Summary
Address #12863
There are currently several open issues that fail with errors like:
QiskitError: 'Cannot synthesize MCRY with unbound parameter:
#7975
#11142
#13192
This PR aims to fix them
Details and comments