# Is there a way to parallelize the same circuit for multiple input data?

**URL:** <https://discuss.pennylane.ai/t/is-there-a-way-to-parallelize-the-same-circuit-for-multiple-input-data/2516>\
**Category:** PennyLane Help\
**Created:** [February 8, 2023, 2:24am UTC](https://discuss.pennylane.ai/t/is-there-a-way-to-parallelize-the-same-circuit-for-multiple-input-data/2516 "2023-02-08T02:24:05Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Abhishek](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/abhishek/32/1530_2.png) [@Abhishek](https://discuss.pennylane.ai/u/Abhishek)\
**Post date:** [March 10, 2023, 11:14am UTC](https://discuss.pennylane.ai/t/is-there-a-way-to-parallelize-the-same-circuit-for-multiple-input-data/2516/7 "2023-03-10T11:14:58Z")

</div>

Hi,

I am struggling with same problem. I tried the following with dask,  
 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/9/94ce7d531f6b4a0e33b80ee222c327c3dcfbdb8a.png)  
 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/0/0b0c18fb9c18f01a2e49c1d28c3a42e94c162a4f.png)

Now, if we are parallelising the expectation values of 5 different inputs for same circuit as below,  
 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/8/86048bdd2cd1a27f54c50db103107d3daa50442a.png)

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/5/507c6c9003e791012d936d06a21ffc494ee428d0.png)

But this is only until computing the expectation values in parallel. But machine learning requires computing the gradients of parameters for optimization. I want to speed up the simulations and got stuck with the gradients computations as follows,  
Gradients : qml.grad(expval)(params)  
ERROR :

- Failed to deserialize

- Cannot pickle ‘generator’ object

Can someone please help in this regard or show some directions on the alternatives.

Thanks a lot!!!

---

_[View the full topic](https://discuss.pennylane.ai/t/is-there-a-way-to-parallelize-the-same-circuit-for-multiple-input-data/2516)._
