Hi @isaacdevlugt , thanks for your support. I slightly modified your example and shown the output below,
import pennylane as qml
from pennylane import numpy as np
dev_lightning = qml.device('lightning.qubit', wires=2)
@qml.qnode(dev_lightning, diff_method="adjoint", max_diff=2)
def circuit_adjoint(a):
qml.RX(a[0], wires=0)
qml.RZ(a[1], wires=1)
qml.CNOT(wires=(0,1))
return qml.expval(qml.PauliZ(wires=0))
x = np.array([0.1, 0.2], requires_grad=True)
qml.jacobian(qml.grad(circuit_adjoint))(x)
array([[0., 0.],
[0., 0.]])
qml.gradients.param_shift_hessian(circuit_adjoint)(x)
tensor([[-9.95004165e-01, -8.32667268e-17],
[-8.32667268e-17, 1.11022302e-16]], requires_grad=True)
Now change the diff_method to ‘best’ and rerun the same lines.
qml.jacobian(qml.grad(circuit_adjoint))(x)
array([[-9.95004165e-01, -8.32667268e-17],
[-8.32667268e-17, -1.11022302e-16]])
Please compare with above output from parameter shift hessian.
By the way, do you have some idea about dask parallelizing. I have posted something there. It would be great if you can share your views.
Thanks