Skip to content
Symbolic & Numerical Algorithms · Numerical Algorithms

Double-Double Lanczos ED & Residual Protocol

How weyl-oracle builds independent stabilizer reductions, matrix-free sector MatVec kernels, 106-bit double-double Lanczos iteration, Ritz residual bounds, and ray-sweep log-log slope checks.

In Weyl's verification architecture, Exact Diagonalization (ED) is not an informal sanity check—it is an independent numerical oracle completely decoupled from the symbolic derivation under test. weyl-oracle builds its matrix-free MatVec operator directly from the raw HIR microscopic Hamiltonian and performs stabilizer reduction independently, never reusing the pCUT pipeline's syndrome map or effective Ising mapping. Even a systematic bug in the symbolic front-end or pCUT transformation cannot hide from the oracle.

What the ED oracle shows

The ED oracle returns only Pass, Fail(OracleDiag) or Inconclusive. It produces no tagged value and does not change the error tag of the result it checks. Passing shows numerical agreement at size LL, not a proof of the symbolic derivation. ED is used only to decide compare assertions and to locate first_bad_order.

Independent Stabilizer Reduction & Symmetry Sectors ​

On a rough–smooth cylinder of circumference LL and height WW, the microscopic qubit count is:

N=(2W+2)LN = (2W + 2)L

At W=2,L=6W = 2, L = 6 (N=36N = 36), a single real f64 state vector already consumes 236×8 B=512 GiB2^{36} \times 8\text{ B} = 512\text{ GiB}; at L=12,W=2L = 12, W = 2 (N=72N = 72), unreduced enumeration is physically impossible. Accordingly, weyl-oracle restricts unreduced full-space cross-checks to small cylinders (W=2,L≤4W = 2, L \le 4) and applies a self-contained three-stage Clifford/stabilizer reduction for larger geometries.

First, working directly from the raw HIR microscopic Hamiltonian, the oracle identifies all conserved star and bulk plaquette operators commuting with every perturbation term (for instance, 4848 deep stars and bulk BpB_p at L=12,W=2L = 12, W = 2). Using symplectic Gaussian elimination, it independently constructs a Clifford frame that eliminates these integrals of motion and leaves neff≪Nn_{\text{eff}} \ll N effective qubits; off-diagonal star operators are never handled by naive bit-filtering in the raw computational basis. Next, in the reduced Hamiltonian Reduced, every Z~w\tilde{Z}^w word commuting with all X~\tilde{X}-type bit-flip terms—such as the top Wilson loop WetopW_e^{\text{top}}, parity, or U(1)U(1) charge—defines a linear constraint over F2neff\mathbb{F}_2^{n_{\text{eff}}}, so weyl-oracle computes the row-reduced nullspace of the flip-mask matrix over F2\mathbb{F}_2 and splits the basis into affine subspaces indexed compactly by their free bits. Finally, because single-cell translation TT acts as a permutation π\pi of the sector's basis states, block-diagonalizing into momentum eigenstates k∈{0,π}k \in \{0, \pi\} (and point-group parity sectors when present) cuts the active dimension by another factor of nearly LL.

rust
// crates/weyl-oracle/src/ed.rs — Symmetry sector and diagnostic report types
pub struct Sector {
    pub nf: usize,                    // Number of free bits; sector dim = 2^nf
    pub symmetries: Vec<u64>,         // F2 nullspace basis (each with a private pivot bit)
    pub free: Vec<u32>,               // Bit positions of free bits in n_eff
    pub pivots: Vec<(u32, u64, bool)>,// (pivot_bit, compact_mask, eigenvalue == -1)
    pub symmetry_values: Vec<i8>,     // Eigenvalues (±1) on the unperturbed reference state
}

pub struct SectorReport {
    pub reference: Reference,               // Vacuum or Particle { template }
    pub momentum: Momentum,                 // k = 0 or k = π
    pub symmetry_values: Vec<i8>,
    pub dimension: usize,                   // Dimension of the momentum block
    pub loops: Vec<(String, Option<i8>)>,   // Named Wilson loops (e.g. W_e^top)
}

Matrix-Free MatVec & Cross-Sector Observables ​

Inside each momentum block, BlockHamiltonian<R> never materializes a sparse matrix. Instead, it evaluates w=Hvw = H v on bit-packed Fock/spin states: diagonal Z~\tilde{Z} words accumulate real energies per basis state, while off-diagonal X~\tilde{X} words jump directly to ket ^ flip_mask, applying the sign parity and orbit normalization factor on the fly.

