Parallel shots on Qiskit

I am running variational algorithms using QuasmSimulator, which means I am performing a classical optimization where the cost function is computed running a quantum circuit. Moreover, for the optimizer to converge I need high accuracy, which implies a large number of shots.

These two things combined make a run last for days on my laptop, even for a few qubits. Thus, I am trying to run shots in parallel to save some time. Qiskit has a backend option for this:

from qiskit.providers.aer import QasmSimulator

... the rest of the code...

job = execute(circ, backend, shots=nshots)


However, when setting this option I see no difference, neither in runtime nor in CPU usage from Window's task manager. I think the problem could be that normally a python script just uses one core, so when Qiskit runs it "thinks" that indeed you have one core only. Any suggestion?

I am using Qiskit 0.23.0

(Note that I asking specifically about parallel shots and not parallel circuits, although that might also help with another issue I have)

• Not answering your question, this is a comment about simulation for calculating an expectation value. Depending on your circuit (e.g. does it contain intermediate measurements) and what you're looking for (e.g. do you simulate a noisy device), there are cases where you can run a single shot and use the expectation value snapshot, which calculates <psi|O|psi>, where |psi> is the state and O is the obervable. Nov 16 '20 at 9:29
• Also, you may find the variational solvers in Qiskit Aqua useful Nov 16 '20 at 9:33
• You can get short runtime indeed if you just use the state vector simulator, which is exact and performs matrix-vector multiplications etc. Perhaps that's what you mean by "one shot". However, if you are simulating a QC functioning, obviously it's impossible to get a one-shot result. In that case, you would just get a reading that is 1 or 0 which does not hold any info. You need to sample many times until you have a meaningful ration of 1s/0s. Or did I misunderstood you? Nov 16 '20 at 10:13
• Yes, you understood correctly Nov 16 '20 at 12:53
• I am also interested in statistical error introduced by a finite sampling of the expectation value, so, unfortunately, I can't bypass the problem as you suggest. Nov 16 '20 at 13:28

Just for short, I think after qiskit evaluates the state vector, it gives you measurement results based on that state vector, instead of evaluate state vector $$n$$ times and gives you one measurement result each time(I guess, since if you import the time package and observe the time consumed about different shots you won't see a pattern that the consumed time grows with the number of shots).