Hi Team,
Is there any way to include Tape in QNode. For example, if I made a set of operations and measurements in a tape and I want to execute that tape parallel way using QNode. I can execute tape in a parallel way using the execute command, but how it can be executed in a qNode? Or, is it possible to do so?
Please let me know your perspectives.
Below is the code:
import pennylane as qml
from pennylane import numpy as np
wires=20
dev=qml.device("default.qubit")
def circuit(params):
tapes=[]
for j in range(5):
ops=[]
for i in range(wires):
ops.append(qml.RY(params[j][i], wires=i))
for i in range(wires):
ops.append(qml.CNOT(wires=[i, (i+1)%wires]))
meas=[qml.expval(qml.PauliZ(wires-1))]
tape=qml.tape.QuantumTape(ops, meas)
tapes.append(tape)
return tapes
params=[np.random.random(wires) for i in range(5)]
qml.execute(circuit(params), dev) #This code gives output properly
q_node=qml.QNode(func=circuit, device=dev)
q_node(params) #Throwing errors
The Error:
ValueError: ops operation RY(tensor(0.63808942, requires_grad=True), wires=[0]) must occur prior to measurements. Please place earlier in the queue.
Also is there any other way to execute tapes in qnn.TorchLayer except making the circuit to qNode?
Thanks