Open isaacdevlugt opened 1 month ago
I have the same problem with circuits returning qml.probs
.
I have the same problem with circuits returning
qml.probs
.
Hey @sotskopa, thank you for letting us know! FYI, you can bypass the issue by setting a different differentiation method (e.g. diff_method="parameter-shift"
)
Just leaving a note here after some internal discussions about this issue. We won't be fixing this bug at this time and will leave it as a future endeavour.
Re: the error message for state-based MPs + Snapshot
+ adjoint
, it's not an easy fix to have a message that better indicates what's going on (e.g., lightning + adjoint doesn't support state-based measurements with Snapshots
instead of the error message above) because of the order in which things are executed under the hood.
FYI, you can bypass the issue by setting a different differentiation method (e.g.
diff_method="parameter-shift"
)
Note that lightning.qubit
doesn't currently support differentiating the state with any differentiation method, but you can use diff_method="adjoint"
or diff_method="backprop"
with default.qubit
:
import pennylane as qml
from jax import numpy as np
import jax
dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev, diff_method="adjoint")
def f(x):
qml.RX(x, 0)
return qml.state()
x = np.array(0.4, dtype=np.complex64)
jax.jacobian(f, holomorphic=True)(x)
Issue description
Lightning does not support measuring
qml.state
whendiff_method="adjoint"
.Expected behavior: QNodes running on lightning can return
qml.state
whendiff_method="adjoint"
(also for circuits withqml.Snapshot()
)Actual behavior: Raises an error.
Reproduces how often: 100%
System information:
Source code and tracebacks