SOPHIA XT
Sign in
Notebook archive · Quantum computing

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.

Thomas Garren, SOPHIA XT Research Self-checks on every load: Bell, GHZ, Grover 25/32, teleportation fidelity 1, rewrite fidelity 1 Computed on this page, no server, no hardware
Three-level state, p0 + p1 + p2 = 1 Computed in your browser
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 · Three-valued logic

Kleene's K₃ and balanced ternary

In the Constellation orchestrator a verifier lane scores another model's output as true, false or abstain, with a confidence attached. Abstain is a first-class outcome. The verifier's three answers are the three values of Kleene's strong logic, where AND and OR are min and max and the middle value absorbs whatever it meets. Balanced ternary is the arithmetic side of the same alphabet: digits \{-1, 0, +1\}, negation by digit flip, and a carry chain that is a trit rather than a bit. Both are evaluated live below.

Three-valued logic · Kleene K₃ and balanced ternary
Truth tables and an adder, evaluated on the page
a ∧ b = min
a \ bFUT
FFFF
UFUU
TFUT
a ∨ b = max
a \ bFUT
FFUT
UUUT
TTTT
a → b
a \ bFUT
FTTT
UUTT
TFUT
consensus
a \ bFUT
FFUU
UUUU
TUUT
a ⊕₃ b
a \ bFUT
FTFU
UFUT
TUTF
¬a and the verifier map
F = −¬ = Tfalse
U = 0¬ = Uabstain
T = +¬ = Ftrue
Balanced-ternary adder, most significant trit first
carry0−000
x = 170+−0−= 17
y = -800−0+= -8
x + y = 900+00= 9
a b
a ∧ b (min)
U
a ∨ b (max)
T
¬a
F
a → b (Łukasiewicz)
U
consensus(a, b)
U
a ⊕₃ b
T
As verifier judgements: a = true, b = abstain; consensus(a, b) = abstain.
Kleene's strong three-valued logic keeps the classical AND and OR as min and max on {F, U, T} and adds a third value U that absorbs whatever it touches: T ∧ U = U, F ∨ U = U, ¬U = U. That is the algebra of a verifier which may return true, false or abstain, which is how the arbiter lane in the SOPHIA XT stack scores another model's output. Balanced ternary writes integers with digits {−, 0, +}; negation is a digit flip, rounding is truncation, and the adder below carries a trit exactly as a binary adder carries a bit. The modular sum ⊕₃ is the classical shadow of the qutrit X₃ gate.
9 · Qutrits · SU(3)

Three-level quantum systems and their gates

A qutrit is a unit vector in \mathbb{C}^3; n of them span 3^n dimensions against 2^n for qubits. Its unitaries are SU(3), generated by the eight Gell-Mann matrices, and its Clifford group is generated by the Fourier gate H_3 and the phase gate S_3.

|\psi\rangle = \alpha|0\rangle + \beta|1\rangle + \gamma|2\rangle, \qquad |\alpha|^2 + |\beta|^2 + |\gamma|^2 = 1
H_3 = \frac{1}{\sqrt 3}\begin{pmatrix} 1 & 1 & 1 \\ 1 & \omega & \omega^2 \\ 1 & \omega^2 & \omega \end{pmatrix}, \quad \omega = e^{2\pi i/3}, \qquad X_3 = \begin{pmatrix} 0&0&1\\1&0&0\\0&1&0 \end{pmatrix}, \quad Z_3 = \mathrm{diag}(1, \omega, \omega^2)
S_3 = \mathrm{diag}(1, 1, \omega), \qquad T_3 = \mathrm{diag}(1, \zeta, \zeta^8), \quad \zeta = e^{2\pi i/9}

Two-qutrit entanglers: the controlled increment \mathrm{CX}_3|a,b\rangle = |a, b+a \bmod 3\rangle and the controlled phase \mathrm{CZ}_3|a,b\rangle = \omega^{ab}|a,b\rangle, related by H_3 on the target exactly as CNOT and CZ are for qubits.

The Gell-Mann matrices \lambda_1 \ldots \lambda_8 are traceless and Hermitian with \mathrm{Tr}(\lambda_a \lambda_b) = 2\delta_{ab}, so any density matrix expands as

\rho = \tfrac13 I + \tfrac12 \sum_{a=1}^{8} n_a \lambda_a, \qquad n_a = \mathrm{Tr}(\rho\lambda_a), \qquad \mathrm{Tr}\,\rho^2 = \tfrac13 + \tfrac12 |n|^2

