You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
possibly related to #1483 and PennyLaneAI/pennylane#6839 . When running a different commit of Catalyst with PennyLane==0.40 we only have one single qubit unitary. Regarding the Hadamard, it may be that we have never had support for qml.matrix(gate) inside the qjit context. Having a gate would ensure it is traced even if it is used only for obtaining a matrix.
The text was updated successfully, but these errors were encountered:
erick-xanadu
changed the title
Code Gen Issue
Calls to qml.ctrl(qml.QubitUnitary)) produces two QubitUnitaries
Feb 4, 2025
**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]>
Code:
We produce the following MLIR, notice that we have the Hadamard, and two QubitUnitaries.
possibly related to #1483 and PennyLaneAI/pennylane#6839 . When running a different commit of Catalyst with PennyLane==0.40 we only have one single qubit unitary. Regarding the Hadamard, it may be that we have never had support for qml.matrix(gate) inside the qjit context. Having a gate would ensure it is traced even if it is used only for obtaining a matrix.
The text was updated successfully, but these errors were encountered: