SOPHIA XT
Quantum computing lab · computed on this page

Quantum computing, simulated live

A five-qubit state-vector simulator you can wire up by hand, Grover's search checked against its closed form, teleportation as six explicit state vectors, a surface code you can break and let the decoder fix, a threshold Monte Carlo, a variational eigensolver on the hydrogen molecule, and a circuit rewrite pass that proves it changed nothing. Every number on the page is computed here, in the browser, when you load it.

Engine
Complex amplitudes in Float64Arrays, gates applied by index stride, up to 32 amplitudes; a base-3 twin on the ternary page
Checks
Bell 1/2 : 1/2, GHZ, Grover 25/32 on three qubits, teleportation fidelity 1, rewrite fidelity 1, all run on load
Principal researcher
Thomas Garren, SOPHIA XT Research
1 · State-vector simulation

The state is a vector; a gate is a stride

A register of n qubits is a unit vector in \mathbb{C}^{2^n}. Wire k owns bit n-1-k of the basis index, so a single-qubit unitary acts on every pair of amplitudes whose indices differ in that bit, and a controlled gate touches only the pairs whose control bits are set. That is the whole simulator: two Float64Arrays and a loop.

|\psi\rangle = \sum_{i=0}^{2^n-1} a_i\,|i\rangle, \qquad \sum_i |a_i|^2 = 1

Gate on wire k with stride s = 2^{\,n-1-k}, for every i with bit k clear:

\begin{pmatrix} a_i' \\ a_{i+s}' \end{pmatrix} = \begin{pmatrix} u_{00} & u_{01} \\ u_{10} & u_{11} \end{pmatrix} \begin{pmatrix} a_i \\ a_{i+s} \end{pmatrix}

The palette is H, X, Y, Z, S, T, the rotations R_x(\theta), R_y(\theta), R_z(\theta), \mathrm{CNOT}, \mathrm{CZ}, \mathrm{SWAP}, the three-wire \mathrm{CCX} and \mathrm{CCZ}, and a projective measurement:

H = \tfrac{1}{\sqrt 2}\begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix}, \quad R_z(\theta) = \begin{pmatrix} e^{-i\theta/2} & 0 \\ 0 & e^{i\theta/2} \end{pmatrix}, \quad \mathrm{CNOT} = \begin{pmatrix} 1&0&0&0\\0&1&0&0\\0&0&0&1\\0&0&1&0 \end{pmatrix}

Each wire's Bloch vector comes from its reduced density matrix, \rho_k = \mathrm{Tr}_{\bar k}\,|\psi\rangle\langle\psi|, with (x, y, z) = (2\,\mathrm{Re}\,\rho_{01},\, -2\,\mathrm{Im}\,\rho_{01},\, \rho_{00}-\rho_{11}). Its length is 1 for a product state and shrinks as the wire entangles; the Bell pair leaves both wires at the centre of the sphere.

Reading the figure

Load the Bell preset: two nonzero amplitudes, both real and positive, both Bloch vectors at zero length, a histogram that splits between 00 and 11 within sampling noise of a half. Load GHZ on three wires and the same happens with 000 and 111. Load the three-qubit Grover preset and the marked state carries 25/32 of the probability after one iteration, which is the closed-form value the self-check table compares against.

Rotations show the phase colour doing its work: an R_z on a wire in superposition moves the hue of half the bars without moving their height, and a measurement gate collapses the wire on one sampled trajectory; resample to see another one.

The engine and its tests are the same code that runs the Grover, teleportation, transpilation and VQE figures below, so a defect in it would show in all of them at once.