The 8-vector n is the qutrit's Bloch vector. Pure states have |n|^2 = 4/3 but do not fill the sphere of that radius: the set of pure states is a four-dimensional surface inside an eight-dimensional ball, which is why the figure shows the eight components as bars and the diagonal pair (n_3, n_8) as a point in the triangle whose corners are the basis states.

Rotations \exp(-i\theta\lambda_a/2) are computed by scaling and squaring of the 3×3 series; the figure reports every gate's unitarity to rounding.

Qutrit simulator · two qutrits, SU(3)
Gates on a nine-dimensional state
Presets
H3 q0 · CX3 0→1
wire
gates
2
Σ|a|²
1.000000
Tr ρ₀²
0.3333
Tr ρ₁²
0.3333
X₃ is the cyclic shift |j⟩ → |j+1 mod 3⟩, Z₃ = diag(1, ω, ω²) with ω = e^{2πi/3}, H₃ is the Fourier transform on Z₃, S₃ = diag(1, 1, ω), and together H₃ and S₃ generate the single-qutrit Clifford group; T₃ = diag(1, ζ, ζ⁸) with ζ = e^{2πi/9} is the non-Clifford gate that completes a universal set (Howard and Vala 2012). Rotations are exp(−iθλ_a/2) for any of the eight Gell-Mann generators, computed by scaling and squaring. The bar rows are the 8-vector n_a = Tr(ρ λ_a) of each wire's reduced density matrix; a pure qutrit has |n|² = 4/3 and a maximally mixed one has n = 0, which is what the qutrit Bell preset produces on each wire. The triangles plot (n₃, n₈), the diagonal part of that vector, whose corners are the three basis states.
10 · Topological memory · anyons

Fusion spaces and braiding

A non-Abelian anyon theory assigns each pair of particles a set of fusion outcomes; the space of ways several particles can fuse to a given total charge is the qudit, and moving particles around each other acts on it by unitaries that depend only on the topology of the paths. Two pieces of data fix the theory: the F-symbols, which change the order of fusion, and the R-symbols, the phases of exchanging two particles in a definite channel. They must satisfy the pentagon and hexagon equations, and the figure checks both.

Fibonacci

\tau \times \tau = 1 + \tau, \qquad d_\tau = \varphi = \tfrac{1+\sqrt5}{2}
F^{\tau\tau\tau}_\tau = \begin{pmatrix} \varphi^{-1} & \varphi^{-1/2} \\ \varphi^{-1/2} & -\varphi^{-1} \end{pmatrix}, \qquad R^{\tau\tau}_1 = e^{-4\pi i/5}, \quad R^{\tau\tau}_\tau = e^{3\pi i/5}

Three τ's with total charge τ span two states, a qubit; the braid group on three strands acts on it through \sigma_1 = R and \sigma_2 = F R F^{-1}, and the image is dense in SU(2) (Freedman, Larsen and Wang 2002), so braiding alone is universal.

Metaplectic, SU(2)₄ ≅ SO(3)₂

X \times X = 1 + Y, \quad Y \times Y = 1 + Y + Z, \quad Y \times Z = Y, \quad Z \times Z = 1
d_X = \sqrt 3, \quad d_Y = 2, \quad d_Z = 1, \qquad [n]_q = \frac{\sin(n\pi/6)}{\sin(\pi/6)}

Four Y's with trivial total charge span three states: a qutrit (Hastings, Nayak and Wang 2013). Braiding acts on it by a finite group, 54 elements up to phase in the figure's count, so the metaplectic scheme completes its gate set by measuring the total charge of pairs rather than by braiding alone. That measured step is where a three-valued readout enters the hardware story.

