CHAPTER 16
Classical simulation and the cost of representation
Learning goals. Estimate exact memory costs, identify efficient special cases, and choose a simulator matched to the circuit and required answer.
16.1 State-vector memory
A generic n-qubit pure state has complex amplitudes. At 16 bytes per complex double, raw storage is
This excludes temporary arrays, circuit metadata, and application overhead. A single-qubit gate updates pairs of amplitudes in O() work. A circuit with G such gates has naive cost O(). A dense general matrix should not be constructed when local gate updates suffice.
| Qubits | Raw state-vector memory |
|---|---|
| 20 | 16 MiB |
| 30 | 16 GiB |
| 40 | 16 TiB |
| 50 | 16 PiB |
Each added qubit doubles memory. A generic density matrix contains complex entries, using bytes. At n=15, that is 16 GiB. Hermiticity reduces independent real parameters but does not remove exponential scaling.
These numbers do not prove that every n-qubit circuit is difficult. They describe a dense representation. A product state needs only n small vectors, and many entangled states have compact alternative representations.
Laboratory L22 — Simulation cost. Change qubit count and numeric precision. Compare state-vector and density-matrix storage on logarithmic scales. No huge arrays are allocated by this calculator.
16.2 Stabilizer simulation
The Clifford gates map Pauli strings to Pauli strings under conjugation. H exchanges X and Z, S maps X to Y, and CNOT has simple propagation rules. A stabilizer state can be stored by n commuting independent Pauli generators rather than amplitudes.
A stabilizer tableau has O(n²) binary entries, and Clifford gates and Pauli measurements admit efficient updates. This is the basis of Gottesman–Knill simulation. It can handle highly entangled states such as GHZ states; entanglement alone is therefore insufficient to imply exponential classical cost [33, 30].
Non-Clifford gates such as T generally break closure of the stabilizer representation. Specialized simulators express a state as combinations of stabilizer states or use related decompositions, with cost depending strongly on non-Clifford resources. A million Clifford operations can be easier to simulate than far fewer appropriately arranged non-Clifford gates.
Stim is an important specialized stabilizer-circuit simulator and detector-error-model tool [32]. Its speed comes from targeting a restricted but useful circuit family. It is not a generic state-vector simulator for arbitrary rotations.
16.3 Tensor networks and entanglement structure
A tensor network factors a large coefficient array into smaller tensors joined by summed indices. For a one-dimensional chain, a matrix product state has amplitudes
The internal matrix dimensions are bond dimensions. A bond dimension χ bounds Schmidt rank across that cut; entanglement entropy is at most . Low-entanglement dynamics can be represented efficiently. Generic strongly entangling dynamics may force χ to grow exponentially [31].
Truncating small Schmidt coefficients gives an approximate method. Its reliability depends on accumulated truncation error and the requested observables. A visually smooth expectation curve does not establish small global state error.
For more general tensor networks, contraction order and graph structure determine cost. A circuit’s depth, geometry, and chosen output can substantially change simulation difficulty. Computing one amplitude, one local expectation, or samples from an approximate distribution are different tasks.
16.4 Trajectories, density matrices, and sampling
A density-matrix simulator exactly averages a specified noise channel but pays storage. A quantum-trajectory method samples Kraus outcomes and evolves pure states, trading memory for Monte Carlo variance. A single trajectory is a conditioned pure state, not the ensemble density operator.
For an observable, average trajectory estimates and include both trajectory randomness and measurement sampling if the workflow has both. Choosing a convenient Kraus decomposition can affect numerical efficiency without changing the channel average.
Sparse state vectors help while only a few basis amplitudes are nonzero, but Hadamard-rich circuits can quickly destroy sparsity. Distributed simulation spreads arrays across machines at the cost of communication. GPU acceleration changes constants and capacity, not the exponential asymptotic storage law.
16.5 A practical simulator selection process
Ask what output is needed. A circuit with Clifford gates and Pauli noise favors a stabilizer tool. A small arbitrary ideal circuit favors a state vector. A small open system favors a density matrix. A larger structured low-entanglement circuit may favor tensor methods. A noisy observable calculation may favor trajectories.
Then check assumptions. Does the tool support mid-circuit measurement, classical conditions, leakage, non-Pauli noise, qudits, and the intended ordering? Does its noise convention match the paper? An unsupported operation should be rejected or explicitly approximated, never silently reinterpreted.
The browser workbench intentionally limits the generic circuit to eight qubits and 40 operations for responsive teaching. Other laboratories use exact specialized formulas for larger small registers. These user-interface limits are not a statement about the maximum classical simulator capacity.
16.6 Why classical baselines keep moving
A quantum benchmark may motivate improved classical contraction, approximation, or sampling methods. A published comparison is dated evidence about a specified task, not a permanent mathematical lower bound. Claimed quantum advantage should report accuracy, hardware time, preprocessing, classical resources, and whether the baseline was later improved.
Worst-case complexity statements and empirical benchmark records are both useful, but they answer different questions. Chapter 24 keeps them separate when describing current experiments.
16.7 Exercises
16.1. How much raw complex-double memory does a 25-qubit state vector use?
Show solution / guidance
bytes = 512 MiB. Working memory can require multiple such arrays.
16.2. What is the ratio of density-matrix to state-vector raw storage for n qubits?
Show solution / guidance
. The density matrix stores relations between every pair of basis states.
16.3. Can a GHZ state have high bipartite entanglement while remaining easy for a stabilizer simulator?
Show solution / guidance
It is entangled but has a compact stabilizer description. Across any nontrivial bipartition its Schmidt rank is two and entropy one bit. It is also an example where multiple compact representations exist.
16.4. A matrix product state uses bond dimension 32. What is its maximum entropy across that bond?
Show solution / guidance
bits. Actual entropy can be smaller.
16.5. Why is one amplitude computed by tensor contraction not the same deliverable as a full state vector?
Show solution / guidance
It gives one complex number. Repeating the calculation for all outputs can be exponentially more expensive and may not reuse all work efficiently.