Hello, I am running the variational classifier demo using the iris dataset as presented in Variational classifier — PennyLane documentation. I have this working perfectly fine in Pennylane. However, if I run this using local qiskit.aer it runs, but much slower. If I then run the demo on in IBM cloud on the ibmq_qasm_simulator it can run for hours and eventually time out. If I try to run on a quantum device such as ibmq_manila, after the queue is reached and the job starts it agains takes hours. I have not been able to get this run in IBM cloud at all, since the connection is eventually reset.
Why is the performance acceptable when running within Pennylane but horrible in QISKIT. This is running the demo as default as presented on the website and only changing the qml.device… Also worth mentioning that I have tried varying the shots down to 20 with no better luck.
There are a few reasons why you would experience these slowdowns, and they all have to do with how the fundamental computational blocks (circuit execution and gradient evaluation) are implemented on the different devices (shots would not play as significant a role here).
PennyLane will be much faster than Qiskit Aer for computing gradients (though they may be similar for computing the circuit evaluations). In PennyLane, the simulations take place in ML libraries (numpy autograd, tensorflow, torch, jax, depending on how you’ve set things up), and these all know how to very efficiently compute gradients of quantum circuits (needed for optimization of the circuit) using backpropagation. I’d guess that qiskit aer has a slower method for computing gradients (potentially finite-difference method or parameter-shift method), which would explain the slowdown.
As for using IBM cloud (simulator or hardware), you’ve identified the source of the problem. Every single step of the optimization has to get sent over the internet and potentially sit in a queue. This is obviously much slower than the same operation being performed locally.