-
Notifications
You must be signed in to change notification settings - Fork 44
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
Adjust the usage of ControlledQubitUnitary #1483
Conversation
in the test_decomposition.py file to match the new interface of the ControlledQubitUnitary op.
Do not merge until PL deprecation done |
Remember to add your name to the contributor section in the changelog! |
I think this is good, just opening for CI. Feel free to merge once the corresponding changes in PL go through! |
**Context:** We are in favor of `wires`, just like what we did with `MultiControlledX`. !Note: this involves a big user-interface change. With PL version <=0.40, for ControlledQubitUnitary, we have arg wires to be the target_wires, and the arg control_wires is a positional arg. To be consistent with all the other interfaces, we would like to alter this into wires to be positional and to represent control_wires+target_wires Before: ```python mat = np.eye(2) control_wires = [0] wires = [1] ControlledQubitUnitary(mat, control_wires, wires=wires, control_values=...) ``` After: ```python mat = np.eye(2) wires = [0, 1] ControlledQubitUnitary(mat, wires, control_values=...) ``` where the new `wires` should be the concatenate of old `control_wires` and `wires` **Description of the Change:** Besides the modified test files across the whole codebase involving `ControlledQubitUnitary`, we made the following necessary adjustments beyond the `__init__` method: - classmethod `_unflatten`, `_primitive_bind_call` and method `_controlled` were adjusted accordingly following the new interface - move the `TypeError` regarding empty arg `wires` to the beginning. - add a register for `ControlledQubitUnitary` in `bind_new_parameters.py` following the pattern of `CRX` - modified the direct calls of `ControlledQubitUnitary` inside src files `metric_tensor.py`, `controlled.py` and `matrix_ops.py`. ### **Eco-System** This is an inevitable breaking change, so we need to immediately inform the affected repos that depend on latest PennyLane but only apply corresponding changes after this PR gets merged. - [ ] labs - [ ] Catalyst: [frontend/test/pytest/device/test_decomposition.py](https://github.com/PennyLaneAI/catalyst/blob/286e51910a39c55130de8c1c6a806818a2bcb14b/frontend/test/pytest/device/test_decomposition.py#L52) PennyLaneAI/catalyst#1483 - [ ] Lightning: PR to fix it PennyLaneAI/pennylane-lightning#1047 - - [test_gates.py](https://github.com/PennyLaneAI/pennylane-lightning/blob/290c986e7d087e17dbf3f09c6d2dfc8bd738cc08/tests/test_gates.py#L451) - - [test_gates_and_expval.py](https://github.com/PennyLaneAI/pennylane-lightning/blob/290c986e7d087e17dbf3f09c6d2dfc8bd738cc08/tests/lightning_tensor/test_gates_and_expval.py#L72) - - [test_measurements_class.py](https://github.com/PennyLaneAI/pennylane-lightning/blob/290c986e7d087e17dbf3f09c6d2dfc8bd738cc08/tests/lightning_qubit/test_measurements_class.py#L814) - [ ] QML Demos: [tutorial_classically_boosted_vqe.py](https://github.com/PennyLaneAI/qml/blob/c444cec6201338056304d9d5a293f969a3aeec5e/demonstrations/tutorial_classically_boosted_vqe.py#L451); PR to fix it PennyLaneAI/qml#1310 ### **Plugins** - [x] Pennylane-AQT: No instances of deprecated code found. - [x] Pennylane-Qiskit: No instances of deprecated code found. - [x] Pennylane-IonQ: No instances of deprecated code found. - [x] Pennylane-Qrack: No instances of deprecated code found. - [x] Pennylane-Cirq: No instances of deprecated code found. - [x] Pennylane-Qulacs: No instances of deprecated code found. **Benefits:** Unified interfaces with other controlled ops. **Possible Drawbacks:** This is a hard change to deprecate this arg. Would have to introduce errors for testing matrices. **Related GitHub Issues:** [sc-80842] --------- Co-authored-by: Christina Lee <[email protected]> Co-authored-by: Astral Cai <[email protected]>
Wait for #1490 to merge to resolve the formatting issue |
Need to change PL testing dev from 15 to 19 |
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.
PennyLane 0.41.0.dev19 is now available in TestPyPi
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.
PennyLane 0.41.0.dev20 is now available in TestPyPi
**Context:** PennyLaneAI/pennylane#6839 In the PR above PL deprecated the interface of `ControlledQubitUnitary(base, control_wires, wires=target_wires)` and use the new interface `ControlledQubitUnitary(base, wires)`. Here we need to adjust the corresponding usage in Catalyst. **Description of the Change:** frontend/test/pytest/device/test_decomposition.py ln52 **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-80842] --------- Co-authored-by: Alex Preciado <[email protected]>
Context:
PennyLaneAI/pennylane#6839
In the PR above PL deprecated the interface of
ControlledQubitUnitary(base, control_wires, wires=target_wires)
and use the new interfaceControlledQubitUnitary(base, wires)
.Here we need to adjust the corresponding usage in Catalyst.
Description of the Change:
frontend/test/pytest/device/test_decomposition.py ln52
Benefits:
Possible Drawbacks:
Related GitHub Issues:
[sc-80842]