Library / Circuits / lumen-state
Lumen State
Lumen State stores a pure state as a length-2ⁿ array of complex amplitudes and applies gates by updating that array in place. It is the reference engine: every other Lumen product is specified by agreement with Lumen State on the circuits both can hold.
Documents on this site
- Lumen State specification/products/lumen-lattice/lumen-state
- Lumen Lattice overview/library/lumen-lattice
- Lumen Lattice/library/lumen-lattice
- Lumen Weave 1.0/library/lumen-weave
- Lumen Drift 1.0/library/lumen-drift
- Lumen Trace 1.0/library/lumen-trace
Register layout
Qubit 0 is the least significant bit of the amplitude index. The amplitude of basis state |b⟩ lives at index b when b is read as an integer. A single-qubit gate on wire q touches pairs of indices that differ only at bit q. A controlled gate on control c and target t touches a pair only when bit c is set.
Global phase is preserved. Data-T does not drop a phase to save a multiply. Two states that differ by e^{iφ} compare equal for probabilities and differ for interference, and the buffer keeps that distinction until a measurement query discards it on purpose.
- Precision: complex64 for exploratory runs, complex128 when a risk memo requires the reference residual.
- Normalisation: asserted after each layer in reference mode; skipped in throughput mode with a residual reported at the end.
- Index convention is part of the contract. Callers who bit-reverse before sending will be rejected with code lumen.state.index_convention.
Gate application
One-qubit gates are fused when they share a wire and no later gate has started. A run of RZ, RX, and H on the same wire becomes one 2×2 unitary before it touches memory. Two-qubit gates are not fused across wires unless the planner proves the pair commutes and the fusion stays inside the State kernel budget.
The hot path never materialises a 2ⁿ×2ⁿ matrix. It streams the buffer twice per targeted bit: once to read a pair, once to write the mixed pair. For a CX, half the buffer is skipped because the control bit is off. That skip is the main reason State stays practical up to the mid-thirties of qubits on a single accelerator, and why it stops being the right product past that width.
Snapshots, shots, and reduced states
A snapshot copies the buffer or a strided subset. A shot query does not copy the buffer; it draws bitstrings with a prefix-sum over probabilities computed on the fly, then returns counts. A reduced state on a kept set K traces out the complement by summing |a|² into a 2^{|K|} density, which is the hand-off object Lumen Drift already knows how to store.
If a caller asks for the full buffer above the configured byte ceiling, State refuses rather than paging. The error tells them to move the query to Lumen Weave or to shrink the kept set.
Agreement with the other engines
On every circuit inside the State budget, Weave’s contracted amplitude, Drift’s pure-state density, and Trace’s Pauli expectation must match State to the published tolerance (1e-5 in complex64 reference tests, 1e-10 in complex128). That test is part of the Data-T release gate. A product that disagrees is not shipped as Lumen 1.0.