Skip to content

Simulation Boundaries and Scaling

Why simulating quantum circuits classically hits a memory wall past ~30 qubits, when tensor networks let quantum-emotion bypass that wall, and where even tensor networks slow down.

Tutorial Signposts: - Tensor Network Scaling & Limits: Tutorial 14: Large Circuits and Tensor Networks (GitHub) - Common Mistakes: Tutorial 15: Common Mistakes and Fixes (GitHub)


1. The Exponential State Vector Wall

In classical computers, a quantum state of \(N\) qubits is represented by a complex vector in a \(2^N\)-dimensional Hilbert space:

\[ |\psi\rangle = \sum_{x \in \{0, 1\}^N} \alpha_x |x\rangle, \quad \alpha_x \in \mathbb{C} \]

Memory Scaling (Complex128: 16 bytes per amplitude)

Qubits (\(N\)) Amplitudes (\(2^N\)) Memory Required Hardware Tier
10 \(1,024\) 16 KB Microcontroller / Cache
20 \(1,048,576\) 16 MB Standard Laptop RAM
30 \(1,073,741,824\) 16 GB High-End Workstation RAM
35 \(34,359,738,368\) 549 GB Multi-socket Server RAM
40 \(1,099,511,627,776\) 16 TB Supercomputer Node Cluster
50 \(\approx 1.13 \times 10^{15}\) 16 PB Top 500 Supercomputer Storage
100 \(\approx 1.27 \times 10^{30}\) \(\approx 2.03 \times 10^{19}\) TB Exceeds all digital data on Earth

Simulators that store and update the full state vector (such as standard array-based engines) hit a hard memory wall at \(N \approx 30\) to \(35\) qubits on desktop hardware.


2. Tensor Network Representation

quantum-emotion bypasses full vector allocation by representing quantum circuits as tensor networks.

Instead of an array of \(2^N\) numbers: - Each qubit initialized in \(|0\rangle\) is a rank-1 tensor (length-2 vector). - Each single-qubit gate is a rank-2 tensor (\(2 \times 2\) matrix). - Each two-qubit gate is a rank-4 tensor (\(2 \times 2 \times 2 \times 2\)).

The state is represented as a graph \(G = (V, E)\) where vertices are tensors and edges are shared indices (wires).

The Local Expectation Contraction

When evaluating an observable \(\langle O \rangle = \langle\psi| O |\psi\rangle\): The network sandwiches the circuit between the conjugated bra \(\langle\psi|\) and ket \(|\psi\rangle\).

The contraction cost is governed by the treewidth of the contraction graph. If an intermediate wire \(k\) is not measured and only has unitary operations \(U\), those gates cancel across the bra-ket sandwich because \(U^\dagger U = I\). The contraction engine (cotengra) uses these cancellations to contract intermediate indices without forming large intermediate tensors.


3. Area-Law vs Volume-Law Entanglement

The computational tractability of tensor network simulation depends on the entanglement structure of the quantum state, not merely the qubit count \(N\).

Area-Law Entanglement (Classical Tractable Regime)

Consider a bipartition of a quantum system into regions \(A\) and \(B\). The von Neumann entanglement entropy is defined as:

\[ S(A) = -\text{Tr}(\rho_A \log_2 \rho_A) \]

For ground states of local gapped 1D Hamiltonians and linear quantum circuits (such as GHZ states, cluster states, and low-depth circuits):

\[ S(A) \le \text{const} \times \text{Area}(\partial A) \]

In a 1D chain, the boundary \(\partial A\) is just a point (area is constant). The maximum bond dimension \(D\) required to represent the state accurately satisfies:

\[ D \approx 2^{S(A)} = \mathcal{O}(1) \]

Because \(D\) stays small (\(D \le 4\)) in a 1D chain, quantum-emotion can evaluate local observables past the \(2^N\) RAM limit (e.g., on 40-qubit 1D GHZ or cluster chains), as long as most intermediate unitaries cancel (\(U^\dagger U = I\)) and entanglement doesn't spread across deep 2D/all-to-all layers.

Volume-Law Entanglement (Classical Intractable Regime)

In deep 2D or 3D circuits, or circuits with all-to-all connectivity (such as random circuit sampling, deep Grover search, or unstructured quantum algorithms):

\[ S(A) \propto \text{Volume}(A) = \frac{N}{2} \]

The required bond dimension grows exponentially with system size:

\[ D \sim 2^{N/2} \]

For \(N = 100\), \(D \approx 2^{50} \approx 10^{15}\). Contracting this tensor network requires exponential time and memory on any classical supercomputer.


4. Summary of Simulation Regimes

Scenario State Vector Simulator Tensor Network Simulator (quantum-emotion) Real Quantum Processor
40-qubit 1D GHZ Chain (endpoint observable) Refused / OOM (16 TB) Fast (low cut entanglement + \(U^\dagger U = I\)) Runs in microseconds
40-qubit 1D Cluster State (local observable) Refused / OOM (16 TB) Fast (low treewidth) Runs in microseconds
Local expectation value \(\langle Z_i \rangle\) \(O(2^N)\) time and memory Fast when lightcone/cut stays small \(O(N_{\text{shots}})\) repetitions
Full vector output psi.eval() \(O(2^N)\) memory (infeasible past \(N \approx 30\)) Raises ValueError guard before allocating Cannot directly read state vector
50-qubit Random 2D Circuit Infeasible (16 PB RAM needed) Infeasible (volume-law contraction wall) Executes natively

5. Practical Guidelines

  1. Don't call psi.eval() for \(N > 25\): quantum-emotion blocks oversized dense allocations with a ValueError. Compute expectation values (\(\langle O \rangle = \psi^\dagger O \psi\)), draw .sample() shots, or request a small subsystem with .eval_density_matrix(wires=...) instead.
  2. Keep entanglement local when benchmarking large \(N\): 1D or nearest-neighbor circuits stay fast because only a small number of bonds cross any cut.
  3. Know where classical simulation stops: Deep 2D/3D random circuits on 50+ qubits cannot be contracted quickly on any classical machine.