State-vector simulator · up to 5 qubits
Build a circuit, read the state
Qubits Presets
Gate
q0 |0⟩q1 |0⟩Hcolumn 0, q0column 0, q1column 1, q0column 1, q1column 2, q0column 2, q1column 3, q0column 3, q1column 4, q0column 4, q1column 5, q0column 5, q1column 6, q0column 6, q1column 7, q0column 7, q1column 8, q0column 8, q1column 9, q0column 9, q1
Amplitudes (2 nonzero)
basisReIm|a|²arg
|00⟩0.70710.00000.50000°
|11⟩0.70710.00000.50000°
Shots
qubits
2
gates
2
depth
2
two-qubit+
1
min purity Tr ρ²
0.500
Σ|a|²
1.000000
Self-checks, run on load
Bell |00⟩, |11⟩0.5000, 0.5000pass
GHZ |000⟩, |111⟩0.5000, 0.5000pass
Grover 3q, k = 1, P(|101⟩)0.78125pass
Oracle + diffusion vs sin²(3θ)0.78125pass
Teleportation, Bob vs |ψ⟩ (12 trajectories)1.000000pass
Pick a gate, click a wire. Two- and three-wire gates take one click per wire in the same column, control first, target last; clicking a placed gate with no gate selected removes it. The state is recomputed from |0…0⟩ after every edit: bars are |a_i|² coloured by arg(a_i), the spheres are the Bloch vectors of each wire's reduced density matrix (a vector shorter than the sphere means that wire is entangled with the rest), and the histogram is 1024 shots sampled from the final state, with the exact probabilities as white ticks. Measurement gates collapse the wire on one sampled trajectory; the histogram then re-runs the whole circuit per shot.
2 · Grover's search

Quadratic speed-up, checked against sin²((2k+1)θ)

With one marked item among N = 2^n, the uniform superposition makes an angle \theta = \arcsin(1/\sqrt N) with the unmarked subspace, and each oracle-plus-diffusion step rotates the state by 2\theta toward the marked one:

P_k = \sin^2\big((2k+1)\theta\big), \qquad k_{\mathrm{opt}} = \Big\lfloor \frac{\pi}{4\theta} \Big\rceil \approx \frac{\pi}{4}\sqrt N

The figure runs the actual operators on the state vector and plots what it measures over that formula. The agreement is at the level of floating-point rounding, and the curve keeps going past k_{\mathrm{opt}} to show why stopping matters.

Grover's search · amplitude amplification
Oracle and diffusion, iteration by iteration
sin²((2k+1)θ) simulator at each k current k k_opt
n
N = 2ⁿ
8
θ = asin(1/√N)
0.3614rad
P(k), simulator
0.781250
sin²((2k+1)θ)
0.781250
max |Δ| over k
1.6e-15
P(k_opt)
0.945313
Each iteration applies the oracle, a phase flip on the marked index, then the diffusion operator 2|s⟩⟨s| − I, an inversion about the mean amplitude. The amplitudes stay real, so the bars show their sign: the marked bar grows while the rest shrink and eventually go negative. The lower panel plots the simulator's success probability at every k as dots over the closed form sin²((2k+1)θ), and the readout reports the largest difference, which is rounding error. Past k_opt ≈ π√N/4 the probability comes back down, which is why the algorithm has to stop.
3 · Teleportation

One qubit moved with two classical bits

The protocol rests on an identity: a message qubit next to a Bell pair can be rewritten in Alice's Bell basis, with Bob's qubit carrying the message up to a Pauli that the Bell label names.

|\psi\rangle \otimes |\Phi^+\rangle = \tfrac12 \sum_{m_0 m_1} |\beta_{m_0 m_1}\rangle \otimes X^{m_1} Z^{m_0} |\psi\rangle

Alice's CNOT and Hadamard turn the Bell basis into the computational basis, her measurement picks a branch with probability exactly 1/4, and Bob undoes the Pauli when the two bits arrive. The figure carries the eight complex amplitudes through every step and evaluates Bob's fidelity in each branch.

