Matrix product state¶
A matrix product state (MPS) stores a state as a chain of tensors whose size is
set by the bond dimension χ. It is exact while χ holds the entanglement across
every cut of the chain, and it truncates, losing accuracy, past that. Coherent
noise in deltakit-maestro runs on Maestro’s MPS (see Simulation
types), so whether its samples can be trusted is
the question here. Each check below compares MPS samples with a reference that
has no truncation, on the same circuits, decoded with the same detector error
model.
Pauli noise: against Stim¶
Stim is an independent simulator, and exact for Pauli noise, so it checks the MPS sampler end to end: circuit translation, noise, measurement and the conversion to detection events. This is a check of correctness only. For Pauli noise alone, use Stim or Maestro’s stabilizer (see Pauli noise against Stim). With the simulation type pinned to MPS (χ=32), Maestro runs Pauli noise on the MPS, one trajectory a shot:
import maestro
from deltakit_maestro import MaestroBackend
mps = MaestroBackend(simulation_type=maestro.SimulationType.MatrixProductState,
max_bond_dimension=32)
dets, obs = mps.compile_sampler(noisy, seed=2026).sample_detection_events(20_000)
On the rotated d=3 surface code (17 qubits, 3 rounds) under three Deltakit noise models, 20,000 MPS shots against 2,000,000 Stim shots a point:
Noise |
p |
Detection rate, MPS |
Stim |
z |
LEP, MPS |
Stim |
z |
|---|---|---|---|---|---|---|---|
SI1000 |
0.002 |
0.0515 ± 0.0004 |
0.0516 |
−0.2 |
0.0140 ± 0.0008 |
0.0133 |
+0.7 |
SI1000 |
0.005 |
0.1193 ± 0.0006 |
0.1195 |
−0.2 |
0.0687 ± 0.0018 |
0.0712 |
−1.4 |
SI1000 |
0.01 |
0.2110 ± 0.0007 |
0.2112 |
−0.3 |
0.2016 ± 0.0028 |
0.2006 |
+0.3 |
SD6 |
0.002 |
0.0406 ± 0.0004 |
0.0404 |
+0.4 |
0.0110 ± 0.0007 |
0.0104 |
+0.8 |
SD6 |
0.005 |
0.0945 ± 0.0006 |
0.0948 |
−0.5 |
0.0559 ± 0.0016 |
0.0555 |
+0.2 |
SD6 |
0.01 |
0.1703 ± 0.0007 |
0.1706 |
−0.5 |
0.1627 ± 0.0026 |
0.1627 |
−0.0 |
Toy |
0.002 |
0.0176 ± 0.0003 |
0.0176 |
−0.0 |
0.0019 ± 0.0003 |
0.0019 |
+0.1 |
Toy |
0.005 |
0.0432 ± 0.0004 |
0.0429 |
+0.8 |
0.0127 ± 0.0008 |
0.0111 |
+2.1 |
Toy |
0.01 |
0.0820 ± 0.0006 |
0.0819 |
+0.2 |
0.0389 ± 0.0014 |
0.0395 |
−0.5 |
Stim’s standard errors are a tenth of the MPS’s, so they’re left out.
MPS and Stim agree at every point. Across the 9 independent runs, the
detection-rate z-scores have χ² = 1.5 and the LEP z-scores have
χ² = 8.0 (each expected 9 ± 4.2; reporting them separately avoids double-counting
shared-shot correlation between detection rate and LEP), with a largest |z| of
2.1. Detector by detector, the worst of the 216 rates is 3.3σ from Stim’s, about
what 216 comparisons give by chance.
Coherent noise and T1 decay: against exact statevector¶
Coherent over-rotations and T1 amplitude damping aren’t Pauli channels, so
Stim can’t run them. Maestro’s Statevector runs them without truncation, and
draws T1 damping the same way, one branch a shot, so it is the reference here.
Both are pinned, and run the same circuits with the same noise:
sv = MaestroBackend(simulation_type=maestro.SimulationType.Statevector)
mps.compile_sampler(noisy, noise_type='coherent', seed=1)
sv.compile_sampler(noisy, noise_type='coherent', seed=2)
Code |
Qubits |
Noise |
p |
Detection rate, MPS |
Statevector |
z |
LEP, MPS |
Statevector |
z |
|---|---|---|---|---|---|---|---|---|---|
rotated d=3 |
17 |
coherent |
0.002 |
0.0728 ± 0.0007 |
0.0735 ± 0.0007 |
−0.7 |
0.0227 ± 0.0015 |
0.0240 ± 0.0015 |
−0.6 |
rotated d=3 |
17 |
coherent |
0.005 |
0.1627 ± 0.0009 |
0.1613 ± 0.0009 |
+1.0 |
0.1094 ± 0.0031 |
0.1129 ± 0.0032 |
−0.8 |
rotated d=3 |
17 |
coherent |
0.01 |
0.2688 ± 0.0010 |
0.2688 ± 0.0011 |
−0.0 |
0.2716 ± 0.0044 |
0.2675 ± 0.0044 |
+0.7 |
rotated d=3 |
17 |
Pauli + |
0.005 |
0.1409 ± 0.0009 |
0.1390 ± 0.0009 |
+1.5 |
0.1063 ± 0.0031 |
0.1035 ± 0.0030 |
+0.6 |
rotated d=3 |
17 |
Pauli + coherent + |
0.005 |
0.1951 ± 0.0010 |
0.1944 ± 0.0010 |
+0.5 |
0.1735 ± 0.0038 |
0.1775 ± 0.0038 |
−0.7 |
repetition d=5 |
9 |
coherent |
0.01 |
0.1947 ± 0.0010 |
0.1948 ± 0.0010 |
−0.1 |
0.0282 ± 0.0017 |
0.0299 ± 0.0017 |
−0.7 |
repetition d=5 |
9 |
Pauli + coherent + |
0.01 |
0.2101 ± 0.0011 |
0.2103 ± 0.0010 |
−0.1 |
0.0401 ± 0.0020 |
0.0379 ± 0.0019 |
+0.8 |
repetition d=9 |
17 |
coherent |
0.01 |
0.2026 ± 0.0006 |
0.2029 ± 0.0006 |
−0.4 |
0.0089 ± 0.0009 |
0.0100 ± 0.0010 |
−0.8 |
repetition d=9 |
17 |
Pauli + coherent + |
0.01 |
0.2210 ± 0.0006 |
0.2199 ± 0.0006 |
+1.3 |
0.0182 ± 0.0013 |
0.0220 ± 0.0015 |
−1.9 |
repetition d=11 |
21 |
coherent |
0.01 |
0.2045 ± 0.0007 |
0.2043 ± 0.0007 |
+0.2 |
0.0050 ± 0.0011 |
0.0075 ± 0.0014 |
−1.4 |
repetition d=11 |
21 |
Pauli + coherent + |
0.01 |
0.2240 ± 0.0008 |
0.2232 ± 0.0008 |
+0.8 |
0.0155 ± 0.0020 |
0.0125 ± 0.0018 |
+1.1 |
Each circuit is a Deltakit SI1000(p) memory experiment (d rounds on the
repetition codes, 3 on the surface code), with χ=32. “Coherent” is
noise_type='coherent', an over-rotation of strength p in place of the gate
noise; “Pauli + T1” is the circuit’s own noise with t1=0.005; “Pauli +
coherent + T1” is noise_type='full' with t1=0.005. Shots: 10,000 each, and
4,000 on the 21-qubit code.
Coherent noise and T1 decay agree with the exact result on both codes, alone
and together. Across the 11 independent runs, the detection-rate z-scores have
χ² = 6.5 and the LEP z-scores have χ² = 11.2 (each expected 11 ± 4.7),
and the largest |z| is 1.9.
Per-detector firing rates for MPS vs. reference simulator. Left: Pauli runs vs.
Stim. Right: coherent, T1, and combined runs vs. exact statevector.¶
Bond dimension: converging to the exact result¶
Too small a χ truncates the state, and shows up as extra detection events (see
Bond dimension). Against the exact statevector,
on the rotated d=3 code, the detection-event rate at each χ, for coherent noise
alone and with T1 damping and the circuit’s Pauli noise added (5,000 MPS shots
a point, 20,000 statevector):
χ |
Coherent, p=0.01 |
z |
Pauli + coherent + |
z |
|---|---|---|---|---|
4 |
0.3196 ± 0.0015 |
+31.5 |
||
8 |
0.3044 ± 0.0015 |
+22.0 |
||
12 |
0.3026 ± 0.0014 |
+21.1 |
||
16 |
0.2692 ± 0.0015 |
+0.6 |
0.2349 ± 0.0014 |
+25.1 |
24 |
0.2776 ± 0.0015 |
+5.7 |
||
32 |
0.2693 ± 0.0015 |
+0.6 |
0.1968 ± 0.0014 |
+0.3 |
48 |
0.2690 ± 0.0015 |
+0.5 |
0.1942 ± 0.0014 |
−1.4 |
64 |
0.2691 ± 0.0015 |
+0.5 |
0.1949 ± 0.0014 |
−0.9 |
96 |
0.1926 ± 0.0014 |
−2.4 |
||
128 |
0.1982 ± 0.0014 |
+1.1 |
||
statevector |
0.2682 ± 0.0007 |
0.1964 ± 0.0007 |
MPS against bond dimension χ, with the exact statevector value (±2σ) as the band.¶
Coherent noise converges at χ=32, as the noiseless and coherent
checks found without an exact
reference. Below it, truncation adds up to 19% more detection events, and not
steadily: χ=16 happens to agree here while χ=24 is 6σ off. Maestro routes gates
along the chain differently below χ=32, where its routing optimisations are off
by default, so convergence below the default isn’t monotonic. With T1 damping
and the circuit’s Pauli noise added, the run converges at χ=32 as well. Past
convergence, the MPS agrees with the exact result at every χ, the furthest point
2.4σ off (χ=96), so a larger χ costs time but not accuracy. A longer run at
χ=64, 40,000 shots each, gives 0.1951 ± 0.0005 against the statevector’s
0.1945 ± 0.0005 (z = +0.9).
The pre-release build of Maestro 0.3.16 that these checks first ran on
(655dca4) needed χ=48 for the combined noise: at χ=32 it gave 9% more
detection events than the exact statevector, 11σ off. Truncation adds detection
events, as coherence does, so an error like that can pass for a coherent effect.
Check χ again when the noise or the Maestro version changes (see Bond
dimension).
The logical error probability is a blunter test. At χ=8 the coherent LEP, 0.276 ± 0.006, is within 0.9σ of the exact 0.270, while the detection-event rate is 22σ off. A χ check by LEP alone would pass a truncated run; check the detection events.
Beyond a statevector¶
A statevector of n qubits holds 2ⁿ amplitudes, so its cost doubles with every qubit. An MPS costs what the entanglement across its chain costs, and a repetition code is a chain. On repetition codes with coherent noise (SI1000(0.01), d rounds), with each sampler spreading its shots over the machine’s 30 threads, each MPS run is checked twice: against the exact statevector where one fits, and against χ=64, double the default, everywhere:
Code |
Qubits |
MPS, χ=32 |
Statevector |
Statevector memory |
Detection rate, MPS |
z, χ=64 |
z, statevector |
|---|---|---|---|---|---|---|---|
d=3 |
5 |
0.04 ms |
0.03 ms |
512 B |
0.183 ± 0.005 |
−0.3 |
−1.0 |
d=5 |
9 |
0.28 ms |
0.08 ms |
8 KiB |
0.194 ± 0.003 |
−0.7 |
+1.5 |
d=7 |
13 |
1.08 ms |
0.21 ms |
128 KiB |
0.204 ± 0.002 |
+2.3 |
+2.9 |
d=9 |
17 |
2.92 ms |
4.96 ms |
2 MiB |
0.203 ± 0.002 |
+0.8 |
+1.5 |
d=11 |
21 |
6.04 ms |
517 ms |
32 MiB |
0.202 ± 0.001 |
−1.1 |
−0.5 |
d=13 |
25 |
10.8 ms |
12.5 s |
512 MiB |
0.205 ± 0.001 |
−0.2 |
−0.6 |
d=15 |
29 |
17.5 ms |
8 GiB |
0.206 ± 0.001 |
−0.4 |
||
d=21 |
41 |
54.1 ms |
32 TiB |
0.209 ± 0.001 |
+1.6 |
||
d=25 |
49 |
95.1 ms |
8 PiB |
0.209 ± 0.001 |
+1.2 |
||
d=31 |
61 |
190 ms |
0.209 ± 0.001 |
+1.1 |
|||
d=41 |
81 |
468 ms |
0.209 ± 0.001 |
+0.3 |
|||
d=51 |
101 |
913 ms |
0.210 ± 0.001 |
+0.4 |
Statevector memory reports a single state (2ⁿ complex128 amplitudes); a
multi-threaded sampler allocates one copy per active worker thread. Shot counts:
1,200 MPS shots up to d=15, 480 up to d=31, and 120 beyond; statevector
runs used 240 shots at 21 qubits and 30 shots at 25 qubits.
Time per shot over 30 threads, repetition codes with coherent noise.¶
Up to 13 qubits the statevector is faster. Past that its cost climbs steeply, from 5.0 ms a shot at 17 qubits to 517 ms at 21 and 12.5 s at 25, where a shot on the MPS takes 11 ms. The MPS’s cost grows with the circuit instead: a shot of the 101-qubit code, 51 rounds, takes 0.91 s.
The MPS agrees with the statevector at every size both run, and with χ=64 at every size. The largest z-score, +2.9 at d=7, is one high χ=32 sample: χ=64 and the statevector agree with each other there (z = +0.5), and the 10,000-shot runs above find no offset on these codes.
On a 2D layout, small as it is, the statevector wins: on the rotated d=3
surface code (17 qubits) a coherent shot takes 1.9 ms on the statevector and
3.8 ms on the MPS at χ=32. Pass
MaestroBackend(simulation_type=maestro.SimulationType.Statevector) to run it
that way; the decoder’s detector error model is the same.