To uphold Weyl's cross-thread determinism invariant, all parallel reductions and inner products partition vectors into fixed chunks of CHUNK = 1 << 14 (16,384 elements) and reduce partial sums in strict chunk-index order. Whether run on 1 thread or 64 threads, floating-point summation trees are identical and outputs match bit for bit.

On the rough–smooth cylinder, ground-state energy density and single-particle dispersion are strictly defined across Wilson-loop sectors:

e0(L)=Evac(L)−Ebulk(L)Le_0(L) = \frac{E_{\text{vac}}(L) - E_{\text{bulk}}(L)}{L}

ωL(k)=Emin⁡ ⁣(k, Wetop=−1)−Emin⁡ ⁣(0, Wetop=+1)\omega_L(k) = E_{\min}\!\left(k,\, W_e^{\text{top}} = -1\right) - E_{\min}\!\left(0,\, W_e^{\text{top}} = +1\right)

The lowest state in the odd sector (Wetop=−1W_e^{\text{top}} = -1) must lie on an isolated single-particle branch; when approaching a multi-particle continuum, the lowest eigenvalue cannot blindly be identified with that branch. Substituting an intra-sector excitation gap for ωL(k)\omega_L(k) is forbidden, and every oracle report preserves both endpoint sectors and eigenstate labels.

Double-Double Arithmetic & Lanczos Tridiagonalization ​

For high-order perturbative series (n=10–14n = 10\text{–}14) evaluated at t∈[0.01,0.15]t \in [0.01, 0.15], the true residual scales as t13∼10−26t^{13} \sim 10^{-26}—ten orders of magnitude below IEEE 754 f64 machine epsilon (ϵf64≈2.22×10−16\epsilon_{\text{f64}} \approx 2.22 \times 10^{-16}). Subtracting energies and series in f64 destroys all significant digits by n≥6n \ge 6.

weyl-oracle therefore parameterizes the entire solver over a Real trait supporting both f64 (for low-order probes) and Dd (double-double, an unevaluated pair (hi, lo): (f64, f64) giving ~106 bits of significand, ϵdd≈4.93×10−32\epsilon_{\text{dd}} \approx 4.93 \times 10^{-32}). Precision::DoubleDouble is applied uniformly across MatVec, Lanczos recurrence, reorthogonalization, inner products, tridiagonal Ritz solves (Jacobi diagonalization), and cross-sector energy subtraction.

Two-Pass Full Reorthogonalization & Ghost Elimination ​

Standard three-term Lanczos loses orthogonality rapidly in finite precision, spawning spurious duplicate Ritz values ("ghost eigenvalues"). weyl-oracle seeds the Krylov subspace with the unperturbed eigenstate v1v_1 (the exact stabilizer state of H0H_0 in that sector)—so each step captures roughly one order of perturbation theory and a few dozen iterations hit the roundoff floor—and applies two-pass classical Gram–Schmidt (CGS2) full reorthogonalization at every step, reprojecting onto the momentum sector every reproject_every steps:

rust
// crates/weyl-oracle/src/ed.rs — Lanczos loop with two-pass full reorthogonalization
pub struct LanczosOpts {
    pub max_iterations: usize,  // Default: 200
    pub max_vectors: usize,     // Memory-bounded Krylov basis cap
    pub reproject_every: usize, // Default: reproject momentum every 4 steps
}

// At step m: w = H * v_m, alpha_m = <w, v_m>
for _ in 0..2 {
    for b in &basis {
        let c = dot(&w, b);          // Fixed-CHUNK deterministic inner product
        axpy_sub(&mut w, c, b);      // w <- w - c * b
    }
}

Rigorous Ritz Residual Bounds ​

Let (θ1,y1)(\theta_1, y_1) be the lowest Ritz pair of the m×mm \times m real symmetric tridiagonal matrix TmT_m, with Ritz vector u1=Vmy1u_1 = V_m y_1. From the Lanczos identity HVm=VmTm+βmvm+1em⊤H V_m = V_m T_m + \beta_m v_{m+1} e_m^\top, the residual norm is computed without an extra MatVec:

ρm=∥Hu1−θ1u1∥2=βm ∣y1,m∣\rho_m = \| H u_1 - \theta_1 u_1 \|_2 = \beta_m \, |y_{1,m}|

With spectral gap gm=θ2−θ1g_m = \theta_2 - \theta_1 and spectral spread Sm=max⁡j∣θj∣S_m = \max_j |\theta_j|, combining the standard Krylov bound with the quadratic Temple/Davis–Kahan bound yields the rigorous eigenvalue error estimate:

