# Memory Requirements for Qiskit Aer Simulator

I'm trying to work out how much memory is used for simulations of different sizes using the Aer simulator.

Here are my calculations:

$$\text{Number of Qubits} = n$$ $$\text{Number of Amplitudes} = 2^{n}$$ $$\text{Array Size } = {2^n}^2 = 2^{2n}$$ $$\text{ Memory in Bytes needed for double precision complex number } = 16$$ $$\text{ Memory needed (Bytes)} = 16 *2^{2n}$$ (I'm a bit confused at the exact definition of a GB of ram whether it's in powers of ten or two)

From this, simulations of circuits with over 18 qubits are rather difficult.

My questions are these:

1. Are these calculations correct ?
2. Does this stand true for both the shot based 'qasm-simulator' and 'statevector' simulator?
3. AER is well coded: does it have simplifications like those described in the solution to this answer (How much memory is required to simulate a 48-qubit circuit?)?

I realise that my calculations are the worse case scenario. I think the statevector matrix would be upper triangular and so at least half of the amplitudes would be 0, meaning there would be at least some memory gained through sparse matrices ! Thank-You !

2. The difference between the qasm-simulator and statevector-simulator are primarily in return type. The statevector simulator and the qasm simulator (when using the statevector simulation method) work in the same way the only difference is that the statevector simulator returns the statevector instead of computing the measurement counts. However, the qasm simulator offers multiple simulation methods (see: https://qiskit.org/documentation/stubs/qiskit.providers.aer.QasmSimulator.html#qiskit.providers.aer.QasmSimulator for a list) which will have different memory and resource requirements. For example, if your circuit is made up of cliffords you can use the stabilizer simulation method and the memory requirements are much lower.
• Yes it could be, transpile() will be used under the covers when you go to execute a QAOAVarForm circuit. The transpiler is what takes a virtual user circuit and optimizes it and converts it to something that a backend (either a real device or a simulator) can run given the constraints of that backend. So it could be transpile() or it could also be something else in Qiskit. It's hard to know exactly where the most memory is being used without profiling your example. If you want to open an issue on github for this with the example you were running we can work through it together. Mar 15, 2021 at 14:36