Skip to main content

Overview

The phase coherence test suite validates that quantum gate identities are preserved through amplitude evolution rather than symbolic substitution. These tests verify that the neural backends correctly handle phase relationships that are central to quantum interference. From README.md:197:
A phase coherence test suite verified algebraic identities: HZH = X, HXH = Z, XX = I, and others, executed as amplitude evolution rather than symbolic substitution.

Test Methodology

Execution Model

From README.md:263:
Phase coherence test suite: 22/22 passed.
Each test executes a sequence of quantum gates and measures the resulting state. The tests verify that:
  1. Probability amplitudes evolve correctly
  2. Phase relationships are preserved
  3. Interference patterns emerge as expected
  4. Unitary constraints hold throughout
These are not symbolic checks. The system actually evolves quantum states through the gate sequences and measures the outcomes.

Test Groups

Group 1: Single-Qubit Phase Algebra

These tests verify fundamental single-qubit identities:
Test: Apply H, then Z, then H to |0⟩Expected: Should be equivalent to applying X to |0⟩, resulting in |1⟩Result: P(|1⟩) = 1.0000Status: PASSThis tests whether the Hadamard gate correctly rotates the Z-axis to the X-axis in the Bloch sphere representation.
Test: Apply H, then X, then H to |0⟩Expected: Should be equivalent to applying Z to |0⟩, resulting in |0⟩Result: P(|1⟩) = 0.0000Status: PASSThis is the conjugate identity to HZH = X.
Test: Apply H, S, S, H to |0⟩Expected: Two S gates equal Z gate, so HSSH = HZH = XResult: P(|1⟩) = 1.0000Status: PASSVerifies that phase gates compose correctly: S² = Z.
Test: Apply H, Rz(π), H to |0⟩Expected: Rotation by π around Z-axis in Hadamard basis equals XResult: P(|1⟩) = 1.0000Status: PASSVerifies continuous rotation gates match discrete gates.
Test: Apply Ry(π) to |0⟩Expected: Full rotation around Y-axis flips the stateResult: P(|1⟩) = 1.0000Status: PASS
Test: Apply X twice to |0⟩Expected: Returns to |0⟩ (identity operation)Result: P(|1⟩) = 0.0000Status: PASSVerifies involution property of Pauli-X.
Test: Apply H, Z, Z, H to |0⟩Expected: Z² = I, so HZZH = HIH = IResult: P(|1⟩) = 0.0000Status: PASSVerifies that phase gates cancel correctly.
Test: Apply Rx(π) to |0⟩Expected: Full rotation around X-axis flips the stateResult: P(|1⟩) = 1.0000Status: PASS

Group 2: Two-Qubit Phase-Sensitive Interference

These tests involve entanglement and controlled operations:
Test: Prepare |+0⟩ with H on qubit 0, apply CNOT twice, then HExpected: CNOT is self-inverse in Bell basisResult: P(|00⟩) = 1.0000Status: PASSThis test is particularly sensitive to phase errors in two-qubit gates.
Test: Bell state preparation with two CZ gates in the middleExpected: CZ² = I in the computational basisResult: P(|00⟩) = 1.0000Status: PASSVerifies controlled phase gate composition.
Test: Create Bell state, apply Z to control, undo entanglementExpected: Phase on control transfers to X on targetResult: P(|10⟩) = 1.0000Status: PASSThis tests whether phases propagate correctly through entangled states.
Test: Apply X to qubit 1, then SWAP twiceExpected: Two SWAPs return to original stateResult: P(|01⟩) = 1.0000Status: PASS
Test: Prepare |01⟩, apply SWAPExpected: Qubits exchange positionsResult: P(|10⟩) = 1.0000Status: PASS

Group 3: Norm Preservation (Unitarity)

These tests verify that probability normalization holds:
CircuitSum of ProbabilitiesToleranceResult
After H1.000000001e-10PASS
After X1.000000001e-10PASS
After HXH1.000000001e-10PASS
After Bell1.000000001e-10PASS
After GHZ1.000000001e-10PASS
After QFT-31.000000001e-10PASS
From README.md:180:
Born probabilities are computed by integrating the squared modulus over the spatial grid: P(k) = Sum_ (alpha_^2 + alpha_^2) normalized so that Sum_k P(k) = 1.

Group 4: Entanglement (Shannon Entropy)

