Hi, I want to utilize the library of multiprocessing to run circuits simultaneously. The toy code is as below:
from multiprocessing import Pool import pennylane as qml from pennylane import numpy as np def cal_grad(param): d_node, weight = param return d_node(weight) dev = qml.device("default.qubit", wires=n_wires) d_node1 = qml.grad(qml.QNode(circuit, dev)) d_node2 = qml.grad(qml.QNode(circuit, dev)) pool = Pool(2) params = np.random.random(n_wires, requires_grad=True) result = pool.map(cal_grad, [(d_node1, params), (d_node2, params)])
However, errors happen as below:
AttributeError: 'tensor' object has no attribute 'requires_grad'
Any suggestions are welcome. Thanks in advance!