What State Register owns
State Register is the exact-execution product inside Lattice Mesh. It holds one pure state of a chosen width n as a contiguous table of 2^n complex amplitudes. A gate is a unitary (or, when Noise Channel is attached, a completely positive map) that reads that table and writes a new one. Nothing in this product approximates the state by dropping singular values. If the table does not fit, the run stops before the first gate and names the byte budget it would have needed.
The laboratory uses this product when a later argument needs every amplitude: a ledger of Pauli expectations on a narrow circuit, a regression test for Bond Contract, or a certification that a short program really prepares the state the author claimed. Widths beyond the memory budget belong to Bond Contract or to Device Span, not to a silent downcast inside State Register.
- One register, one width, one endianness, declared before any gate.
- Gates are applied in the order written. The script order is time order, which is the reverse of the order in which matrices are multiplied.
- The global phase of the whole table is left alone. Relative phases between basis states are preserved bit for bit in double precision.
- A run that would allocate past the declared ceiling returns a budget fault. It does not switch products underneath the caller.
Index convention
Qubit 0 is the least significant bit of the amplitude index. For a basis label written |q_{n-1} … q1 q0⟩, the table row is the integer k = Σ_b q_b 2^b. A single-qubit gate on wire b mixes every pair of rows whose indices differ only in bit b. A two-qubit gate on wires b and c mixes the four rows that span those two bits and leaves every other bit untouched.
This little-endian rule is part of the product contract. Observable Ledger, Device Span, and the Bond Contract regression tests all read the same numbering. A caller who wants the opposite endianness reverses the wire list at the boundary and documents that reversal. State Register itself does not offer a second numbering.
| Width n | Amplitudes | Table size |
|---|---|---|
| 8 | 256 | 4 KiB |
| 16 | 65,536 | 1 MiB |
| 20 | 1,048,576 | 16 MiB |
| 24 | 16,777,216 | 256 MiB |
| 30 | 1,073,741,824 | 16 GiB |
Worked circuit: the Aether braid
Every Lattice Mesh page uses the same house circuit so numbers can be checked across products. The Aether braid is three wires, initialized to |000⟩, then Hadamard on wire 0, controlled-not from 0 onto 1, and controlled-not from 1 onto 2. The gate script below is Lattice script, the notation this laboratory writes in notebooks. It is not a binding to any external library.
register = Lattice.open(width=3, endian="little", ceiling="64 MiB")
register.apply("H", on=0)
register.apply("CNOT", control=0, target=1)
register.apply("CNOT", control=1, target=2)
register.assert_norm(tol=1e-12)Follow the pairs. Hadamard on wire 0 writes (|000⟩ + |001⟩) / √2. The first controlled-not copies the excitation on wire 0 onto wire 1, producing (|000⟩ + |011⟩) / √2. The second controlled-not copies wire 1 onto wire 2, producing (|000⟩ + |111⟩) / √2. Six of the eight amplitudes stay zero. The two nonzero amplitudes are each 1/√2, about 0.7071067811865476, with phase zero.
| Index | Basis | Amplitude |
|---|---|---|
| 0 | |000⟩ | 1/√2 |
| 1 | |001⟩ | 0 |
| 2 | |010⟩ | 0 |
| 3 | |011⟩ | 0 |
| 4 | |100⟩ | 0 |
| 5 | |101⟩ | 0 |
| 6 | |110⟩ | 0 |
| 7 | |111⟩ | 1/√2 |
Probabilities are the squared moduli: one half on |000⟩, one half on |111⟩, and zero elsewhere. The norm of the table is 1. State Register checks that norm after every gate when assert_norm is armed, and also once at the end of a batch if the caller only wants a final check. A drift past the tolerance is a fault, not a warning that the ledger is still allowed to publish.
Gate catalogue
The catalogue is small on purpose. Each name denotes one matrix family, written in the usual computational basis with the target wire’s |0⟩ column first. Angles are radians. A controlled gate uses the positive control convention: the target matrix is applied only when every listed control bit is 1.
| Name | Action on the named wire |
|---|---|
| I | Leave the wire unchanged. |
| X, Y, Z | Pauli operators. |
| H | Hadamard. Sends |0⟩ to (|0⟩+|1⟩)/√2 and |1⟩ to (|0⟩−|1⟩)/√2. |
| S, T | Phase gates diag(1, i) and diag(1, e^{iπ/4}). |
| Rx, Ry, Rz | Rotations by an angle argument. Rx(θ) = exp(−i θ X / 2), and likewise for Y and Z. |
| CNOT, CZ, SWAP | Two-wire maps. CNOT is controlled-X. SWAP exchanges the two wires. |
A controlled-swap and a three-wire Toffoli are available as named macros that expand into the catalogue above, so a notebook can print the expanded script. State Register applies the expanded form. It does not keep a hidden native kernel that disagrees with that expansion.
Custom unitaries are accepted only as an explicit matrix whose dimension is 2 or 4, together with the wires they occupy. The product checks U†U = I to the caller’s tolerance before the first pair is touched. A matrix that fails the check is rejected. There is no path that writes a non-unitary into the table and continues.
How a gate walks the table
A gate on a low wire touches pairs that sit next to each other in memory. A gate on a high wire touches pairs separated by a stride of 2^b. State Register groups those pairs into tiles that fit the scratch buffer declared at open. The tile size is an execution detail. The numerical result is defined to match a straightforward pairwise update in double precision, summed in an order the regression file records: for each pair, the two old amplitudes are read, the 2×2 (or 4×4) matrix is applied, and the two new amplitudes are written before the next pair.
That specified order matters when two valid summation orders would round differently. The regression for the Aether braid compares against the table in Table 2, not against a second implementation that is free to reassociate. Device Span is required to reproduce the same values when it uses one worker. When it uses several workers, the tolerance widens only by the amount published in the device-span contract, and the laboratory records both.
Faults
- Budget fault: 16 × 2^n plus scratch exceeds ceiling.
- Width fault: a gate names a wire outside 0 … n−1.
- Unitary fault: a custom matrix fails U†U = I.
- Norm fault: the table’s Euclidean norm leaves the asserted band.
- Phase-lock fault: the caller asked to pin amplitude 0 to be real and non-negative, and the first nonzero amplitude was zero because the state is orthogonal to |0…0⟩. The product then refuses to invent a pivot and asks the caller to name a pivot row.
None of these faults truncate the state and return a partial table marked successful. The register is left as it was before the failing call, or it is closed, depending on the flag close_on_fault. The default is to close.
How the other products use it
Observable Ledger never stores its own copy of the amplitudes. It asks State Register for ⟨P⟩ by contracting the table with P, or it asks for shot samples when the caller wants a finite sample rather than the exact expectation. Bond Contract is checked against State Register on every circuit whose exact table fits in the regression ceiling (width at most 16 in the current laboratory profile). Noise Channel can be pushed onto a State Register only by replacing the pure table with a density operator, which is a different allocation — see that product — and State Register will not silently upgrade itself.
Device Span is a distribution of this same table. A span of one device is required to match State Register entry for entry on the Aether braid and on the rotation suite (Rx, Ry, Rz at angles kπ/12). A mismatch is a laboratory incident, not a tolerated platform difference.