δEm=max⁡ ⁣(64 ϵR Sm,  {min⁡ ⁣(ρm,  ρm2gm)if gm>ρmρmotherwise)\delta E_m = \max\!\left(64 \, \epsilon_R \, S_m,\; \begin{cases} \min\!\left(\rho_m,\; \dfrac{\rho_m^2}{g_m}\right) & \text{if } g_m > \rho_m \\ \rho_m & \text{otherwise} \end{cases}\right)

Convergence triggers when the bound drops to the roundoff floor 64ϵRSm64 \epsilon_R S_m or βm≤64ϵRSm\beta_m \le 64 \epsilon_R S_m. Crucially, Weyl never hardcodes an assumed 10−3010^{-30} accuracy or 4×4\times cost for double-double; actual error, residual, gap, and iteration counts are measured per solve and emitted in Eigenvalue<R> and telemetry.

Precision ModeSignificandMachine Epsilon ϵR\epsilon_RReliable Verification Orders (t∼0.05t \sim 0.05)Memory per Vector
Precision::F6453 bits2.22×10−162.22 \times 10^{-16}n≤6n \le 6 (fast low-order probes)8×dim⁡8 \times \dim B
Precision::DoubleDouble~106 bits4.93×10−324.93 \times 10^{-32}n≤16n \le 16 (high-order residual slopes)16×dim⁡16 \times \dim B

Finite-Size Scaling & Memory Budget ​

On a rough–smooth cylinder (W=2W=2), independent stabilizer reduction combined with Z~\tilde{Z} symmetry sectors and momentum blocking brings an exponentially intractable Hilbert space within single-node RAM (assuming m=40m = 40 reorthogonalized Lanczos basis vectors):

Cylinder (L,W)(L, W)Raw Qubits NNRaw Vector (f64)Effective Qubits neffn_{\text{eff}}Momentum Block dim⁡\dim40-Step Lanczos Basis (Dd)
(4,2)(4, 2)24128 MiB8∼12\sim 12<8 KiB< 8\text{ KiB}
(6,2)(6, 2)36512 GiB12∼36\sim 36<32 KiB< 32\text{ KiB}
(8,2)(8, 2)482 PiB16∼260\sim 260∼166 KiB\sim 166\text{ KiB}
(12,2)(12, 2)723.7×10103.7 \times 10^{10} TiB24∼3.5×105\sim 3.5 \times 10^5∼224 MiB\sim 224\text{ MiB}
(16,2)(16, 2)96infeasible32∼6.7×107\sim 6.7 \times 10^7∼43 GiB\sim 43\text{ GiB}

When the target order nn approaches LL (for instance, n=12n = 12 with symmetry forcing the first omitted nonzero order to r=14r = 14), an L=12L = 12 cylinder inevitably mixes in winding linked clusters. The protocol therefore requires enlarging to L=16L = 16 (r<Lr < L) or subtracting exact winding terms from an independent finite-size expansion; otherwise it returns Inconclusive.

Ray Sweep & Log-Log Residual Slope Protocol ​

To validate a Stage B multivariate series Sn(x,κ1,κ2)S_n(x, \kappa_1, \kappa_2) truncated at total degree nn, sweeping xx at fixed nonzero κ\kappa cannot test the total-degree truncation. weyl-oracle instead sweeps fixed rays through the origin:

(x,κ1,κ2)=t⋅(α,β1,β2),t∈[0.01,0.15](x, \kappa_1, \kappa_2) = t \cdot (\alpha, \beta_1, \beta_2), \qquad t \in [0.01, 0.15]

using seven default ascending samples t∈{1100,164,140,125,116,110,320}t \in \{ \tfrac{1}{100}, \tfrac{1}{64}, \tfrac{1}{40}, \tfrac{1}{25}, \tfrac{1}{16}, \tfrac{1}{10}, \tfrac{3}{20} \}. If all terms through degree nn are exact, the residual vanishes asymptotically as:

R(t)=∣OED(L;t)−Sn(t)∣=Cr tr+O(tr+1),dln⁡R(t)dln⁡t→t→0+rR(t) = \left| O_{\text{ED}}(L; t) - S_n(t) \right| = C_r \, t^r + \mathcal{O}(t^{r+1}), \qquad \frac{\mathrm{d}\ln R(t)}{\mathrm{d}\ln t} \xrightarrow{t \to 0^+} r

where r>nr > n is the first omitted order that does not vanish along the ray.

The protocol enforces four strict gates before issuing a verdict. Because linked clusters wrapping around the cylinder enter at order LL, comparisons are conclusive only under the finite-size winding guard r<Lr < L; note that n<Ln < L alone does not guarantee r<Lr < L, since symmetry can force r=n+2=Lr = n + 2 = L, and whenever r≥Lr \ge L the user must increase LL or subtract exact winding contributions from an independent finite-size expansion. To keep numerical roundoff floors from flattening the fitted slope, only sample points satisfying the 10×10\times signal-to-noise gate R(t)>10 δOnum(t)R(t) > 10 \, \delta O_{\text{num}}(t) enter the log-log fit. Linear regression then starts from an adaptive window of the smallest valid tt values, dropping larger-tt points bent by higher orders: a fitted slope s≥r−0.3s \ge r - 0.3 yields Pass (permitting s>rs > r when CrC_r happens to vanish on that ray), whereas s<r−0.3s < r - 0.3 yields Fail. Finally, first_bad_order = Some(k) is reported conservatively—only when the fitted slope lies within 0.30.3 of an integer k≤nk \le n and the regression window contains enough points to discriminate; otherwise the oracle returns Inconclusive or leaves the bad order unspecified.

rust
// crates/weyl-oracle/src/protocol.rs — Structured ray-sweep verification record
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RayOutcome {
    pub observable: String,
    pub ray: Vec<String>,               // Rational ray direction (α, β₁, β₂)
    pub known_order: u32,               // Highest total degree n of the series
    pub expected_slope: f64,            // Expected first omitted nonzero order r
    pub fitted_slope: Option<f64>,      // Log-log regression slope over valid window
    pub window: Option<(f64, f64)>,     // Active [t_min, t_max] regression window
    pub residuals: Vec<(f64, f64, f64)>,// Per-point (t, exact - series, num_err)
    pub first_bad_order: Option<u32>,   // Set only when cleanly discriminable
}

Zero-Tolerance Free-Fermion Oracle for Stage A

For Stage A non-interacting boundary models (exact free-fermion mapping), weyl-oracle provides a closed-form analytic oracle:

ω(k)=21+x2−2xcos⁡k,e0=−12π∫02π1+x2−2xcos⁡k dk\omega(k) = 2\sqrt{1 + x^2 - 2x\cos k}, \qquad e_0 = -\frac{1}{2\pi}\int_0^{2\pi} \sqrt{1 + x^2 - 2x\cos k}\,\mathrm{d}k

It compares every hopping amplitude tδt_\delta and e0e_0 term-by-term over Q\mathbb{Q} with zero tolerance across all 14 orders, eliminating any need for small-LL ED slope fitting on Stage A.

Invoking ED Checks in .weyl and weylc ​

In surface Weyl code, compare binds the cylinder geometry, precision, rays, and cross-sector observables; the verdict decides whether downstream results may be published:

weyl
compare gap_series against ed(
    geometry  = cylinder(L = 12, W = 2),
    precision = double_double,
    rays      = [(1, 0, 0), (1, 1/2, 0), (1, 1/3, 1/4)],
    sectors   = { vacuum: (k = 0, W_e_top = +1), exc: (k = pi, W_e_top = -1) },
    slope_tol = 0.3,
)

Running weylc run executes the full pipeline, including the ED oracle verdicts for every compare assertion, and produces a structured residual trace ready for human audit or MCP telemetry ingestion:

bash
$ weylc run examples/toric_boundary.weyl
[oracle.ed] L=12 W=2 | n_eff=24 | sectors: vac(k=0, W=+1, dim=352), exc(k=pi, W=-1, dim=348)
[oracle.ed] ray=(1, 1/2, 0) | precision=double-double (eps=4.93e-32)
  t=0.01000  |exact - series|=1.428e-26  err_bound=3.11e-30  snr=4.59e+03  [used]
  t=0.01563  |exact - series|=4.912e-24  err_bound=3.14e-30  snr=1.56e+06  [used]
  t=0.02500  |exact - series|=2.194e-21  err_bound=3.19e-30  snr=6.88e+08  [used]
  t=0.04000  |exact - series|=1.012e-18  err_bound=3.25e-30  snr=3.11e+11  [used]
[oracle.ed] fitted_slope = 13.04 (expected = 13.0, tol = 0.3) -> PASS

To cross-check the reduced effective Hamiltonian with an external solver (NumPy/SciPy, QuSpin, or XDiag), weylc export-ed emits a self-contained weyl.ed-model JSON payload alongside a standalone solve_ed.py runner.

Weyl v0.1 · MIT License