Backward function takes long and batches

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 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.

1 Like