Tensor-Network Simulation
Tensor-network simulation evaluates a quantum circuit by factoring its state or its requested output into smaller arrays. It can save enormous amounts of memory when those arrays remain small. The difficulty depends on the circuit, the qubit ordering, and the output: one amplitude, an expectation value, and the full state can require very different calculations.
This page develops two approaches: evolving a matrix product state (MPS) through the gates, and contracting a network for the chosen output in an order that need not follow circuit time. Exact contraction preserves the circuit’s answer; truncating a bond introduces a state approximation whose physical meaning must be established.
Helpful background. Quantum circuit simulation defines output tasks and qubit indexing. Tensor networks introduces tensor indices and contractions, and singular value decomposition explains the factorization used to compress a bond.
Circuit amplitudes as tensor contractions
Section titled “Circuit amplitudes as tensor contractions”Consider an ideal circuit acting on . Its output amplitude is
Insert computational-basis resolutions of the identity between gates. Each gate becomes an array of matrix elements, and each internal wire carries a summed basis index. For a two-qubit gate,
The lower indices connect to earlier gates and the upper indices to later ones. Fixing every output bit gives a scalar amplitude. Leaving some output indices open gives an array of amplitudes. The network is simply the original matrix multiplication written as smaller sums; its conversion introduces no approximation.
For example, on the first qubit followed by CNOT prepares a Bell state. The intermediate index gives
Only and have nonzero amplitudes, both . This little calculation already illustrates contraction: sum the shared index while preserving the uncontracted output labels.
The output changes the network
Section titled “The output changes the network”The following table assumes a pure input and an ideal unitary circuit.
| Requested output | Construction | Result |
|---|---|---|
| One amplitude | Fix all output bits | Complex scalar |
| Amplitude batch | Leave output bits open | complex values |
| One probability | Square the amplitude magnitude | |
| Marginal | Join ket and bra; sum unwanted outputs | |
| Expectation | Insert between ket and bra | |
| Reduced state | Leave subsystem ket and bra legs open |
A marginal is a sum of probabilities,
not the squared magnitude of a sum of amplitudes. The doubled ket–bra network implements this distinction. Gates outside a measured observable’s backward causal cone can cancel with their adjoints, often making a local expectation much cheaper than the full state.
An explicitly requested dense output still has to be produced: a -qubit reduced density matrix has entries. A compact network representation does not remove that output cost. It can, however, stream entries rather than keep the entire dense output in memory.
Evolving a matrix product state
Section titled “Evolving a matrix product state”An open-boundary MPS writes a coefficient as a product of matrices,
The first and last factors are a row and a column, so the product is a scalar. The bond after site has a stored dimension . The physical Schmidt rank across that cut is at most ; equality requires a minimal representation with zero-weight directions removed. A bound gives dense storage for local dimension .
Vidal’s circuit simulation method exploits this structure. The MPS introduction develops canonical forms and their relation to Schmidt decompositions in more detail.
A two-site gate update
Section titled “A two-site gate update”Bring the MPS into mixed canonical form with its center on the two updated sites. The left and right block states are then orthonormal. Contract the two site tensors with the gate:
Reshape into a matrix with row and column , factor it by SVD, and distribute the factors back to the sites. Keeping all nonzero singular values is exact up to numerical roundoff. Keeping fewer compresses the state. The orthonormal block bases are essential: only then are these singular values the physical Schmidt coefficients and their discarded squared sum a probability weight. An arbitrary gauge can make a numerically small tensor entry physically important.
For comparable bond sizes, the dense SVD costs . This is a useful scaling law only while the required stays modest. A gate crossing a cut with operator Schmidt rank obeys
Here the symbols denote the physical ranks before and after the gate. They are also bounded by the dimensions of the two sides. A two-qubit gate can multiply rank by as much as four when the boundary qubits are already entangled with other qubits; acting on a two-qubit product input can create rank at most two. Repeated layers can require exponentially growing bonds.
The same state, two different qubit orders
Section titled “The same state, two different qubit orders”Prepare three independent Bell pairs, , , and . A cut splitting pairs has equally weighted Schmidt coefficients: each split pair supplies an independent binary label.
Putting each pair next to its partner gives the bond ranks
Putting all qubits before all qubits gives
The physical state did not change. The second ordering simply asks an MPS bond to carry more independent correlations. For pairs the corresponding largest ranks are and .
Curved lines join the partners of each Bell pair; they are not MPS bonds. The dashed central cut splits one pair in the upper ordering and all three in the lower ordering. Its exact Schmidt rank is therefore or .
Nonlocal gates can be applied using swaps, changing the MPS order, or an operator network. Such transformations may increase intermediate bond sizes even if the final state is simple. Choosing an order is therefore part of choosing an efficient representation, not a change to the hardware circuit. The circuit examples studied by Zhou, Stoudenmire, and Waintal illustrate how entanglement growth limits this approach.
What discarded weight does tell you
Section titled “What discarded weight does tell you”For a normalized state with Schmidt coefficients in decreasing order, discarding terms beyond rank removes weight
If , renormalizing the retained state gives squared-overlap fidelity and trace distance from that pre-truncation state. These are one-step statements. Schollwöck explains why canonical MPS forms make such truncations physically meaningful.
There is also a useful conservative cumulative bound. Suppose an initially exact pure state undergoes the same unitary gates as the target, with normalized Schmidt truncations after selected gates. If the actual discarded weights are , then
Unitary evolution preserves trace distance; the triangle inequality adds at most at each truncation. Thus the total-variation distance of any final measurement distributions is at most this bound, and the error of a Hermitian observable is at most . The bound can be loose, but it is a bound; neither the sum nor the product of local infidelities is generally the exact final infidelity. Conditioning on a selected measurement outcome needs a separate analysis because normalization can amplify errors.
Entropy gives a necessary rank constraint, not a complete error estimate. Examine the Schmidt tail at the required tolerance, increase the bond cap, and compare the actual observable or distribution of interest.
Choosing a contraction order
Section titled “Choosing a contraction order”Instead of evolving a state through time, construct the network for the requested output and contract tensors in any convenient order. Associativity preserves the exact result, but intermediate arrays can have very different sizes.
For an ordinary network in which each internal index joins two tensors, let and be their index sets and . Contracting all shared indices produces
With index dimensions , the dense multiply-add count and output size are approximately
A shared label that also occurs on other tensors is a hyperedge: it must remain until every required factor has been included. Summing it too early changes the calculation. Copy tensors can convert such a description to ordinary pairwise edges.
A small example of a large cost difference
Section titled “A small example of a large cost difference”Let , , and have shapes , , and . Computing uses
multiply-add pairs. Computing uses
The intermediate contains 6 entries; contains 800. Both produce the same 80-entry output. Larger networks magnify these differences.
For binary indices, define the memory width of a chosen path by . Its largest intermediate alone needs bytes at bytes per element. Total live memory also includes inputs, workspaces, cached tensors, and concurrent tasks.
Markov and Shi relate circuit contraction to graph treewidth: a circuit with gates and underlying graph treewidth can be simulated in time in their bounded-size gate setting. This is a structural result, not a guarantee that a practical search immediately finds the best contraction. Low depth alone does not guarantee small width on an arbitrary connectivity graph.
Greedy search, graph partitioning, and subtree optimization trade search time against later contraction cost; Gray and Kourtis describe a combined search approach. First simplify exactly where possible: fuse adjacent one-qubit gates, absorb fixed inputs, and cancel adjoint pairs outside causal cones. Diagonal and sparse gates may be much cheaper than the dense estimates above. For repeated outputs, reuse common intermediate tensors. Include the initial search cost when deciding whether that reuse is worthwhile.
Slicing indices without losing interference
Section titled “Slicing indices without losing interference”Fixing a set of internal indices produces smaller contractions :
Complete summation is algebraically exact, and different slices can run independently. Slicing an index reduces an intermediate only if that index would occur in it; arbitrary slices need not reduce the largest tensor. Repeated work can increase total cost, and running many slices concurrently can restore the memory pressure that individual slices avoided.
If is an amplitude, add the complex slice amplitudes before taking its squared magnitude. For the circuit , the amplitude of output 1 has two contributions,
Their sum is zero. Adding would destroy the destructive interference. A sliced index is an algebraic summation variable, not a measurement outcome.
Omitting selected slices is generally an approximation. Randomly sampled, properly weighted slices can instead define an unbiased estimator of the amplitude, with sampling uncertainty. Squaring such an estimator does not give an unbiased probability estimator automatically. Near cancellation, even complete summation may need more precision; absolute error is more informative than relative error near a zero.
Sampling and mid-circuit measurements
Section titled “Sampling and mid-circuit measurements”A normalized MPS supports direct sequential sampling using
Compute the two conditional probabilities, draw the next bit, update the remaining conditional state, and continue. Only positive-probability prefixes are visited, so a zero-probability branch must never be normalized. No Markov-chain equilibration is required. Sampling is exact for the represented MPS distribution, including any state approximation made earlier; this does not make it exact for the original untruncated circuit. Ferris and Vidal develop direct sampling for unitary tensor networks.
General contraction methods can also obtain conditionals from doubled networks, but one tractable amplitude does not guarantee cheap sampling: the required marginals may be harder. Caching shared prefixes or contracting several output legs together can save repeated work.
For a projective mid-circuit measurement, compute , sample , and evolve through the branch selected by that record. Keeping a trajectory avoids explicitly storing every possible branch; it does not make the conditional contractions inexpensive. A discarded measurement result generally produces a mixed state, so it cannot be replaced by one arbitrary pure branch. Noise simulation develops channels, ensembles of trajectories, and density-operator networks.
Choosing and checking a calculation
Section titled “Choosing and checking a calculation”| Task or structure | Useful starting point | Main limitation |
|---|---|---|
| Local gates, modest Schmidt ranks | MPS evolution | Rank growth and ordering |
| A few amplitudes | Fixed-output contraction | Intermediate size |
| Many samples from one compact state | Reuse final MPS | Truncation error |
| A local expectation | Causal-cone contraction | Remaining environment |
| Stabilizer input and Clifford gates | Stabilizer simulation | Restricted operations |
Compare small instances with a state-vector calculation, including asymmetric states that reveal reversed qubit indices. Compare alternate contraction orders and complete sliced sums. For approximate calculations, vary the bond cap and truncation threshold and inspect the requested output itself. Convergence of one expectation need not imply convergence of the full state.
The distinctions are simple but consequential: changing contraction order, exact factorization, and complete slicing change cost without changing the algebra; bond truncation and approximate environments change the answer; floating-point arithmetic adds numerical error to either calculation.
State the circuit, output, numerical precision, and approximation when describing a result. For performance comparisons, separate path-search time from contraction and sampling time and measure memory as well as operation counts. A higher-FLOP path can run faster if its matrix operations use the hardware more efficiently. Failure of one ordering or bond cap establishes the limit of that calculation, not the impossibility of every classical simulation method.
Exercises
Section titled “Exercises”1. Contract a Bell amplitude
Section titled “1. Contract a Bell amplitude”The circuit prepares , applies to qubit 1, and then CNOT with qubit 1 as control. Express the amplitude for output as an index contraction and evaluate it.
Solution
Let be the basis index between and CNOT. Then
CNOT maps to , so the first factor is . Since both and equal ,
The joined index is precisely the contracted wire segment.
2. Estimate a pairwise contraction
Section titled “2. Estimate a pairwise contraction”Tensor has dimensions and tensor has dimensions . Estimate the output size and dense multiply-add count for contracting over .
Solution
The output has
elements. Each output sums over eight values of , so the rough dense work is
multiply-add pairs. This local estimate does not include index permutation, allocation, or the effect on later intermediates.
3. Bound Schmidt-rank growth
Section titled “3. Bound Schmidt-rank growth”An MPS has Schmidt rank across a cut. A two-qubit gate crossing that cut has operator Schmidt rank . What upper bound follows for the exact post-gate rank? Does the rank have to reach the bound?
Solution
The operator-Schmidt expansion writes the gate as a sum of two product operators across the cut. Acting on a state of Schmidt rank 64 therefore gives rank at most
The actual rank may be smaller because terms can be linearly dependent or have zero weight for the particular state. The bound controls worst-case growth; it does not predict the Schmidt spectrum.
4. Interpret discarded weight
Section titled “4. Interpret discarded weight”A normalized two-site update has squared Schmidt coefficients , , , and . If only two values are kept, find the discarded weight and the one-step fidelity after renormalization.
Solution
The discarded weight is
The normalized retained state has one-step fidelity
This does not say that ten such truncations produce final fidelity or . Later gates and truncations act on changed states, so a global claim needs a separate analysis.
5. Sum sliced amplitudes
Section titled “5. Sum sliced amplitudes”For the circuit , slice the intermediate basis index and calculate the amplitude and probability of output 1. What happens if the two slice probabilities are added instead?
Solution
The contributions are
Their sum is zero, so output 1 has probability zero. Adding their squared magnitudes gives , which incorrectly removes interference. That result would describe an unread projective measurement between the Hadamards, not the original unitary circuit.
6. Choose an output strategy
Section titled “6. Choose an output strategy”You need amplitudes that share all output bits except a selected 12-qubit subset. Why might leaving those output legs open be better than running independent scalar contractions?
Solution
One contraction with 12 open binary legs can reuse every intermediate that is independent of those outputs and return a tensor with entries. Scalar repetition may redo that shared work. The open-leg plan is not automatically better: its intermediates may be larger, and the -entry output must still be stored. Compare complete contraction trees and measured resource costs for both plans.
7. Sample a GHZ MPS
Section titled “7. Sample a GHZ MPS”For
what are the left-to-right conditional probabilities?
Solution
The first bit is uniform:
After drawing , every later bit is deterministic:
for . Direct MPS sampling therefore returns only and , each with probability one half, without a Markov chain.
8. Turn local truncations into an error bound
Section titled “8. Turn local truncations into an error bound”An ideal unitary circuit is simulated with two normalized Schmidt truncations, each discarding weight . Bound the final trace distance, the error in any measurement distribution, and the expectation error of a Pauli observable. Is the final infidelity necessarily ?
Solution
Each truncation changes the represented pure state by trace distance . Unitary invariance and the triangle inequality give . Measurement cannot increase trace distance, so total-variation distance is at most . A Pauli operator has norm one, giving expectation error at most . For pure states, . None of these inequalities asserts an exact accumulated error; the discarded directions can combine in different ways.
9. Why the canonical environment matters
Section titled “9. Why the canonical environment matters”Represent a two-qubit state by coefficient matrix , where
What state is represented? If the smaller singular value of is discarded and the physical state is renormalized, what fidelity remains? Compare this with the best physical rank-one approximation.
Solution
represents the normalized state . An SVD of alone keeps its entry, yielding after physical normalization, with fidelity . The misleading relative discarded squared weight in is
The physical Schmidt values are instead and . Keeping the larger one yields with fidelity . The nonorthonormal environment changes the physical metric. Canonicalization absorbs this metric before applying a physical truncation criterion.
10. Count the pairs crossing each cut
Section titled “10. Count the pairs crossing each cut”For the three-Bell-pair state in the figure, derive all five Schmidt ranks in the two orderings. If the central rank in the second ordering is truncated to two, what is the largest possible fidelity?
Solution
The adjacent-pair order splits pairs, giving ranks . The separated-partner order splits pairs, giving . At its central cut all eight squared Schmidt coefficients are . Retaining two preserves weight , the optimal rank-two fidelity at that cut. A small bond cap is highly inaccurate in this order, even though the other order represents the same state exactly with maximum bond two.
References
Section titled “References”- A. J. Ferris and G. Vidal, “Perfect sampling with unitary tensor networks,” Physical Review B 85, 165146 (2012), doi:10.1103/PhysRevB.85.165146.
- J. Gray and S. Kourtis, “Hyper-optimized tensor network contraction,” Quantum 5, 410 (2021), doi:10.22331/q-2021-03-15-410.
- I. L. Markov and Y. Shi, “Simulating quantum computation by contracting tensor networks,” SIAM Journal on Computing 38, 963–981 (2008), doi:10.1137/050644756.
- U. Schollwöck, “The density-matrix renormalization group in the age of matrix product states,” Annals of Physics 326, 96–192 (2011), doi:10.1016/j.aop.2010.09.012.
- G. Vidal, “Efficient classical simulation of slightly entangled quantum computations,” Physical Review Letters 91, 147902 (2003), doi:10.1103/PhysRevLett.91.147902.
- Y. Zhou, E. M. Stoudenmire, and X. Waintal, “What limits the simulation of quantum computers?” Physical Review X 10, 041038 (2020), doi:10.1103/PhysRevX.10.041038.