-
Notifications
You must be signed in to change notification settings - Fork 634
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
Deprecate QubitUnitary
as a valid input to ControlledQubitUnitary
#6840
Conversation
Hello. You may have forgotten to update the changelog!
|
…n-favour-of-`wires`' into Deprecate-`QubitUnitary`-as-a-valid-input-to-`ControlledQubitUnitary`
This comment was marked as outdated.
This comment was marked as outdated.
@albi3ro @astralcai Here's how I deprecate the |
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.
Don't forget to add entries to the changelog and the deprecations page.
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 just realized something: for every other controlled operator, its base
property is an operator. For example:
>>> op = qml.CRX(0.5, [0, 1])
>>> op.base
RX(0.5, wires=[1])
Should we maintain the same behaviour for ControlledQubitUnitary
? @albi3ro
EDIT:
To be more consistent with how every other custom controlled operation works, the ControlledQubitUnitary
should probably create a QubitUnitary
internally and set its base
to that.
EDIT:
nvm I'm dumb.
Co-authored-by: Astral Cai <[email protected]>
…tary`-as-a-valid-input-to-`ControlledQubitUnitary`' into Deprecate-`QubitUnitary`-as-a-valid-input-to-`ControlledQubitUnitary`
…n-favour-of-`wires`' into Deprecate-`QubitUnitary`-as-a-valid-input-to-`ControlledQubitUnitary`
Co-authored-by: Christina Lee <[email protected]>
…n-favour-of-`wires`' into Deprecate-`QubitUnitary`-as-a-valid-input-to-`ControlledQubitUnitary`
…n-favour-of-`wires`' into Deprecate-`QubitUnitary`-as-a-valid-input-to-`ControlledQubitUnitary`
Co-authored-by: Christina Lee <[email protected]>
51fb48c
into
Deprecate-`control_wires`-in-`ControlledQubitUnitary`-in-favour-of-`wires`
**Context:** Due to the deprecations of `ControlledQubitUnitary` input args PennyLaneAI/pennylane#6839 PennyLaneAI/pennylane#6840, we need to update several tests of lightning that use deprecated interfaces. **Description of the Change:** **Benefits:** **Possible Drawbacks:** **Related GitHub Issues:** [sc-80842] --------- Co-authored-by: ringo-but-quantum <[email protected]> Co-authored-by: Alex Preciado <[email protected]>
**Context:** A recent deprecation #6840 deprecated the usage of `QubitUnitary` type input `base` for instantiation of `ControlledQubitUnitary`. However, a modification that was equivalent in PennyLane caused unexpected behavior in Catalyst, PennyLaneAI/catalyst#1494. After investigation, it appears to be the issue with the private method `_try_wrap_in_custom_ctrl_op` of `pennylane/ops/op_math/controlled.py`, since it used to call the deprecated `init` to directly use base as `QubitUnitary`, and to safely deprecate it we decided to locally replace with equivalent `ControlledQubitUnitary(base=op.matrix(), ...)`, this caused Catalyst to received double `QubitUnitary`. It is also noteable that the call `ControlledQubitUnitary` should not appear in this script, since logically all the classes living in `controlled_ops` depend on `controlled.py`, which means that from the very beginning the affected private method served as a tricky hack with cyclic dependence. Therefore, we would like to replace the `ControlledQubitUnitary` call with a direct `ControlledOp`. **Description of the Change:** source files: as mentioned above. tests: necessary improvements were made to correctly reflect the assertion results. **Benefits:** - Remove bugs - Less cyclic dependency **Possible Drawbacks:** - Probably there're more that depend on this method, which might be affected by this fix **Related GitHub Issues:** PennyLaneAI/catalyst#1494 --------- Co-authored-by: Christina Lee <[email protected]>
Context:
Providing a
QubitUnitary
as the base operator defeats the purpose entirely and is just a messier way of usingqml.ctrl(qml.QubitUnitary(...), ...)
For richer context, check #6839 for better illustration; this PR should in principle be an add-on to it.
Note: this deprecation is related with a previous bug. Trace via attached story link to see full discussions.
Description of the Change:
__init__
and_unflatten
: If get aQubitUnitary
base, raise PLDW and then get matrix bybase.matrix()
.Added an overloading method
_flatten
. This is a fix to #6839.Deleted two tests that restrictively replied on the support of
QubitUnitary
base.Benefits:
Possible Drawbacks:
Related GitHub Issues:
[sc-80843]