-
Notifications
You must be signed in to change notification settings - Fork 746
Open
Labels
bug 🐛Something isn't workingSomething isn't working
Description
Originally reported in the forum (https://discuss.pennylane.ai/t/error-when-using-catalyst-grad-with-blockencode/9234), the following code will fail in the latest release:
import pennylane as qml
import catalyst
from jax import numpy as jnp
A = jnp.array([[1, 0], [0, 1]])
dev = qml.device("lightning.qubit", wires=2)
@qml.qnode(dev)
def loss_fn(angle):
qml.BlockEncode(A, wires=[0, 1])
qml.RZ(angle, wires=0)
return qml.expval(qml.Z(0))
angle = jnp.array(0.5)
grad_fn = catalyst.qjit(catalyst.grad(loss_fn))
grads = grad_fn(angle)The numpy.ndarray conversion method __array__() was called on traced array with shape float64[4]
The issue is improper detection of the abstract array case for U with the current Catalyst frontend, located here:
pennylane/pennylane/ops/op_math/decompositions/unitary_decompositions.py
Lines 216 to 219 in dce345c
| # The 2-CNOT decomposition relies on sorting eigenvalues, which is not supported | |
| # with abstract tracers when capture is enabled. In that case, we fall back | |
| # to the 3-CNOT decomposition. | |
| if not capture.enabled(): |
I believe the bug was introduced in PR #8717
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug 🐛Something isn't workingSomething isn't working