Concept

State-vector simulation

State-vector simulation stores every amplitude of a pure state and updates them when a gate is applied. It is exact for the circuit you wrote, and it is limited by memory that doubles with each added qubit.

What is stored

For n qubits the computational basis has 2^n strings. A pure state assigns a complex amplitude to each string. Double-precision complex storage uses 16 bytes per amplitude, so the resident state is 16 × 2^n bytes before any workspace. Ten qubits is 16 kilobytes. Twenty is 16 megabytes. Thirty is 16 gigabytes. Forty is 16 terabytes. The arithmetic is the planning tool; the machine you have is the constraint.

Global phase does not matter for any measurement, but relative phase between amplitudes does. A simulator that drops phases, or stores only probabilities, cannot apply a later interfering gate correctly. The state vector keeps both magnitude and phase.

memory_bytes ≈ 16 × 2^n     (complex128 amplitudes)

Applying a gate

A one-qubit gate mixes each pair of amplitudes that differ only on the target bit. A two-qubit gate mixes groups of four amplitudes that differ on the two targets. The update is a small dense multiply inside a large stride pattern. Nothing about the physics requires forming a 2^n by 2^n matrix; the gate list already says which pairs interact.

Controlled gates add a mask. Amplitudes whose control bits are off are left untouched. That is why a controlled rotation is not the same cost model as a dense multiply of the whole space, even though both are linear maps on the same vector.

Normalization is an invariant, not a suggestion. If a bug in the update drifts the squared length away from 1, later probabilities are not a distribution. Research checks compare the norm after a batch of gates and also compare a known identity circuit, which must return the input state.

Exact means exact for the circuit

If the gates are the gates you declared, the state vector is the mathematical state of that circuit, up to floating-point roundoff. It is not a prediction of a noisy device. Hardware noise, readout bias, and crosstalk are absent unless you insert them as extra operations. Treating an ideal state vector as a device forecast overstates fidelity.

Roundoff grows with the number of arithmetic operations, which grows with depth and with n. For the circuit sizes in Kryptur methodological notes, double precision is the default because single precision can wash out small interference terms that later gates are supposed to amplify.

When to stop using it

Stop when 2^n no longer fits in the memory you are willing to reserve, or when you only need a low-entanglement observable that a compressed representation can track. State vectors remain the reference for small and medium circuits: they validate a tensor-network code, a sampling routine, and a hand calculation on two or three qubits.

Kryptur papers that quote small-n benchmarks use this exact view as the ground check. Larger combinatorial encodings move to hybrid loops, where the quantum step may be shallow and the classical refinement carries the search. The state vector explains the quantum step; it does not replace the classical one.

Move through the library

Each concept keeps its keyword in the path. These links stay on Kryptur.