I'm trying to profile qiskit backends and I use randomized_benchmarking provided by qiskit.ignis.

Initially I ran a circuit with 20 qubits 100 length on statevector_simulator, which takes around 180s and qubits can go up to 32 and then it runs out of memory. Then I tried qasm_simulator and it only takes 2s to finish and can run up to 54+ qubits.

Why does qasm_simulator perform so much better than statevector_simulator? Does this happen because the circuit only contains simple gates?


1 Answer 1


Well, first off you can check the properties of the statevector simulator and the qasm simulator by doing the following:

from qiskit.providers.aer import StatevectorSimulator, QasmSimulator

From the outputs of these calls, you can see that both simulator backends have the same default number of maximum qubits and maximum number of shots. Also, they both accept circuits with all gates, not just the basis gates.

The reason why using the statevector simulator will take longer and then eventually run out of memory as you increase the number of qubits is because the statevector simulator has to return a block of data the size of 2^N (where N is the number of qubits, and 2^N is the size of the statevector). As the number of qubits increases, the size of the statevector increases exponentially. On the other hand, the qasm simulator returns counts, which is a sampling of the statevector of the circuit, way smaller in size and won't increase in size exponentially as the number of qubits increases. Though they return different things, the qasm and statevector simulator are both part of the same simulator.

You can also customize the qasm simulator to act like the statevector simulator by adding the parameter backend_options to your call to execute() or run() your circuit with the value backend_options = {"method": "statevector"}, and the qasm simulator will return a statevector.

  • $\begingroup$ I get it. I'm also intersted in how many memory it uses during exuction. If they excute same circuit, do they also need different memory? Or It may depedn on what circuit looks like? $\endgroup$
    – izumi
    Commented Oct 5, 2020 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.