Anyons · F and R symbols, braid group representation
Braiding as a unitary on the fusion space
F^{YYY}_{Y}, rows/cols 1, Y, Z
0.5000-0.70710.5000
-0.70710.00000.7071
0.50000.70710.5000
R^{YY}_c and fusion rules
c = 1exp(i·-0.6667π)
c = Yexp(i·0.6667π)
c = Zexp(i·0.3333π)
X × X1 + Y
X × YX + X′
X × X′Y + Z
X × ZX′
Y × Y1 + Y + Z
Y × X′X + X′
Y × ZY
X′ × X′1 + Y
X′ × ZX
Z × Z1
σ1 on the 3-dim fusion space
-0.500−0.866i00
0-0.500+0.866i0
000.500+0.866i
σ2 on the 3-dim fusion space
-0.250+0.433i0.354+0.612i0.250−0.433i
0.354+0.612i00.354+0.612i
0.250−0.433i0.354+0.612i-0.250+0.433i
σ3 on the 3-dim fusion space
-0.500−0.866i00
0-0.500+0.866i0
000.500+0.866i
U(word) = σ1·σ2·σ1
-0.250−0.433i0.354+0.612i-0.250−0.433i
0.354+0.612i0-0.354−0.612i
-0.250−0.433i-0.354−0.612i-0.250−0.433i
U · |basis 0⟩
(1,Y,1)-0.250−0.433i0.2500
(Y,Y,1)0.354+0.612i0.5000
(Z,Y,1)-0.250−0.433i0.2500
Σ|amp|²1.000000
space
append
start basis
fusion space dim
3
quantum dim d_x
2.000000
pentagon residual
running 0%
hexagon residual
pending
unitarity ‖σ†σ − I‖
1.8e-15
braid relation
1.2e-15
‖σ₁σ₃ − σ₃σ₁‖
0.0e+0
projective image
finite, order 54
The F-symbols are the q-deformed 6j symbols of SU(2)_k with q = e^{iπ/(k+2)} (Kirillov and Reshetikhin 1989) and the R-symbols are R^{ab}_c = (−1)^{a+b−c} q^{c(c+1)−a(a+1)−b(b+1)}; the pentagon and hexagon residuals are the largest violation of the two consistency equations over every label, computed on this page. Fibonacci is the integer-spin part of SU(2)_3: one anyon τ with τ × τ = 1 + τ, quantum dimension φ, and F^{τττ}_τ the familiar 2×2 golden-ratio matrix. The metaplectic theory is SU(2)_4, equivalently SO(3)_2: the spin-1 anyon Y has Y × Y = 1 + Y + Z, so four Y's with trivial total charge span three states, the qutrit of Hastings, Nayak and Wang (2013). On a left-to-right fusion tree σ₁ is diagonal in R, and σ₂ is F R F⁻¹. Every σ is unitary and the σ's satisfy the braid relations to rounding; the braid word you build is applied to the chosen basis state and its product matrix is shown. Closing the generators under multiplication, modulo global phase, ends after 54 elements for the metaplectic qutrit, so braiding alone is not universal there (Jones 1986; Freedman, Larsen and Wang 2002: with four or more strands the image is finite only for k + 2 = 1, 2, 3, 4 or 6); for Fibonacci the closure does not terminate, consistent with the density theorem of Freedman, Larsen and Wang (2002).
11 · Research direction · qutrit diffusion

The design question

A diffusion language model denoises a whole sequence at once rather than emitting one token after another. The ternary diffusion study asks what changes when the sequence lives on a three-letter alphabet and the denoiser's state is a register of qutrits: the noise process becomes a random walk on \mathbb{Z}_3 per position, driven by X_3, and the denoising step is a unitary on the register followed by a three-outcome measurement, which is the verifier's true, false, abstain read directly off the hardware.

The pieces on this page are the scaffolding for that question: the qutrit gate set and its 8-vector, the three-valued logic the verifier already uses, and the anyon fusion space that would hold the register with topological protection.

Open problems

Routing above N=2 on similar-domain capsules collapses, and the learned router reached zero mutual information; the representation problem, projecting a query into the capsule space, is unsolved.

A first reproducible training run of the ternary denoiser has not been done; the benchmarks will come from that run.

Metaplectic braiding is not universal on its own, so the architecture depends on charge measurement of anyon pairs, an operation that no current device performs.

12 · Reference implementation

The qutrit simulator, in Python

The same operations the figure above runs, written out for a notebook: the gate matrices, a two-qutrit register, the entanglers and the Gell-Mann 8-vector.

Qutrit register

