I tried to run a calculation of 37 qubits with a Statevector simulator on Qiskit. The following is a demo code.

from qiskit import QuantumRegister
from qiskit import QuantumCircuit
from qiskit import QuantumCircuit, Aer, execute
from qiskit_aer import AerSimulator, StatevectorSimulator
from qiskit.providers.aer.library import save_statevector
from qiskit import execute, transpile
from qiskit.providers.aer import QasmSimulator

import math
import numpy as np
simulator = Aer.get_backend('aer_simulator')

stateCirc = QuantumCircuit(37)



job = execute(stateCirc, simulator)

result =job.result()

data = result.data()

psi0 = data['v0']

np.vdot(psi0, psi0)

This program took infinite time in my laptop...

Later on, I ran the following code

simulator = Aer.get_backend('aer_simulator')


to find that my laptop can only deal with 30 qubits.

Does anyone know if there is any way to get the 37-qubit state vector? Could you show some demo code for demonstration?

Thank you!

  • 1
    $\begingroup$ Just note that a 37-qubit statevector encoded in single precision is 1Tio of RAM (i.e., 1024Gio). Double this number if you perform your computations in double precision. You would need a pretty beefy laptop to perform this simulation. $\endgroup$ Commented Aug 30, 2023 at 7:38
  • $\begingroup$ Thank you! I would say that is an elephanty laptop... I am now thinking to run the program on a server. However, I am not sure 1) if I need to parallelize the code; 2) if I could run python with the Qiskit package on a server... $\endgroup$
    – Marxmas
    Commented Aug 31, 2023 at 2:09

1 Answer 1


Your machine does not have the memory needed to generate a 37 qubit statevector. n_qubits for aer_simulator is set to MAX_QUBITS_STATEVECTOR which is set by the amount of memory your station has. To get a 37 qubit statevector you'll need to run this program on more powerful system. There are services on the cloud like GCP, AWS or Azure that you can leverage.

  • $\begingroup$ Thank you. Do you know if one can apply the Qiskit package on a server with big RAM, e.g., 4TB, memory? I am not sure if I need to the parallelize my serial Qiskit code in the implementation, though. $\endgroup$
    – Marxmas
    Commented Aug 31, 2023 at 2:17
  • $\begingroup$ 4TB won't get you there. int(log2(4000 * (1024**3) / 16)) is 37. This program will crash your beefy server because other processes will also be sharing memory with your simulator. A ~10TB machine might do. $\endgroup$ Commented Aug 31, 2023 at 2:42
  • $\begingroup$ Thank you for the explanation. I am not clear what does 16 mean here? Double precision or single precision? $\endgroup$
    – Marxmas
    Commented Aug 31, 2023 at 20:23
  • $\begingroup$ It's double precision. $\endgroup$ Commented Aug 31, 2023 at 21:20
  • $\begingroup$ Hey @Marxmas, please accept my answer if it helped you. $\endgroup$ Commented Sep 1, 2023 at 16:17

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.