Teleportation · three qubits, two classical bits
The state vector at every step of the protocol
Step 5: Bob applies X^{m₁} then Z^{m₀} on q2
q0 |ψ⟩q1 |0⟩q2 |0⟩HHm₀m₁ = 00X^{m₁}Z^{m₀}|ψ⟩
Amplitudes (2 nonzero)
basisReIm|a|²arg
|000⟩0.8144-0.25190.7268-17°
|001⟩0.49930.15450.273217°
Classical-correction branches
m₀m₁PBob beforefixF beforeF after
000.250(0.74, 0.50, 0.45)I1.0001.000000
010.250(0.74, -0.50, -0.45)X0.5411.000000
100.250(-0.74, -0.50, 0.45)Z0.2061.000000
110.250(-0.74, 0.50, -0.45)XZ0.2531.000000
branch m₀m₁
P(branch)
0.250000
fidelity vs |ψ⟩
1.000000
|ψ⟩ Bloch
0.74, 0.50, 0.45
Bob Bloch
0.74, 0.50, 0.45
Steps 1 to 3 entangle the message with the Bell pair and rotate Alice's two wires into the Bell basis. At step 4 Alice's measurement lands on one of four branches, each with probability exactly 1/4, and Bob's wire is left in X^{m₁}Z^{m₀}|ψ⟩: the branch table shows his Bloch vector before correction, which is |ψ⟩ reflected, and the fidelity after the correction, which is 1 in every branch. No information about |ψ⟩ crosses the channel until the two classical bits arrive: before step 5, averaging Bob's state over the four branches gives the maximally mixed state.
4 · Error correction

The surface code and its threshold

A stabilizer code stores one logical qubit in the joint +1 eigenspace of a set of commuting Pauli products. On the rotated surface code those products are the faces of a square lattice,

S_X = \prod_{q \in \square} X_q, \qquad S_Z = \prod_{q \in \square} Z_q, \qquad Z_L = \prod_{\text{row}} Z_q, \quad X_L = \prod_{\text{col}} X_q

Measuring the stabilizers does not disturb the logical state, but an error on a data qubit flips the faces it touches, and a decoder has to guess the most likely error consistent with the pattern of flipped faces. Minimum-weight matching is the standard choice: pair the flipped faces (or pair a face with the boundary) along the shortest paths. Below threshold, longer codes fail less often; the logical error rate of a distance-d code scales roughly as (p/p_{\mathrm{th}})^{(d+1)/2} (Fowler, Mariantoni, Martinis and Cleland, Phys. Rev. A 86, 032324, 2012). The Monte Carlo panel measures that crossing for d = 3 and 5 under the simplest noise model, independent X and Z flips with perfect syndrome measurement; on hardware, Google Quantum AI reported a suppression factor \Lambda = 2.14 \pm 0.02 per distance step from d = 3 to 7 on the Willow processor (Nature 638, 920, 2025).

Surface code · stabilizers, syndrome, matching decoder
Inject errors, measure, decode
Z stabilizer X stabilizer ancilla data qubit X error Z error correction
Monte Carlo progress
0%
trials per point
2000
P_L(p=0.04), d=3
—
P_L(p=0.04), d=5
—
d=3 / d=5 crossing
pending
trials run
0
distance inject
data / ancilla
9 / 8
errors placed
0
defects
—
matching weight
—
residual weight
—
outcome
not measured
The rotated surface code with distance d has d² data qubits, the circles, and d² − 1 stabilizers, each measured by the ancilla qubit drawn as a square at the centre of its face: Z-type on the cyan faces, X-type on the amber ones, weight-2 half-faces on the boundaries. An X error flips every Z stabilizer it touches, so a single error lights two neighbouring faces (one, at a boundary); a Z error does the same to the X faces. The decoder pairs lit faces by minimum-weight matching on the face graph, allowing a pairing with the boundary, and applies the corrections along the paths (mint rings). The residual after correction is either nothing, a closed loop (a stabilizer, harmless), or a chain crossing the lattice, which is a logical error. Any single error is always corrected at d = 3; two errors on one row or column can already fool it. The plot below is the same decoder run a few thousand times per point under independent X and Z errors with probability p each, with 95% Wilson intervals; the d = 5 curve drops below d = 3 at small p and crosses it near the threshold of this noise model, around p ≈ 0.1.
5 · Variational algorithms

A variational eigensolver on H₂

A variational algorithm prepares a parametrised state on the quantum device, measures the energy, and lets a classical optimiser move the parameters. The energy is a sum of Pauli expectation values, each of which a device measures directly:

