# Backward function takes long and batches

**URL:** <https://discuss.pennylane.ai/t/backward-function-takes-long-and-batches/164>\
**Category:** PennyLane Help\
**Created:** [June 18, 2019, 5:17pm UTC](https://discuss.pennylane.ai/t/backward-function-takes-long-and-batches/164 "2019-06-18T17:17:45Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Tom\_Bromley](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/tom_bromley/32/129_2.png) [@Tom\_Bromley](https://discuss.pennylane.ai/u/Tom_Bromley)\
**Post date:** [January 24, 2023, 5:41pm UTC](https://discuss.pennylane.ai/t/backward-function-takes-long-and-batches/164/9 "2023-01-24T17:41:56Z")

</div>

Hi @erinaldiq!

Sorry for the late response.

> I am using `pennylane-0.28.0` and for a circuit with batched inputs I still get `dev.num_executions==10` if the batch size is 10 when using the `qiskit.ibmq` device. Your example gives `dev.num_executions==1` with the `default.qubit` device, and I can reproduce that.

Thanks, this is good to know. We have taken a closer look at the [plugin](https://github.com/PennyLaneAI/pennylane-qiskit) and it looks like there is a bug. Although executions are being dispatched as a batch to Qiskit backends, the `num_executions` counter is being incorrectly iterated due to being inside a post-processing `for` loop. @Romain_Moyard is looking to fix this shortly.

> Can you explain (some of) the reason(s) why this is not the default behavior?

This is legacy behaviour due to `TorchLayer` not being updated. Currently, `TorchLayer` ensures that one input is passed to a QNode at a time (hence the unstacking of the first dimension). However, PennyLane now supports an outer batch dimension in parameters passed to a QNode, so we just need to update `TorchLayer` by removing the `for` loop.

---

_[View the full topic](https://discuss.pennylane.ai/t/backward-function-takes-long-and-batches/164)._
