Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Context:** Currently `qml.matrix` breaks when the input is a catalyst-compiled QNode instead of a plain QNode, and the QNode need to be manually retrieved by the user: PennyLaneAI/catalyst#765 It would be beneficial to do this "unwrap" in `qml.matrix` , like those in qml.draw: https://github.com/PennyLaneAI/pennylane/blob/59a1e0586e707d057a0c92d4239036afa5312b73/pennylane/drawer/draw.py#L213-L214 **Description of the Change:** 1. in `pennylane/ops/functions/matrix.py`, in `qml.matrix(op)`, if the input `op` is a catalyst.qjit compiled function, dispatches the behavior to be `qml.matrix(op.user_function)`. 2. Added a test in `tests/ops/functions/test_matrix.py` **Benefits:** a qjit compiled qnode can be passed into `qml.matrix` directly to query the matrix representation of the circuit **Related GitHub Issues:** PennyLaneAI/catalyst#765 [sc-64247]
- Loading branch information