E(\theta) = \langle \psi(\theta) | H | \psi(\theta) \rangle = \sum_j c_j\, \langle \psi(\theta) | P_j | \psi(\theta) \rangle, \qquad \frac{\partial E}{\partial \theta_k} = \frac{E(\theta + \tfrac{\pi}{2} e_k) - E(\theta - \tfrac{\pi}{2} e_k)}{2}

The second identity is the parameter-shift rule, exact when each parameter enters through a single rotation gate; it turns a gradient into two extra energy evaluations per parameter with no finite-difference error. The figure runs that loop on the two-qubit hydrogen Hamiltonian, one gradient step per animation frame, and draws the exact ground energy from diagonalising the same Hamiltonian as the target.

Variational eigensolver · H₂ on two qubits
Parameter-shift gradient descent against the exact ground energy
H₂, STO-3G, R = 0.735 Å, terms at the current θ
P_jc_j (Ha)⟨P_j⟩c_j⟨P_j⟩
II-1.05237321.0000-1.052373
ZI0.39793740.68960.274415
IZ-0.39793740.6948-0.276500
ZZ-0.01128010.9941-0.011213
XX0.1809312-0.7190-0.130085
E(θ) = Σ c_j⟨P_j⟩-1.195756
spectrum of H: -1.857, -1.245, -0.883, -0.225 Ha
nuclear repulsion 1/R: 0.719969 Ha
iteration
0
E(θ)
-1.195756Ha
E − E₀
661.519mHa
|∇E|
1.30e-1
E₀ + 1/R
-1.137306Ha
θ
0.80 -3.12 0.17 3.02
The Hamiltonian is H₂ in the STO-3G basis at R = 0.735 Å after the parity mapping and the two-qubit reduction of Bravyi, Gambetta, Kitaev and Taube (arXiv:1701.08213), H = c₀ I + c₁ ZI + c₂ IZ + c₃ ZZ + c₄ XX, with the coefficients tabulated for that mapping in the Qiskit Nature H₂ example. Its lowest eigenvalue, from Jacobi diagonalisation of the 4×4 matrix on this page, is the dashed line; the electronic energy plus the 1/R nuclear repulsion is the STO-3G total of −1.1373 Ha. The ansatz is RY(θ₀)RY(θ₁), CNOT, RY(θ₂)RY(θ₃); each gradient component is [E(θ+π/2) − E(θ−π/2)]/2, exact for a single RY, so eight energy evaluations per step. The mint band is chemical accuracy, 1.6 mHa. The descent runs from a random start each time you restart; every start on this landscape reaches the band.
6 · Transpilation

Fewer gates, same unitary

A transpiler rewrites a circuit into one a device can run: fewer gates, shorter depth, a native gate set, a connectivity the chip has. The rules here are the exact ones, the ones that leave the unitary untouched, and the figure verifies that by running both circuits and comparing the outputs. Build something redundant in the simulator above and send it through; the QFT preset is the counter-example that these three rules cannot shorten.

Transpilation · exact rewrite pass
Gate count and depth before and after
Before
q0 |0⟩q1 |0⟩q2 |0⟩HHTTRZRZSXRYRYHH
After
q0 |0⟩q1 |0⟩q2 |0⟩ZXRY
gates
19 → 4
depth
12 → 2
two-qubit+
7 → 1
F on |0…0⟩
1.000000000
F on random input
1.000000000
Pass log
inverse cancellation8 removed
rotation merge2 removed, 3 merged
CNOT ladder to SWAP2 removed, 1 merged
Three rewrites, each of which leaves the unitary exactly unchanged: an adjacent pair of the same self-inverse gate on the same wires cancels; adjacent rotations about the same axis merge (T·T → S, S·S → Z, RZ(a)·RZ(b) → RZ(a+b), and a merged angle of 0 mod 2π disappears); and CNOT(a,b)·CNOT(b,a)·CNOT(a,b) becomes SWAP(a,b). Adjacency is checked on the wires, so a gate on another wire in between does not block a cancellation while a gate on a shared wire does. Depth is as-soon-as-possible scheduling. The two fidelities compare the outputs of the original and rewritten circuits on |0…0⟩ and on a fixed pseudo-random product state; both are 1 to rounding. The QFT preset is already irreducible under these three rules, which is the point of showing it.
7 · Post-quantum cryptography

