Hi! I’ve been working with qml.ctrl and I get this problem, could anyone help me?
DeviceError: Gate ControlledOperation not supported on device default.qubit.autograd
I share part of my code:
import pennylane as qml
from pennylane import numpy as np
np.random.seed(23)
n = 2
@qml.template
def function1(x,w):
for i in range(n):
qml.CZ(wires = [i, (i+1)%n])
qml.RY(w[i], wires = i)
for i in range(n):
qml.RY(x[i], wires = i)
qml.CZ(wires = [i, (i+1)%n])
qml.RZ(x[i], wires = i)
def circuit(x,y,w):
qml.adjoint(function1(x,w))
function1(y,w)
dev = qml.device("default.qubit", wires = n + 1)
@qml.qnode(dev)
def function2(x,y,w):
ops = qml.ctrl(circuit, control = n)
qml.Hadamard(n)
ops(x = x, y = y, w = w)
qml.Hadamard(n)
return qml.probs(wires = n)
def function3(x,y,w):
probs = function2(x,y,w)
print(probs)
return probs[0] - probs[1]
function3([1]*n,[2]*n,[3]*n)
Thanks in advance!