Statevector simulation

Also known as: state vector simulator

On this page 7

Statevector simulation is the method of running a quantum circuit on a classical computer by storing the complete wavefunction of all qubits as a vector of 2^n complex amplitudes and updating it gate by gate. In quantum software it is the reference technique for exact, noise-free results, and a tool that implements it is often called a state vector simulator.

Because the vector doubles with every added qubit, statevector simulation is precise but exponentially expensive in memory. It sits alongside density matrix, stabilizer and tensor network methods in every major quantum computing SDK, and developers use it daily to debug algorithms, verify compilers and compute ideal expectation values before sending work to real hardware.

How a statevector simulator evolves the quantum state

A statevector simulator represents an n-qubit register as an array of 2^n complex numbers, one amplitude per computational basis state from |00…0⟩ to |11…1⟩. The squared magnitude of each amplitude gives the probability of measuring that bitstring, and the amplitudes always satisfy the normalization condition that these probabilities sum to one.

Applying a gate means multiplying the vector by a unitary matrix. The simulator never builds the full 2^n by 2^n matrix; instead it applies a 2 by 2 kernel for single-qubit gates or a 4 by 4 kernel for two-qubit gates to pairs or quadruples of amplitudes selected by bit masks. Each gate therefore costs time proportional to 2^n operations, and a circuit costs roughly the number of gates times 2^n.

Measurement is handled in one of two ways. The simulator can sample bitstrings from the final probability distribution to imitate hardware shots, or it can return the exact amplitudes and expectation values directly, which no physical device can do. Mid-circuit measurement requires collapsing and renormalizing the vector, so each trajectory with classical feedback must be simulated separately.

The following table summarizes the main data structures and operations inside a typical statevector engine.

OperationWhat the simulator doesCost per step
InitializationSets amplitude of |0…0⟩ to 1, others to 02^n writes
Single-qubit gateUpdates amplitude pairs differing in one bitAbout 2^n multiply-adds
Two-qubit gateUpdates amplitude groups of fourAbout 2^n to 4 x 2^n operations
SamplingDraws bitstrings from squared magnitudes2^n once, then cheap per shot
Expectation valueComputes the inner product with an observableProportional to 2^n per Pauli term
Core operations of a statevector engine

Memory limits and practical qubit counts

The decisive constraint of statevector simulation is memory, not arithmetic. In double precision, each complex amplitude occupies 16 bytes, so the state of n qubits needs 16 x 2^n bytes. Single precision halves this to 8 bytes per amplitude, buying exactly one extra qubit for the same memory at the price of lower numerical accuracy.

The table below shows how quickly the requirement grows and what class of machine can hold each state in double precision.

QubitsMemory requiredTypical platform
2016 MBAny laptop
3016 GBWorkstation or single GPU
34256 GBLarge server or multi-GPU node
4016 TBDistributed cluster
45 to 500.5 to 16 PBLeadership-class supercomputer
Statevector memory in double precision

In practice, about 30 qubits is a comfortable ceiling for desktop work and about 40 to 45 qubits is the limit of distributed runs on large supercomputers. Beyond roughly 50 qubits, the exact statevector no longer fits in any existing machine, which is why demonstrations of quantum advantage deliberately target that regime.

Statevector simulation compared with other simulation methods

Statevector simulation is the most general exact method for pure states, but specialized simulators win whenever a circuit has exploitable structure. Choosing the right backend in a quantum circuit simulator usually decides whether a workload finishes in seconds or not at all.

MethodScaling driverBest forMain limitation
Statevector2^n amplitudesAny circuit up to about 30 to 45 qubitsExponential memory
Density matrix4^n entriesExact noise modelingHalf the qubits of statevector
Stabilizer (Clifford)Polynomial in nError correction circuitsClifford gates only
Tensor networkEntanglement and circuit depthShallow or weakly entangled circuitsCost explodes with entanglement
Matrix product stateBond dimensionOne-dimensional, low-entanglement statesApproximation error
Comparison of classical simulation methods

Noise can still be added to statevector simulation through quantum trajectories, also called Monte Carlo wavefunction sampling. Each run applies randomly chosen error operators, and averaging many trajectories approximates the noisy result at statevector memory cost rather than the quadratically larger density matrix cost.

Using statevector backends in quantum SDKs

Every mainstream SDK ships a statevector backend, and most expose both a sampling interface that mimics hardware and an exact interface that returns amplitudes. Qiskit provides a Statevector class and the high-performance engine in Qiskit Aer, Cirq includes a built-in simulator with optional qsim acceleration, PennyLane offers default.qubit and GPU devices, and CUDA-Q targets GPU and multi-node execution.

Performance depends heavily on implementation. Mature engines use gate fusion, which merges consecutive gates into one larger matrix, along with SIMD vectorization, multithreading and GPU kernels. Distributed simulators split the vector across nodes, so gates on high-order qubits trigger network communication, and qubit reordering strategies minimize that traffic.

The decision table below helps match a task to the appropriate simulation mode.

SituationRecommended choiceReason
Debugging a small algorithmExact statevectorShows every amplitude and phase
Estimating ideal energies in VQEExact expectation valuesRemoves shot noise from optimization
Predicting hardware histogramsSampled statevector with noiseMatches real shot statistics
Surface code with 1,000 qubitsStabilizer simulatorClifford circuits scale polynomially
Deep circuit on 60 qubitsTensor network or hardwareStatevector cannot fit in memory
Choosing a simulation mode

Limitations and common mistakes

Exact results can create false confidence. A statevector run reports ideal behavior, so an algorithm that looks excellent may fail on hardware with realistic gate errors, decoherence and readout noise. Developers should always compare against a noisy simulation or a real device before drawing conclusions.

  • Ignoring global phase: two statevectors that differ by a global phase describe the same physical state, so naive equality checks fail.
  • Confusing bit order: SDKs differ in whether qubit 0 is the least or most significant bit, which silently permutes amplitudes.
  • Overusing exact expectation values: results without shot noise hide the sampling cost that hardware will impose.
  • Underestimating memory: adding just five qubits multiplies the requirement by 32.
  • Assuming large runs are free: distributed simulations above 40 qubits consume substantial supercomputer time.

Explained without jargon

A quantum computer holds many possibilities at once. Statevector simulation lets an ordinary computer imitate this by writing down one number for every possible outcome. With 3 qubits there are 8 outcomes, so the list has 8 numbers. Each step of the program updates the whole list.

The catch is size. Every extra qubit doubles the list. Thirty qubits already need a list of about one billion numbers. Fifty qubits would need more memory than any computer on Earth. So the method is perfect for small programs and impossible for large ones. It is like a flawless map that grows too big to unfold.

A typical use case

A research chemist is developing a variational quantum eigensolver to estimate the ground-state energy of a small molecule encoded in 12 qubits. Before paying for hardware time, she runs the circuit on a GPU statevector backend that holds the full 4,096-amplitude state and returns exact expectation values in milliseconds per iteration.

The exact simulation shows that her ansatz reaches the reference energy within chemical accuracy after about 200 optimizer steps. She then switches to a sampled, noise-aware run with 8,000 shots per measurement and discovers that readout errors shift the energy noticeably. This comparison tells her to add error mitigation before submitting the job to a cloud quantum processor, saving several days of wasted hardware runs.