The three NIST standards, by the numbers

Shor's algorithm factors integers and takes discrete logarithms in polynomial time on a fault-tolerant machine, which is why RSA and elliptic-curve key exchange have replacements standardised before such a machine exists. NIST published the first three on 13 August 2024: FIPS 203, ML-KEM, a key-encapsulation mechanism derived from CRYSTALS-Kyber; FIPS 204, ML-DSA, a signature scheme derived from CRYSTALS-Dilithium; and FIPS 205, SLH-DSA, the stateless hash-based signature derived from SPHINCS+. The first two rest on the hardness of Module-LWE over structured lattices, the third only on the security of its hash function, which is why its signatures are large and its keys tiny. In March 2025 NIST selected HQC, a code-based scheme, as a second KEM. The parameter sets below are transcribed from the three standards; the security category is NIST's scale where 1, 3 and 5 track AES-128, AES-192 and AES-256 key search.

Sizes in bytes, from FIPS 203 Table 3, FIPS 204 Table 2 and FIPS 205 Table 2
standardparameter setcategorypublic keyprivate keyciphertext / signaturehard problem
FIPS 203 · ML-KEMML-KEM-51218001,632768 ciphertextModule-LWE
FIPS 203 · ML-KEMML-KEM-76831,1842,4001,088 ciphertextModule-LWE
FIPS 203 · ML-KEMML-KEM-102451,5683,1681,568 ciphertextModule-LWE
FIPS 204 · ML-DSAML-DSA-4421,3122,5602,420 signatureModule-LWE / SIS
FIPS 204 · ML-DSAML-DSA-6531,9524,0323,309 signatureModule-LWE / SIS
FIPS 204 · ML-DSAML-DSA-8752,5924,8964,627 signatureModule-LWE / SIS
FIPS 205 · SLH-DSASLH-DSA-128s132647,856 signaturehash functions
FIPS 205 · SLH-DSASLH-DSA-128f1326417,088 signaturehash functions
FIPS 205 · SLH-DSASLH-DSA-192s3489616,224 signaturehash functions
FIPS 205 · SLH-DSASLH-DSA-192f3489635,664 signaturehash functions
FIPS 205 · SLH-DSASLH-DSA-256s56412829,792 signaturehash functions
FIPS 205 · SLH-DSASLH-DSA-256f56412849,856 signaturehash functions
ML-KEM's shared secret is 32 bytes in every parameter set. The SLH-DSA sizes are the same for the SHA2 and SHAKE variants; the s sets trade signing speed for smaller signatures, the f sets the reverse. For scale, an RSA-2048 signature is 256 bytes and a P-256 ECDSA signature is 64.
8 · SOPHIA XT and this page

What runs today

On this page

Every figure above executes in the visitor's browser: the state-vector and qutrit engines, the surface-code decoder and its Monte Carlo, the Jacobi eigensolver and the parameter-shift loop, the rewrite pass, and the SU(2)k anyon algebra on the ternary page. There is no server behind them and no quantum hardware; they are the reference implementations we use to reason about these algorithms, published as the page itself. The self-check table in the first figure runs on every load.

Three-valued verifier judgements, true, false or abstain, are part of the arbiter lanes in the SOPHIA XT stack today; the ternary page carries the measured routing results and the qutrit and anyon mathematics that direction rests on.

Open problems

The threshold plot uses code-capacity noise with perfect syndrome measurement. Circuit-level noise, where the stabilizer measurements themselves fail and the decoder has to match across rounds in time, lowers the threshold to below one percent and is the next figure to build.

The eigensolver uses exact expectation values. On a device each Pauli term is estimated from shots, and the gradient signal competes with shot noise; the figure does not yet model that.

Five qubits is the limit of a state vector that redraws at animation rate on a phone. Tensor-network or Clifford simulation would extend the reach for structured circuits, and the transpiler needs routing to a fixed coupling graph before it resembles a hardware pass.