Hi,
I am trying to use dask distributed for parallelizing the computations in the framework of pennylane. But the issue i am struggling with is caused due to pickle problem, deserialize and object Arraybox. Following is the code,
import pennylane as qml
import matplotlib.pyplot as plt
from pennylane import numpy as np
import dask
import time
import random
from dask.distributed import Client, progress
client = Client(threads_per_worker=1, n_workers=4)
dev = qml.device('lightning.qubit', wires=1, shots=None)
@qml.qnode(dev, diff_method='adjoint')
def circuit(x):
qml.RX(x, wires=0)
return qml.expval(qml.PauliZ(wires=0))
def expval(x):
temp = []
for i in range(5):
val = dask.delayed(circuit)(x[i])
temp.append(val)
expvals = np.array(dask.compute(*temp))
expvals = np.sum(expvals)
return expvals
%%time
x = np.random.random(5)
expval(x)
qml.grad(expval, argnum=0)(x)
Errors:
-
Could not serialize object of type ArrayBox.
-
Can’t pickle local object ‘VJPNode.initialize_root..’
-
cannot pickle ‘generator’ object
Can someone please help in this regard of distributed dask usage or show some direction for the alternatives.
Thanks a lot!!!