1import numpy as np
2
3w = np.exp(2j* np.pi /3)
4zeta = np.exp(2j* np.pi /9)
5
6X3 = np.array([[0,0,1],[1,0,0],[0,1,0]], dtype=complex)# |j> -> |j+1 mod 3>
7Z3 = np.diag([1, w, w**2])
8H3 = np.array([[1,1,1],[1, w, w**2],[1, w**2, w]])/ np.sqrt(3)# Fourier on Z_3
9S3 = np.diag([1,1, w])# with H3 generates the Clifford group
10T3 = np.diag([1, zeta, zeta**8])# non-Clifford (Howard & Vala 2012)
11
12GELL_MANN =[
13 np.array([[0,1,0],[1,0,0],[0,0,0]]),
14 np.array([[0,-1j,0],[1j,0,0],[0,0,0]]),
15 np.array([[1,0,0],[0,-1,0],[0,0,0]]),
16 np.array([[0,0,1],[0,0,0],[1,0,0]]),
17 np.array([[0,0,-1j],[0,0,0],[1j,0,0]]),
18 np.array([[0,0,0],[0,0,1],[0,1,0]]),
19 np.array([[0,0,0],[0,0,-1j],[0,1j,0]]),
20 np.array([[1,0,0],[0,1,0],[0,0,-2]])/ np.sqrt(3),
21]
22
23defrotation(a:int, theta:float)-> np.ndarray:
24"""exp(-i theta lambda_a / 2) by eigendecomposition."""
25 vals, vecs = np.linalg.eigh(GELL_MANN[a -1])
26return vecs @ np.diag(np.exp(-0.5j* theta * vals)) @ vecs.conj().T
27
28classRegister:
29"""n qutrits; qutrit k owns base-3 digit n-1-k of the basis index."""
30
31def__init__(self, n:int):
32 self.n = n
33 self.psi = np.zeros(3**n, dtype=complex)
34 self.psi[0]=1.0
35
36defapply(self, U: np.ndarray, k:int):
37 psi = self.psi.reshape([3]* self.n)
38 psi = np.moveaxis(np.tensordot(U, psi, axes=([1],[k])),0, k)
39 self.psi = psi.reshape(-1)
40
41defcx3(self, c:int, t:int):
42 psi = self.psi.reshape([3]* self.n)
43 out = np.zeros_like(psi)
44for a inrange(3):
45 idx =[slice(None)]* self.n
46 idx[c]= a
47 out[tuple(idx)]= np.roll(psi[tuple(idx)], a, axis=t if t < c else t -1)
48 self.psi = out.reshape(-1)
49
50defcz3(self, c:int, t:int):
51 psi = self.psi.reshape([3]* self.n)
52 a = np.arange(3).reshape([3if i == c else1for i inrange(self.n)])
53 b = np.arange(3).reshape([3if i == t else1for i inrange(self.n)])
54 self.psi =(psi * w **((a * b)%3)).reshape(-1)
55
56defreduced(self, k:int)-> np.ndarray:
57 psi = np.moveaxis(self.psi.reshape([3]* self.n), k,0).reshape(3,-1)
58return psi @ psi.conj().T
59
60defbloch8(self, k:int)-> np.ndarray:
61 rho = self.reduced(k)
62return np.array([np.trace(rho @ L).real for L in GELL_MANN])
63
64defprobabilities(self)-> np.ndarray:
65return np.abs(self.psi)**2
66
67if __name__ =="__main__":
68 r = Register(2)
69 r.apply(H3,0)
70 r.cx3(0,1)# qutrit Bell state (|00> + |11> + |22>) / sqrt 3
71print(np.round(r.probabilities(),4))
72print("purity of q0:", np.trace(r.reduced(0) @ r.reduced(0)).real)# 1/3
73print("8-vector of q0:", np.round(r.bloch8(0),6))# all zero

The design study

The ternary diffusion design study: the qutrit register, the ternary diffusion process and the anyon encoding, as a PDF.

Download the PDF
13 · 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 in sections 8 to 12. 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. Sections 8 to 11 carry the three-valued logic, the qutrit and anyon mathematics, and the design question 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.

From the notebook archive

Ten essays and one
remembrance.

The notebook keeps the long reading: essays and side studies from the lab, each with figures that compute in the page. Current work and results are in the research index.

  1. 01 Spatial comprehension Plane fitting, tracking through occlusion, relation graphs and occupancy maps, computed on a point cloud.
  2. 02 Telemetric pathfinding Replanning when the map changes, sharing a grid between agents, and deciding from telemetry when a plan is stale.
  3. 03 AGI alignment Oversight for systems that outgrow their evaluators, with a live preference model.
  4. 04 Physics Fusion confinement, fluids, reconnection and a homopolar disc, each with a solver you can run.
  5. 05 Quantum computing You are reading this one.
  6. 06 The agentic web What changes when software agents, not people, read the pages.
  7. 07 Ethical AI Fairness metrics, federated learning, differential privacy, and how a model is made to persuade.
  8. 08 Digital feudalism Who owns what a billion people wrote, and what that does to the commons.
  9. 09 Rico Inf Curve Particle streams in a four-singularity well, and the propellantless ship sized to the numbers.
  10. 10 AI and humanity An essay and analysis of where the two curves meet.
  11. · In memoriam: Nuno F. Loureiro A tribute to the plasma physicist, 1977 to 2025.