These tests verify correct entropy for known states:
State: (|00⟩ + |11⟩)/√2Expected Entropy: 1 bitMeasured: 1.0000 bitsStatus: PASSMaximal entanglement produces exactly 1 bit of Shannon entropy.
State: (|000⟩ + |111⟩)/√2Expected Entropy: 1 bitMeasured: 1.0000 bitsStatus: PASSThree-qubit GHZ state also has 1 bit entropy despite more qubits.
State: Uniform superposition over 8 statesExpected Entropy: 3 bitsMeasured: 3.0000 bitsStatus: PASSMaximal classical entropy for 3 qubits.
State: |0⟩Expected Entropy: 0 bitsMeasured: 0.0000 bitsStatus: PASSPure state has zero entropy.

Complete Test Log

======================================================================
PHASE COHERENCE & UNITARITY TEST SUITE
======================================================================

--- Group 1: Single-qubit phase algebra ---
  [PASS] HZH = X  (|0>->|1>):  P(|1>)=1.0000  expected=1.0
  [PASS] HXH = Z  (|0>->|0>):  P(|1>)=0.0000  expected=0.0
  [PASS] HSSH = HZH = X  (P(|1>)=1.0000  expected=1.0)
  [PASS] H Rz(pi) H = X  (P(|1>)=1.0000  expected=1.0)
  [PASS] Ry(pi)|0> = |1>  (P(|1>)=1.0000  expected=1.0)
  [PASS] XX = I  (|0>->|0>):  P(|1>)=0.0000  expected=0.0
  [PASS] HZZH = H I H = I  (P(|1>)=0.0000  expected=0.0)
  [PASS] Rx(pi)|0> = |1>  (P(|1>)=1.0000  expected=1.0)

--- Group 2: Two-qubit phase-sensitive interference ---
  [PASS] H CNOT CNOT H = I  (P(|00>)=1.0000  expected=1.0)
  [PASS] H CNOT CZ CZ CNOT H = I  (P(|00>)=1.0000  expected=1.0)
  [PASS] H CNOT Z(ctrl) CNOT H = X(0)  (P(|10>)=1.0000  expected=1.0)
  [PASS] X(1) SWAP SWAP = I  (P(|01>)=1.0000  expected=1.0)
  [PASS] SWAP |01> = |10>  (P(|10>)=1.0000  expected=1.0)

--- Group 3: Norm preservation (unitarity) ---
  [PASS] Norm preserved after H: sum(P)=1.00000000  expected=1.0
  [PASS] Norm preserved after X: sum(P)=1.00000000  expected=1.0
  [PASS] Norm preserved after HXH: sum(P)=1.00000000  expected=1.0
  [PASS] Norm preserved after Bell: sum(P)=1.00000000  expected=1.0
  [PASS] Norm preserved after GHZ: sum(P)=1.00000000  expected=1.0
  [PASS] Norm preserved after QFT-3: sum(P)=1.00000000  expected=1.0

--- Group 4: Entanglement (Shannon entropy) ---
  [PASS] Bell state entropy = 1 bit  (got 1.0000)
  [PASS] GHZ-3 entropy = 1 bit  (got 1.0000)
  [PASS] QFT-3 entropy = 3 bits  (got 3.0000)
  [PASS] |0> entropy = 0 bits  (got 0.0000)

======================================================================
ALL TESTS PASSED  (22/22)
======================================================================

State Representation

From README.md:173-182:
The simulator represents an n-qubit state as a tensor of shape (2^n, 2, G, G), where G = 16 is the spatial grid size. The first index labels computational basis states. The second index holds real and imaginary components. The last two indices represent a spatial wavefunction. Born probabilities are computed by integrating the squared modulus over the spatial grid: P(k) = Sum_ (alpha_^2 + alpha_^2) normalized so that Sum_k P(k) = 1.

Backend Agreement

From README.md:184-192:
Three neural backends were used:
  • Hamiltonian: A spectral convolution network that applies a learned Hamiltonian operator
  • Schrödinger: A 2-channel network trained to propagate wavefunctions
  • Dirac: An 8-channel network operating on 4-component spinors
Each backend was loaded from its own checkpoint file. No weights were shared. No caches were synchronized. All three ran on CPU with identical random seeds.
All 22 tests passed identically on all three backends.

Significance

From README.md:371:
The perfect symmetry |E(+F) - E(-F)| at machine precision tells me that the backends are not introducing spurious field-dependent artifacts. They are not breaking parity. They are not leaking information between positive and negative field directions.
These phase coherence tests establish that the neural backends preserve quantum interference patterns exactly. This is not approximate behavior—the tests verify exact algebraic identities through amplitude evolution.

Build docs developers (and LLMs) love