From 42defd5999278c2867b8c55d5cd8905a9c062ff1 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Wed, 29 Jul 2026 22:00:40 +0800 Subject: [PATCH 01/13] qmc: add issue 121 polyhedral study --- .../qmc/solutions/mao-kexiang-121/README.md | 151 +++ .../finite_density_extension.md | 524 ++++++++++ .../solutions/mao-kexiang-121/main_theorem.md | 672 +++++++++++++ .../mao-kexiang-121/novelty_audit.md | 139 +++ .../mao-kexiang-121/physical_realization.md | 161 +++ .../mao-kexiang-121/reduction_checklist.md | 175 ++++ .../mao-kexiang-121/requirements.txt | 3 + .../mao-kexiang-121/sign_problem_hunter.py | 951 ++++++++++++++++++ .../test_sign_problem_hunter.py | 297 ++++++ .../wang2015_run_template.json | 33 + 10 files changed, 3106 insertions(+) create mode 100644 tracks/qmc/solutions/mao-kexiang-121/README.md create mode 100644 tracks/qmc/solutions/mao-kexiang-121/finite_density_extension.md create mode 100644 tracks/qmc/solutions/mao-kexiang-121/main_theorem.md create mode 100644 tracks/qmc/solutions/mao-kexiang-121/novelty_audit.md create mode 100644 tracks/qmc/solutions/mao-kexiang-121/physical_realization.md create mode 100644 tracks/qmc/solutions/mao-kexiang-121/reduction_checklist.md create mode 100644 tracks/qmc/solutions/mao-kexiang-121/requirements.txt create mode 100644 tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py create mode 100644 tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py create mode 100644 tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json diff --git a/tracks/qmc/solutions/mao-kexiang-121/README.md b/tracks/qmc/solutions/mao-kexiang-121/README.md new file mode 100644 index 000000000..86cc6f5d8 --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/README.md @@ -0,0 +1,151 @@ +# Polyhedral and Perron-compound sign-free generator supports + +## Team + +| | | +|---|---| +| **Team name** | Mao-Kexiang | +| **Members** | Kexiang Mao ([@Mao-Kexiang](https://github.com/Mao-Kexiang)) | + +## Challenge + +| Row | | +|---|---| +| **Challenge** | Find structured fermionic Gaussian-vertex sets with det(I + product exp(A_i)) >= 0 beyond the known split-orthogonal and fixed-metric semigroup principles, and map any survivor to an interacting QMC weight. | +| **Catalog issue** | `Addresses #121` — “Sign-problem free hunter,” released by Lei Wang, Institute of Physics, Chinese Academy of Sciences. | +| **Track** | `tracks/qmc/` — from the issue's `Method: Quantum Monte Carlo` field. | + +## Bottom line + +This submission reports **substantial progress toward #121, not a claimed closure of the whole research challenge**. + +The main analytic candidate is an open, two-orbit family of real 3 x 3 generators whose arbitrary positive-time words have positive determinant weights. The supplied support has an exact obstruction to every common quadratic contraction metric and a proof under internal review of nonembedding in one fixed complex-CAR Wei structure. An S3 Fock-space twirl maps the same twelve vertices to an engineered Hermitian interacting Hamiltonian with an exact determinant-valued continuous-time Gaussian-vertex series expansion; this is not a standard auxiliary-field DQMC formulation. + +Two major gaps remain. First, the final A/B family does not yet ship with its own randomized cross-dimension harness, so the survival claim currently rests on the analytic common-norm proof and internal proof audit. Second, the contraction Hamiltonian has a frustration-free vacuum ground state at chemical potential zero, while the finite-occupancy extension factorizes into number-conserving cells with no itinerant intercell hopping. We do not claim a scalable finite-density phase, a production sampler, publication priority, or Hamiltonian-level exclusion of every alternative Hubbard-Stratonovich, fermion-bag, Majorana, Jordan-Wigner, or stoquastic representation. + +## 1. Main theorem candidate + +For epsilon > 0 and kappa > 0, define + +```text +A(epsilon,kappa) = +[ -1-epsilon-kappa 1 -epsilon ] +[ 0 -1-kappa 1 ] +[ 2 0 -2-kappa ] + +S = diag(1,1,-1), B = S A S, +C = S3 orbit of A union S3 orbit of B. +``` + +On the open parameter region + +```text +epsilon > 0, kappa > 0, 40 epsilon + 59 kappa < 2, +``` + +the accompanying proof draft establishes: + +1. Every X in C has logarithmic infinity norm mu_infinity(X) = -kappa. Thus every positive-time word T obeys ||T||_infinity < 1 on the isolated three-mode space and det(I+T) > 0. Embedded local words obey det(I+T) >= 0. +2. No common H > 0 can satisfy X^T H + H X <= 0 for all X in C. At epsilon=1/100 and kappa=1/1000, permutation averaging reduces H to I+r ee^T, while A requires r <= -1541/24791 and B requires r >= 1541/42609. +3. The twelve generators span all of M_3(R); the standard-isotypic minor is 162(2 epsilon^3 + epsilon^2 - 4 epsilon + 3), which is positive in the stated region. +4. For odd one-particle dimension and full span, the number-conserving Nambu support cannot be put into Wei's fixed complex-CAR semigroups without inducing the forbidden common H. A compactness argument also excludes alternate logarithms of this same discrete support for sufficiently small time step. +5. The result is not tied to one decimal matrix. `main_theorem.md` gives a seven-parameter signed directed-triangle design cone with a nonempty open feasible region. + +The determinant proof itself is short: a common induced norm puts every eigenvalue of the real product T in the closed unit disk. Real eigenvalues contribute nonnegative factors 1+lambda, and nonreal conjugate pairs contribute |1+lambda|^2. + +## 2. Interacting physical realization + +For X=A or B, define the three-site Fock-space twirl + +```text +M_X(tau) = (1/6) sum over sigma in S3 of + exp[tau c^dagger (P_sigma X P_sigma^T) c]. +``` + +The exterior-power representations of the natural S3 representation are real and multiplicity-free in every three-mode number sector, so M_X is Hermitian. At the rational interior point and sufficiently small positive tau, both twirls are non-Gaussian and interacting. Their exact local operator content is + +```text +constant + chemical potential + uniform hopping + density interaction ++ correlated hopping + three-body density. +``` + +For positive couplings, overlapping triangular clusters give + +```text +H = - sum over triangles Delta of [g_A M_A,Delta + g_B M_B,Delta]. +``` + +Expanding exp(-beta H) and resolving every twirl insertion into one of the twelve Gaussian orbit vertices gives nonnegative scalar activities and fermion factor det(I + product exp(τ X_j)) >= 0 at arbitrary depth. A sampled orbit vertex need not be Hermitian or a positive operator; Hermiticity belongs to the complete twirl. + +This meets the issue's minimum “route to a physical determinant weight” requirement in the broad sense of an exact grand-canonical Gaussian-vertex series. It is not a standard auxiliary-field DQMC decomposition of a two-body model. At chemical potential zero the vacuum minimizes every positive-coupling contraction term; positive chemical potential leaves the certified cone, and canonical weights are not automatically positive. + +`finite_density_extension.md` develops a Perron-plus-second-compound criterion that permits one expanding positive mode. Its decoupled D4 cell Hamiltonian has a unique one-particle local ground state at mu=0, and the full cell-factorized fermionic expansion has positive grand-canonical determinant weights. The conserved one-particle-per-cell sector carries qutrit compass terms, but projected qutrit weights, an active low-energy qutrit manifold, and itinerant intercell fermion exchange are not proved sign-free. + +## 3. Novelty boundary + +Established ingredients include logarithmic norms, common polyhedral Lyapunov functions, cone-preserving matrices, compound matrices, and group twirling. The candidate contribution is their QMC combination: + +- an explicit nonzero-volume arbitrary-depth determinant-positive vertex family; +- exact separation from every common ellipsoidal contraction certificate; +- a full-span odd-dimensional obstruction for the same support against Wei's fixed complex-CAR classes; +- an interacting Hermitian realization using the original safe vertices; +- a separate Perron-compound route and an exact map of its finite-density limitations. + +A targeted primary-source audit found no direct QMC use of this common-polyhedral construction or the Perron-plus-compound combination. That search is not proof of priority. The real-determinant pseudo-unitary observation in Appendix A of Phys. Rev. X 9, 021022 (2019), the total-positivity route independently submitted in PR #259, and all standard split-orthogonal/Kramers/Majorana/Wei reductions are treated as prior or competing work rather than claimed here. + +The one-dimensional total-nonnegative/Jordan-Wigner route was deliberately excluded from this submission because PR #259 already contains it. See `novelty_audit.md` and `reduction_checklist.md` for the detailed filter. + +## 4. Reproducibility and evidence + +The committed baseline oracle independently constructs the Fock-space lift of c_i^dagger c_j and checks + +```text +Tr_Fock product exp(c^dagger A_i c) = det(I + product exp(A_i)). +``` + +It includes analytic O(1,1), randomized O(n,n) identity-component positive controls, all four O(1,1) components, the exact rational negative certificate det(I+T)=-4/3 in O^{--}, and the four-site Wang et al. 2015 Hubbard/spin-flip construction. + +The code was developed with Python 3.13.9. From the repository root, install the minimal dependencies and run the regression tests with + +```bash +python -m pip install -r tracks/qmc/solutions/mao-kexiang-121/requirements.txt +python -m pytest -q tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py +``` + +These team-local tests are not discovered by the repository's default `make test` target. To reproduce the complete preregistered Wang-2015 baseline of 256 configurations at orders 0 through 8, including three independent 256-dimensional Fock checks, use the committed manifest: + +```bash +run_dir="$(mktemp -d)" +cp tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json "$run_dir/run.json" +python tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py --run-dir "$run_dir" +``` + +Final A/B-specific randomized validation is not yet included; the earlier A/D/F development harness was excluded as superseded. The arbitrary-word A/B statement currently rests on the analytic common-norm proof and the internal proof audit. No new scientific calculation was run merely to prepare this PR. + +## 5. File map + +| File | Role | +|---|---| +| [`main_theorem.md`](main_theorem.md) | Open A/B family, exact no-ellipsoid and full-span certificates, fixed-CAR Wei obstruction, and seven-parameter cone. | +| [`physical_realization.md`](physical_realization.md) | Exact S3-twirl operator classification, correlated-hopping tuning, and three-body/vacuum no-go results. | +| [`finite_density_extension.md`](finite_density_extension.md) | Perron-compound theorem, D4 finite-occupancy construction, and explicit non-itinerant limitation. | +| [`novelty_audit.md`](novelty_audit.md) | Closest primary literature and cautious priority language. | +| [`reduction_checklist.md`](reduction_checklist.md) | Split-orthogonal, Kramers, Majorana, Wei, stoquastic, and physical-realizability novelty filter. | +| [`sign_problem_hunter.py`](sign_problem_hunter.py) | Reproducible split-orthogonal/Wang-2015 determinant and independent Fock oracle. | +| [`test_sign_problem_hunter.py`](test_sign_problem_hunter.py) | Exact and numerical baseline regression tests. | +| [`wang2015_run_template.json`](wang2015_run_template.json) | Path-free manifest for the full 256-configuration baseline. | + +## 6. Honest completion audit against issue #121 + +| Issue requirement | Status | +|---|---| +| Rebuild determinant/Fock oracle with positive and exact negative controls | Substantially complete. | +| Validate the known fixed-metric semigroup cone independently | Incomplete in the committed baseline. | +| Map known literature and run a novelty filter | Substantial targeted internal audit; historical priority remains unproved. | +| New structured support with arbitrary-depth proof | Analytic theorem candidate after internal audit; dedicated A/B randomized harness still missing. | +| Interacting physical determinant weight | Exact for an engineered grand-canonical Gaussian-vertex series; not a standard auxiliary-field DQMC formulation and vacuum-limited. | +| Nontrivial scalable finite-density itinerant model and benchmark | Incomplete. | +| Exclude every alternative positive decomposition of the same Hamiltonian | Incomplete and not claimed. | +| Public MathOverflow/arXiv endgame and external review | Not yet done. | + +For these reasons the PR uses `Addresses #121`, not `Closes #121`. The core matrix question has a serious candidate answer; the strongest physical interpretation of the challenge has not yet been solved. diff --git a/tracks/qmc/solutions/mao-kexiang-121/finite_density_extension.md b/tracks/qmc/solutions/mao-kexiang-121/finite_density_extension.md new file mode 100644 index 000000000..6858b2043 --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/finite_density_extension.md @@ -0,0 +1,524 @@ +# Finite-occupancy cell extension: Perron cones plus compound contraction + +Date: 2026-07-29 + +Status: analytic research note. The determinant theorems, the explicit D4 family, +the local spectra, and the exclusion of a common one-particle indefinite metric are +proved below. The current lattice construction is a grand-canonical, cell-factorized +fermion embedding with no intercell hopping. Positivity after projection to one +particle per cell, equivalence to every possible 6-by-6 Majorana/MTR representation, +and literature priority are not proved. + +## Executive result + +The vacuum no-go is not a theorem about every determinant-positive semigroup. It is +a theorem about semigroups that contract the entire one-particle space. A different +safe mechanism is possible: + +1. every vertex preserves one common proper cone K, so every word has a nonnegative + Perron eigenvalue equal to its spectral radius; +2. the second exterior power of every vertex contracts in one common norm. + +The second condition permits at most one eigenvalue outside the unit disk. The first +condition forces that exceptional eigenvalue, if it exists, to be positive. Hence no +real eigenvalue can cross -1 and every word T obeys det(I+T)>0. + +Unlike an ordinary contraction, a vertex may now have one eigenvalue a>1. A +Hermitian Gaussian vertex can therefore favor a one-particle state over the vacuum. +This gives a genuine algebraic escape from the vacuum no-go. + +An explicit continuous family is + + G_v = b I + (a-b) v v^T, + +with a>1, 0= 0. + +If q<1, the inequality is strict. + +### Proof + +Cone invariance is multiplicatively closed, so T K is a subset of K. The +finite-dimensional Perron-Frobenius/Krein-Rutman theorem says that rho(T) is an +eigenvalue of T and rho(T)>=0. + +The eigenvalues of wedge^2 T are all products lambda_i lambda_j with i=|lambda|>1, while +rho(T) +is also an eigenvalue. Consequently -rho(T)|lambda| is an eigenvalue of wedge^2 T +with magnitude greater than one, contradicting (2). Thus every negative real +eigenvalue lies in [-1,0). Nonreal eigenvalues occur in conjugate pairs, and hence + + det(I+T) + = product_{lambda real}(1+lambda) + product_{Im lambda>0}|1+lambda|^2 + >= 0. + +When q<1, the same argument excludes lambda=-1, proving strict positivity. + +This proof permits arbitrarily large positive Perron eigenvalues. It controls only +the product of any two eigenvalues, not the largest one-particle eigenvalue. + +### A bounded positive-fugacity window + +If q<1 and the word is nonempty, any negative real eigenvalue lambda satisfies + + |lambda| rho(T) <= q^m, rho(T)>=|lambda|, + +so + + |lambda| <= q^(m/2) <= sqrt(q). + +It follows that + + det(I+zT)>0 for 0<=z<1/sqrt(q). + +This allows a finite z>1 window. It does not allow a fixed positive chemical +potential for all inverse temperatures, because z=exp(beta mu) is unbounded as +beta tends to infinity. + +## 2. Exact D4 polyhedral family + +Work in R^3 with basis e0,e1,e2 and the square cone + + K_square = {x : x0>=|x1| and x0>=|x2|}. + +Its dual cone is + + K_square^* = {y : y0>=|y1|+|y2|}. + +Every vector in V_D4 belongs to both K_square and K_square^*. Therefore, for x in +K_square, + + G_v x = b x + (a-b) v (v^T x) + +is a positive linear combination of two vectors in K_square. Hence every G_v +preserves K_square. + +The square cone has four extreme rays, whereas a three-dimensional simplicial cone +such as the nonnegative orthant has only three. An invertible linear map preserves +the number of extreme rays. This certificate is therefore not entrywise +nonnegativity hidden by a change of one-particle basis. + +Each G_v is real symmetric positive definite, with eigenvalues + + a along v, b,b on v^perp. + +Its two largest singular values are a and b, so the Euclidean compound norm is + + ||wedge^2 G_v||_2 = ab. + +Thus every a>1, 00. + +The construction also works for any collection of unit vectors contained in +K intersection K^*, provided the same a,b obey ab<1. It is therefore a continuous +geometric family rather than four special matrices. + +## 3. Exact exclusion of a common one-particle indefinite metric + +The full D4 family admits no nonzero Hermitian matrix eta satisfying either + + G_v^dagger eta G_v - eta <= 0 (3) + +for all v, or the reversed inequality for all v. This excludes every ordinary +one-particle contraction or expansion semigroup based on a fixed nondegenerate +quadratic metric, including indefinite metrics. + +### Proof for (3) + +Every v in V_D4 has an orthogonal partner w in V_D4. For example, + + (e0+e1)/sqrt(2) is orthogonal to (e0-e1)/sqrt(2). + +The vector w has eigenvalue b under G_v and eigenvalue a under G_w. Evaluating the +two negative-semidefinite inequalities on w gives + + (b^2-1) w^dagger eta w <= 0 implies w^dagger eta w >=0, + (a^2-1) w^dagger eta w <= 0 implies w^dagger eta w <=0. + +Therefore w^dagger eta w=0. The same holds for every v in V_D4. + +Set Q_v=G_v^dagger eta G_v-eta. Since Q_v<=0 and + + v^dagger Q_v v=(a^2-1)v^dagger eta v=0, + +negative semidefiniteness implies Q_v v=0. For any u perpendicular to v, + + u^dagger Q_v v=(ab-1)u^dagger eta v=0. + +Because ab is not one, eta v=0. Three vectors in V_D4 are linearly independent, +so eta=0. This contradicts the nondegeneracy required of a metric. + +The reversed semidefinite inequality gives the same conclusion with all intermediate +signs reversed. + +Since + + log G_v = (log b) I + log(a/b) v v^T, + +a common generator inequality + + (log G_v)^dagger eta + eta log G_v <= 0 + +would exponentiate to (3). It is therefore excluded as well. + +### Exclusion of the same-support Wei/Majorana fixed-metric representation + +The four principal logs have a four-dimensional linear span, not the full +six-dimensional space of real symmetric 3-by-3 matrices. Their generated Lie +algebra is nevertheless all of gl(3,R). + +Indeed, differences of opposite orbit elements give + + X_01=E_01+E_10, X_02=E_02+E_20. + +Their sums give two inequivalent diagonal directions. Commuting those diagonals +with X_01 and X_02 generates the skew 01 and 02 matrices, while +[X_01,X_02] gives the skew 12 matrix. Further diagonal commutators give X_12; +the original traceful diagonal plus [X_ij,skew_ij] gives every diagonal. Hence the +full matrix algebra is generated and the common commutant is scalar. + +Consequently the support is irreducible and has no nontrivial common invariant +subspace. A number-conserving complex-CAR Wei/MTR reality operator must lie in this +commutant; in odd one-particle dimension a scalar commutant cannot carry the +required Kramers square -I. The remaining fixed-metric top-block condition would +give a real symmetric H satisfying + + (log G_v)^T H + H log G_v <= 0 + +for every v. Exponentiation gives G_v^T H G_v-H<=0, but the direct proof above +forces H=0. The remaining Majorana block relation in odd dimension then rules out a +nondegenerate fixed metric. Thus this exact log-vertex support is not a disguised +Wei complex-CAR fixed-metric contraction class. + +This is stronger than merely excluding a three-dimensional positive metric. +It does not exclude a different Gaussian/HS decomposition of the same Hamiltonian, +an enlarged or explicitly doubled fermion representation, nonprincipal complex logs, +or a representation not using this fixed vertex support. Those alternatives and +historical priority remain open. + +## 4. Hermitian finite-density local physics + +Define the Fock-space Gaussian vertex + + O_v = Gamma(G_v) = exp[dGamma(log G_v)]. + +Because G_v is symmetric positive definite, O_v is Hermitian positive definite; +no group twirl is required. Its sector maxima are + + N=0 : 1, + N=1 : a, + N=2 : ab, + N=3 : ab^2. + +For a>1>b and ab<1, the unique largest eigenvalue is a in the one-particle state + + |v> = c_v^dagger |0>. + +Consequently -g O_v locally favors exactly one fermion rather than vacuum or full +occupancy. This is the precise step that the common-contraction construction could +not achieve. + +For the equal D4 orbit sum, + + H_cell = -kappa sum_{v in V_D4} O_v, + +the exact largest eigenvalues of the positive orbit sum in each number sector at +a=2,b=1/4 are + + N=0 : 4, + N=1 : 9/2, 11/4, 11/4, + N=2 : 9/8, 25/16, 25/16, + N=3 : 1/2. + +Thus the decoupled H_cell has a unique N=1 ground state e0, separated from the +vacuum by kappa/2. This is a rigorous finite-occupancy local ground state at mu=0. + +## 5. A local lattice model and its exact determinant proof + +Put three fermion orbitals in every cell i and write O_i(v)=Gamma_i(G_v). Allow +onsite orbit sums and bond vertices + + O_i(v) O_j(w) + = Gamma(G_v on cell i direct-sum G_w on cell j). + +A general positive-vertex Hamiltonian is + + H = -sum_i,v h_i,v O_i(v) + -sum_,v,w J_ij,vw O_i(v) O_j(w), + +with h_i,v>=0 and J_ij,vw>=0. + +Every one-particle propagation matrix in the stochastic-series expansion is block +diagonal in the fixed cells. For a configuration C, + + T(C) = direct-sum_i T_i(C), + +where each T_i is a word in the local D4 semigroup. Therefore + + det[I+T(C)] = product_i det[I+T_i(C)] >0. + +This is an all-orders analytic certificate, not a random-word observation. + +On a fixed finite graph, sufficiently weak bond terms compared with the full product +gap preserve the one-fermion-per-cell ground sector. A thermodynamic statement needs +a degree- and coupling-uniform gap bound, which is not supplied here. The conserved +N_i=1 sector is three-dimensional and carries a qutrit representation, but strong +H_cell makes e0 unique; an active low-energy qutrit manifold has not been established. + +### Matched and crossed D4 pairs generate both exchange signs + +Let + + X_01=|e0> -> |110> -> |101> -> |000> + +is a three-edge cycle with positive edge-sign product. A diagonal sign gauge that +made every off-diagonal element nonpositive would require the product around an odd +cycle to be negative, which is impossible. Thus this restriction is not Fock-sign- +gauge stoquastic. + +The pure one-color X_01 X_01 model is nevertheless diagonal in the local X_01 +basis and is classically simple. A serious quantum target must use both x and y +bond colors, because X_01 and X_02 do not commute on a shared cell. Whether the full +two-color compass model is curable by a more general local unitary is not yet proved. + +This is the most concrete nontrivial physical target found in this audit. + +## 6. Why the current lattice extension is not yet an itinerant-fermion result + +The determinant proof uses a fixed direct sum of three-orbital cells. It has three +important consequences: + +1. every local particle number N_i is conserved; +2. fermions never exchange between different cells; +3. in the N_i=1 sector the model is exactly a qutrit/spin model. + +Thus the grand-canonical fermion embedding has a strictly positive factorized +determinant expansion, and its conserved N_i=1 sector carries a qutrit Hamiltonian. +It does not follow that the canonically projected qutrit configuration weights are +nonnegative, and the construction does not solve the exchange sign of itinerant +finite-density fermions. + +Allowing one-particle hopping between cells destroys block factorization. A scalable +replacement must control an extensive number of expanding channels without reducing +to a fixed occupied subspace, total nonnegativity, or a Kramers square. + +## 7. General fixed-splitting no-go + +Suppose the one-particle space has one common invariant splitting + + V = V_s direct-sum V_u, + +and every vertex is block diagonal, G=G_s direct-sum G_u, with + + ||G_s||<=1, ||G_u^(-1)||<=1. + +For every word T, + + det(I+T) + = det(I+T_s) det(T_u) det(I+T_u^(-1)). + +The first and third factors are nonnegative. Its sign is sign det(T_u), a product +of one-vertex orientation characters. Choosing the Hamiltonian coefficient signs to +cancel that character gives a sign-free expansion. + +However, fill every orbital in V_u and empty every orbital in V_s. The resulting +Slater determinant is a common eigenstate of every vertex. Exterior-power duality +shows that, after normalization by |det G_u|, every particle excitation in V_s and +every hole excitation in V_u is contractive. Once the Hermitian physical vertices +are formed, that same Slater determinant minimizes every local Hamiltonian term. + +Therefore every common fixed stable/unstable splitting has a frustration-free Slater +ground state. Special cases are + +- V_u empty: the vacuum no-go; +- V_s empty: the full-filling/inverse-contraction no-go; +- particle-hole doubled blocks: a fixed half-filled Slater reference, usually the + known split-orthogonal, reflection-positive, or Kramers-square route. + +The D4 Perron family escapes this no-go precisely because its expanding Perron line +depends on v; no common unstable linear subspace exists. + +## 8. Exact all-fugacity and canonical criteria + +For one fixed real T, + + p_T(z)=det(I+zT) + +is nonnegative for every z>0 if and only if every distinct negative real eigenvalue +of T has even algebraic multiplicity. Complex pairs contribute positive quadratic +factors, positive real eigenvalues never vanish for z>0, and an odd-multiplicity +negative eigenvalue creates a sign-changing positive root z=-1/lambda. + +Thus positivity at z=1 is much weaker than positivity at arbitrary positive chemical +potential for all beta. A common norm alone cannot provide the latter. + +The fixed-N weight is + + Z_N(T)=Tr(wedge^N T), + +the coefficient of z^N in det(I+zT). Even positivity of p_T(z) for all z>0 does not +imply every coefficient is nonnegative. In the D4 cell construction, projection to +N_i=1 replaces each local grand-canonical determinant by tr(T_i); the +Perron-compound theorem does not prove these traces nonnegative. Canonical +finite-density or direct qutrit QMC therefore needs a separate compound-trace or +cone proof. + +Known easy sufficient mechanisms are: + +- two identical/conjugate flavors: determinant square, already Kramers/MTR; +- total nonnegativity: every principal minor and every Z_N is nonnegative, but the + induced Fock matrices are entrywise nonnegative and -H is stoquastic/Jordan-Wigner + type; +- a common triangular positive-diagonal semigroup: arbitrary-z positivity, but any + Hermitian element in the common flag algebra is simultaneously diagonal/classical. + +## 9. k-expanding hierarchy + +There is an arbitrary-index extension. Let S be a real matrix semigroup. Assume + +1. for every j=1,...,k, wedge^j S preserves a proper cone K_j; +2. one common norm on wedge^(k+1) obeys ||wedge^(k+1)G||<=1 for every generator. + +Then det(I+T)>=0 for every word T. + +To prove it, let r be the number of eigenvalues of T outside the unit disk. The +(k+1)-compound bound gives r<=k. If r>0, the product of all r unstable eigenvalues +is the unique eigenvalue of wedge^r T with maximal modulus. Cone preservation of +wedge^r T forces this product to be positive. Hence the number of negative real +unstable eigenvalues is even; all stable negative eigenvalues give nonnegative +factors 1+lambda. + +The uniqueness statement remains valid for nonnormal matrices, Jordan blocks, +repeated eigenvalues, and equal moduli. Schur triangularization shows that the +compound spectrum consists of products of eigenvalues counted with algebraic +multiplicity. Since r counts every eigenvalue with modulus greater than one, any +different r-element product must replace at least one unstable factor by a factor +of modulus at most one, and therefore has strictly smaller modulus. Complex +unstable eigenvalues enter in conjugate pairs. A boundary eigenvalue lambda=-1 may +make the determinant zero but cannot make it negative. + +This hierarchy can support a local term whose maximum lies in an intermediate +particle sector k. It is not automatically total positivity because the K_j may be +non-simplicial, non-coordinate polyhedral cones. + +For an extensive itinerant density k proportional to volume, however, the number and +dimension of the required exterior cones grow rapidly. The cell-factorized model is +a tensorized shortcut, but it removes intercell fermion exchange. A publishable +itinerant construction needs a local/tensor certificate for this hierarchy or a +word-dependent dominated splitting that remains efficient with system size. + +## 10. Publication assessment + +The result is stronger than the earlier all-contraction candidate: + +- it genuinely evades the vacuum no-go; +- it is a continuous parameter family; +- its local terms are Hermitian without twirling; +- its decoupled cell Hamiltonian has a unique N=1 local ground state at mu=0; +- it has no common one-particle positive or indefinite quadratic metric. + +It is not yet a publication-ready condensed-matter result: + +- common invariant cones, Perron semigroups, compound contractions, and dominated + splittings are established mathematics; +- a hidden alternative Majorana/MTR or positive Gaussian decomposition of the same + Hamiltonian has not been excluded; +- the scalable model has fixed cells and no intercell fermion exchange; +- no phase diagram, critical point, or algorithmic benchmark has been produced. + +Current rating: a credible research lemma and a promising construction principle, +not yet a PRB claim. It could become publishable if either + +1. the D4 family is excluded from alternative Majorana/MTR/Wei decompositions and + yields a two-color nonstoquastic qutrit model with a useful QMC algorithm; or +2. the cone-compound hierarchy is extended to local itinerant hopping at extensive + density and produces new finite-density physics. + +A PRB or SciPost-level paper would need a scalable algorithm, a physically motivated +model, a novelty audit against alternative decompositions, and a nontrivial phase or +critical point. A broad one-flavor itinerant finite-density class could be PRL-level. + +## 11. Literature anchors + +- Z.-C. Wei, Semigroup approach to the sign problem in quantum Monte Carlo + simulations, Phys. Rev. B 110, 075146 (2024): + https://doi.org/10.1103/PhysRevB.110.075146 +- V. Yu. Protasov, Perron matrix semigroups (2025): + https://arxiv.org/abs/2502.10571 +- R. Alseidi, M. Margaliot, and J. Garloff, Discrete-time k-positive linear + systems, IEEE Trans. Autom. Control 66, 399-405 (2021): + https://doi.org/10.1109/TAC.2020.2987285 +- E. Weiss and M. Margaliot, A generalization of linear positive systems with + applications to nonlinear systems (2019): + https://arxiv.org/abs/1902.01630 +- L. Wang et al., Split orthogonal group: a guiding principle for sign-problem-free + fermionic simulations, Phys. Rev. Lett. 115, 250601 (2015): + https://doi.org/10.1103/PhysRevLett.115.250601 + +No searched QMC source was found that combines a proper Perron cone with a strict +second-compound contraction to certify det(I+word)>=0. This is a negative search +result, not a proof of priority. diff --git a/tracks/qmc/solutions/mao-kexiang-121/main_theorem.md b/tracks/qmc/solutions/mao-kexiang-121/main_theorem.md new file mode 100644 index 000000000..8fa2da9de --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/main_theorem.md @@ -0,0 +1,672 @@ +# An open polyhedral determinant-positive family beyond the fixed Wei semigroups + +Date: 2026-07-29 + +Status: analytic theorem draft under internal referee audit. The algebraic separation +from Wei 2024 is a vertex-support statement. Literature priority and exclusion of +alternative positive decompositions of the same many-body Hamiltonian are not +claimed. + +## 1. Executive theorem + +For epsilon>0 and kappa>0 define + + A = [ -1-epsilon-kappa 1 -epsilon ] + [ 0 -1-kappa 1 ] + [ 2 0 -2-kappa ] + + S = diag(1,1,-1), B = S A S, + +and let C(epsilon,kappa) be the union of the two S3 conjugacy orbits of A +and B. Throughout the open triangle + + epsilon>0, kappa>0, 40 epsilon + 59 kappa < 2, (R) + +the following statements hold. + +1. Every X in C has mu_infinity(X)=-kappa. Hence every positive-time word + + T = exp(t_m X_m) ... exp(t_1 X_1) + + is a real contraction in one common polyhedral norm and obeys + det(I+T)>0 on the isolated three-mode space. Embedded local words obey + det(I+T)>=0. +2. C has no common H>0 satisfying X^T H+H X<=0 for every X in C. +3. C real-linearly spans all of M_3(R). +4. The number-conserving Nambu lifts of C cannot satisfy Eqs. (2)-(3) of + Wei, Phys. Rev. B 110, 075146 (2024), after any one fixed complex + orthogonal CAR basis transformation. +5. The two S3 Fock twirls are Hermitian. At epsilon=1/100, + kappa=1/1000 they are interacting and non-Gaussian for all sufficiently + small positive tau; this persists on an open parameter neighborhood. + +The decimal-looking matrix is therefore one convenient rational interior point, +not an isolated or fitted solution. + +## 2. Common polyhedral contraction + +Each row of A has diagonal entry equal to minus its absolute off-diagonal row sum, +followed by the strict shift -kappa I. Therefore + + mu_infinity(A) + = max_i [A_ii + sum_(j!=i) |A_ij|] + = -kappa. + +Permutation matrices and S are infinity-norm isometries, so the same equality holds +for all twelve generators. Submultiplicativity gives + + ||T||_infinity <= exp[-kappa sum_j t_j] < 1. + +Every real eigenvalue of T lies in (-1,1), while nonreal eigenvalues occur in +conjugate pairs. Hence + + det(I+T) + = product_(lambda real) (1+lambda) + product_(Im lambda>0) |1+lambda|^2 + > 0. + +The opposite-sign directed pair A_13 A_31=-2 epsilon<0 is invariant under a +diagonal site-sign gauge. Thus the family is not made Metzler by such a gauge. + +## 3. Exact exclusion of every common ellipsoid + +Assume that H>0 satisfies + + X^T H+H X<=0 + +for every X in C(epsilon,kappa). For each permutation matrix Pi define + + H_bar = (1/6) sum_(Pi in S3) Pi^T H Pi. + +The family C(epsilon,kappa) is closed under permutation conjugation. Therefore, +for every X in C(epsilon,kappa), + + X^T H_bar+H_bar X + = (1/6) sum_Pi Pi^T + [(Pi X Pi^T)^T H+H(Pi X Pi^T)] + Pi + <= 0. + +Moreover H_bar>0. Since H_bar commutes with the natural permutation +representation, there are real alpha,beta such that + + H_bar = alpha I + beta ee^T, + e=(1,1,1)^T. + +Its restriction to e^perp is alpha I, so positivity gives alpha>0. After division +by alpha we may consequently write + + H_r = I+r ee^T, r=beta/alpha, r>-1/3. + +Set + + x=(1,1,3/5)^T, y=Sx=(1,1,-3/5)^T. + +The A inequality must hold on x, whereas the B=SAS inequality must hold on y. +Direct calculation gives + + x^T(A^T H_r+H_r A)x + = (2/25) [ + 2-40 epsilon-59 kappa + +13 r(2-8 epsilon-13 kappa) + ], + +and + + y^T(B^T H_r+H_r B)y + = (2/25) [ + 2-40 epsilon-59 kappa + -7 r(6+8 epsilon+7 kappa) + ]. + +Condition (R) implies + + 2-40 epsilon-59 kappa>0, + 2-8 epsilon-13 kappa>0, + 6+8 epsilon+7 kappa>0. + +The first quadratic-form inequality therefore requires + + r <= -(2-40 epsilon-59 kappa) + / [13(2-8 epsilon-13 kappa)] < 0, (A-bound) + +whereas the second requires + + r >= (2-40 epsilon-59 kappa) + / [7(6+8 epsilon+7 kappa)] > 0. (B-bound) + +The two necessary conditions are incompatible. Hence no common positive-definite +H exists. At epsilon=1/100 and kappa=1/1000 the two bounds are + + r <= -1541/24791, r >= 1541/42609. + +## 4. Exact full-span certificate + +Let + + E=span{e}, V=e^perp, + Q=ee^T/3, P=I-Q. + +The natural permutation representation is E direct-sum V, where E is trivial and +V is the two-dimensional standard representation. Consequently, under conjugation +by S3, + + M_3(R) + = Hom(E,E) direct-sum Hom(V,E) direct-sum Hom(E,V) + direct-sum End(V) + = 2 trivial + sign + 3 standard. + +We now give explicit coordinates on the three standard copies. Define + + u(X)=P X e, + v(X)=P X^T e, + w(X)=P diag(P X P), + +and + + Phi(X)=(u(X),v(X),w(X)) in V direct-sum V direct-sum V. + +For every permutation matrix Pi, P commutes with Pi, Pi e=e, and + + diag(Pi Y Pi^T)=Pi diag(Y). + +It follows that + + Phi(Pi X Pi^T)=Pi Phi(X), + +with Pi acting on each of the three V factors. Thus Phi is equivariant. + +The restriction of Phi to the standard isotypic component is an isomorphism. +Indeed, on Hom(E,V), every matrix has the form + + X=u e^T/3, u in V, + +and Phi(X)=(u,0,0). Similarly, on Hom(V,E), every matrix has the form + + X=e v^T/3, v in V, + +and Phi(X)=(0,v,0). + +The remaining standard copy is the space + + Sym_0(V) + ={Y:Y^T=Y, Ye=0, tr Y=0} + +inside End(V). For Y in Sym_0(V), PYP=Y and diag(Y) lies in V, so + + w(Y)=diag(Y). + +This map is invertible. Explicitly, if d=(d_1,d_2,d_3)^T lies in V, then + + Y(d) = + [ d_1 d_3 d_2 ] + [ d_3 d_2 d_1 ] + [ d_2 d_1 d_3 ] + +is symmetric, has zero row sums and zero trace, and satisfies diag(Y(d))=d. +Therefore Phi maps the three standard summands isomorphically onto V^3. Its +kernel is precisely the sum of the two trivial copies and the sign copy. + +Write the three standard coordinates as the columns of + + R(X)=[u(X) v(X) w(X)], + +and denote its i-th site row by + + r_i(X)=(u_i(X),v_i(X),w_i(X)). + +Every column of R(X) belongs to V, hence + + r_1(X)+r_2(X)+r_3(X)=0. + +The multiplicity space generated by the permutation orbit of a collection of +matrices is the linear span of all of their site rows. To see this directly, +identify V^3 with V tensor R^3. The restrictions to V of the four group elements + + I, (12), (23), (12)(23) + +are linearly independent in End(V). For example, in the basis + + (1,-1,0)^T, (1,1,-2)^T + +their matrices are + + [ 1 0 ] [ -1 0 ] [ 1/2 3/2 ] [ -1/2 -3/2 ] + [ 0 1 ], [ 0 1 ], [ 1/2 -1/2 ], [ 1/2 -1/2 ], + +respectively. Hence the real span of the S3 action on V is all of End(V). +For a tensor R in V tensor R^3, applying End(V) to its V factor generates +V tensor M_R, where M_R is the span of its site rows. For several seed tensors, +the generated multiplicity space is the span of all of their site rows. + +For the present A and B, direct evaluation gives + + 9 r_1(A)=(-12 epsilon, 9-3 epsilon, -epsilon), + 9 r_2(A)=( 6 epsilon, 6 epsilon, 3-epsilon), + 9 r_1(B)=( 18, -9-9 epsilon, -3 epsilon). + +Thus these three site rows span the full three-dimensional multiplicity space +whenever + + det [ + -12 epsilon 9-3 epsilon -epsilon + 6 epsilon 6 epsilon 3-epsilon + 18 -9-9 epsilon -3 epsilon + ] + =162(2 epsilon^3+epsilon^2-4 epsilon+3) + +is nonzero. If + + f(epsilon)=2 epsilon^3+epsilon^2-4 epsilon+3, + +then + + f'(epsilon)=2(3 epsilon-2)(epsilon+1). + +The only stationary point on epsilon>=0 is epsilon=2/3, where + + f(2/3)=37/27>0. + +It is the global minimum on the nonnegative half-line. Hence all three standard +copies, of total dimension six, occur in the orbit span. + +For completeness, define the sign coordinate + + chi(X) + =(X_12-X_21)+(X_23-X_32)+(X_31-X_13). + +Permutation conjugation gives + + chi(Pi X Pi^T)=sgn(Pi) chi(X), + +so chi detects the one-dimensional sign summand. For A, + + chi(A)=4+epsilon != 0, + +and the sign summand is therefore present. + +Finally, tr X and e^T X e are independent coordinates on the two trivial +summands. Their values on A and B have rank two because + + tr A=tr B=-4-epsilon-3 kappa != 0, + +while + + e^T B e-e^T A e=-6+2 epsilon != 0 + +throughout (R). The orbit span consequently contains two trivial dimensions, +one sign dimension, and six standard dimensions. Their dimensions add to + + 2+1+3*2=9. + +Therefore the two original S3 orbits span all of M_3(R). No larger signed orbit +is required. + +## 5. Odd-dimensional obstruction to the Wei 2024 classes + +### 5.1 General lemma + +Let F be a real family in M_n(R), with n odd. Assume every X in F is Hurwitz, +span_R F=M_n(R), and there is no H>0 satisfying + + X^T H+H X<=0 (Q) + +for all X. Then the number-conserving Nambu lifts of F do not satisfy Wei's +Eqs. (2)-(3) for one fixed pair J1,J2, even after an arbitrary fixed +complex-orthogonal CAR basis change. + +### 5.2 Nambu setup and reality rigidity + +Let zeta=sqrt(2)(c,c^dagger)^T. Its CAR bilinear form and number-conserving +action generator are + + B_CAR = [ 0 I ], + [ I 0 ] + + D_X = diag(X,-X^T). + +Then D_X^T B_CAR+B_CAR D_X=0. The ordinary skew-symmetric coefficient of the +quadratic form is K_X=B_CAR D_X, not D_X itself, and + + (1/4) zeta^T K_X zeta = c^dagger X c - (1/2) tr X. + +Let W be the one fixed complex CAR basis transformation in a hypothetical Wei +representation. Pull its reality operation and Hermitian contraction form back by +W to the original Nambu coordinates. The first Wei condition then defines an +antilinear CAR isometry + + Theta_1=U K, Theta_1^2=+I or -I, + +that commutes with every D_X. This reality equality is real-linear in X. Since +span_R F=M_n(R), it extends from X in F to D_Y for every Y in M_n(R), in +particular to Y=I. + +Write U in particle-hole blocks. Commutation with + + D_I=diag(I,-I) + +kills the off-diagonal blocks. Commutation with all D_Y then gives + + U=diag(alpha I,delta I). + +CAR preservation gives alpha delta=1, whereas + + U conjugate(U)=diag(|alpha|^2 I,|delta|^2 I). + +Thus Theta_1^2=-I is impossible. A CAR-preserving phase gauge commuting with every +D_X makes Theta_1=K. Full span has removed any hidden Kramers partner. + +### 5.3 The contraction structure forces a common H>0 + +In a canonical Majorana frame let eta_0=iJ2. After pulling both Hermitian forms +back by the same CAR transformation, define + + G = U^T B_CAR, + eta = pulled-back eta_0. + +Equivalently G is the congruence transform of J1. Anticommutation of J1 and J2 +gives the coordinate-independent identity + + eta G^(-1) eta = -G. (C) + +The other compatibility relation is + + U^dagger eta U = conjugate(eta). + +The phase gauge above makes U=I, so G=B_CAR and eta=conjugate(eta). Since eta is +Hermitian, it is real symmetric. Equation (C) therefore becomes + + eta B_CAR eta = -B_CAR. (CAR) + +Write + + eta = [ H R ] + [ R^T K ]. + +Wei's LMI pulls back to D_X^T eta+eta D_X<=0. Its particle-particle principal block +is (Q). For a fixed Hurwitz X define Q_X=-(X^T H+H X)>=0. Then + + H = integral_0^infinity exp(X^T t) Q_X exp(X t) dt >= 0. + +If z is in ker H, then z^T Q_X z=0, hence Q_X z=0 and H X z=0. Therefore ker H is +invariant under every X. Full span leaves only ker H={0} or all of R^n, so H>0 or +H=0. + +If H=0, the upper-right block of (CAR) requires R^2=-I_n. This is impossible for +odd n over the reals because det(R)^2=det(-I_n)=-1. Consequently H>0, contradicting +the hypothesis. This proves the lemma. + +Every X in C(epsilon,kappa) is Hurwitz, and Sections 3-4 give the other hypotheses. +For every parameter point in (R), the supplied natural Nambu generator support +therefore lies outside both fixed-metric sufficient classes of Wei 2024, including +the complex-orthogonal Majorana extension stated after Eq. (3). + +This statement concerns the supplied Gaussian vertex support and its natural +principal logarithms. It does not prove that the resulting Hamiltonian has no +different Hubbard-Stratonovich, fermion-bag, or other positive decomposition. + +### 5.4 Small-time robustness against alternate logarithms + +The discrete vertices satisfy a stronger local statement. There is a tau_0>0 +such that, for every 00 such that, for every X in C(epsilon,kappa) and +0=0. + +Iteration of this identity gives + + H_m + =sum_(k=0)^(N-1) + (E_(X,m)^T)^k Q_(X,m) E_(X,m)^k + +(E_(X,m)^T)^N H_m E_(X,m)^N. + +The last term tends to zero as N tends to infinity. Consequently + + H_m + =sum_(k=0)^infinity + (E_(X,m)^T)^k Q_(X,m) E_(X,m)^k + >=0. (PSD) + +Moreover H_m cannot vanish. If H_m=0, the upper-right block of (CAR-m) would give + + R_m^2=-I_3, + +which is impossible over the reals because + + det(R_m)^2=det(-I_3)=-1. + +Thus H_m is a nonzero positive-semidefinite matrix. Define + + H_hat_m=H_m/tr(H_m). + +This normalization need not be extended to eta_m; it is used only in the homogeneous +particle-block inequality (D). We have + + H_hat_m>=0, tr(H_hat_m)=1, + +and the set of such matrices is compact. After passing to a subsequence, + + H_hat_m -> H_* + +for some H_*>=0 with tr(H_*)=1. + +For each fixed X, expansion of E_(X,m) in (D) gives + + E_(X,m)^T H_hat_m E_(X,m)-H_hat_m + =tau_m(X^T H_hat_m+H_hat_m X)+O(tau_m^2). + +The remainder is uniform along the sequence because the family is finite and +the normalized positive-semidefinite matrices have bounded norm. Divide by +tau_m and take the limit. The cone of negative-semidefinite matrices is closed, +so + + X^T H_*+H_* X<=0 (Q*) + +for every X in C(epsilon,kappa). + +It remains only to check that H_* is positive definite rather than merely +semidefinite. If z lies in ker(H_*), let + + Q_X=-(X^T H_*+H_* X)>=0. + +Then z^T Q_X z=0, and positivity of Q_X implies Q_X z=0. Since H_* z=0, this +identity reduces to + + H_* X z=0. + +Thus ker(H_*) is invariant under every X in C(epsilon,kappa), and hence under +their real linear span M_3(R). The only subspaces invariant under all of M_3(R) +are {0} and R^3. Because tr(H_*)=1, its kernel is not all of R^3. Therefore + + H_*>0. + +Equation (Q*) now contradicts the exact no-common-H result of Section 3. This +proves the existence of tau_0. + +The physical twirl may be chosen with tau smaller than both this tau_0 and the +open small-tau interval where its interacting non-Gaussian invariants remain +nonzero. The argument concerns alternate logarithms of the same finite CAR group +support. It does not exclude a different Gaussian support, a different +Hubbard-Stratonovich transformation, or a different many-body decomposition. + +## 6. A wider seven-parameter design cone + +Let a,b,c,d,delta_1,delta_2,delta_3 all be positive and set + + A(theta) = [ -a-b-delta_1 a -b ] + [ 0 -c-delta_2 c ] + [ d 0 -d-delta_3 ] + + B(theta)=S A(theta) S. + +Every row has logarithmic infinity rate -delta_i. Fix any t in (0,1) and define + + G_t(theta) + = d t(1-t) - b(1+t) - c(1-t) + - delta_1 - delta_2 - delta_3 t^2. + +If G_t(theta)>0, the same averaging proof excludes every common H>0. For +x=(1,1,t), the A and B inequalities are + + G_t + r p_t <= 0, + G_t - r q_t <= 0, + +where + + p_t=(2+t)[(1-t)(d-c)-b(1+t)-delta_1-delta_2-delta_3 t] > 0, + q_t=(2-t)[(1-t)(c+d)+b(1+t)+delta_1+delta_2-delta_3 t] > 0. + +They require r<0 and r>0. Multiplying by q_t and p_t and adding gives the exact +Farkas contradiction + + (p_t+q_t) G_t <= 0. + +For fixed rational t these are rational linear inequalities. G_t>0 is a nonempty +open convex cone; removing overall scale leaves six essential continuous parameters. +At the original point and t=3/4, + + G_t=1679/16000, + p_t=10109/16000, + q_t=15375/16000. + +Full span and non-Gaussian interaction are open algebraic conditions and hold at +this point. Their intersection with G_t>0 contains an open neighborhood. + +## 7. Physical realization by two interacting S3 twirls + +For X=A or B define + + M_X(tau) = (1/6) sum_(sigma in S3) + exp[tau c^dagger (P_sigma X P_sigma^T) c]. + +Within each particle-number sector the exterior-power representation of S3 is real +and multiplicity-free. Group averaging makes M_X Hermitian. Generically it is not a +Gaussian operator: the average contains genuine many-body interactions. + +For positive g_A,g_B, sums of local copies on overlapping triangular clusters, + + H = -sum_Delta [g_A M_(A,Delta)+g_B M_(B,Delta)], + +admit an exact determinant-valued continuous-time Gaussian-vertex series expansion. +Expanding exp(-beta H) and then resolving each twirl insertion selects one of the +twelve Gaussian generators with a nonnegative scalar activity. The individual +Gaussian vertices need not be Hermitian or positive operators; only the complete +twirl is Hermitian. The Fock trace for every sequence is + + det[I + product_j exp(t_j X_j)] >= 0. + +This is an engineered interacting Hamiltonian with an exact sign-free series +expansion, not a standard auxiliary-field DQMC decomposition of a two-body Hubbard +Hamiltonian. No sampler, estimator, or scaling benchmark is claimed. + +At the rational point, exact small-tau invariants for both twirls are nonzero, so +both are interacting and non-Gaussian on an open neighborhood. Determinant +positivity holds at arbitrary word depth, not merely over a sampled range. + +## 8. Novelty boundary and publication position + +Established ingredients include logarithmic norms, common polyhedral Lyapunov +functions, contraction semigroups, and group twirling. The theorem candidate is the +combination of: + +- an explicit nonzero-volume QMC vertex family certified by a common polyhedral norm; +- exact failure of all common ellipsoidal metrics; +- a full-span odd-dimensional obstruction separating the same support from Wei 2024 + even under fixed complex CAR basis changes; +- a Hermitian interacting realization using only the original twelve vertices. + +Current limitations are equally important: + +- this positive-coupling twirled-contraction Hamiltonian has a vacuum ground-state + no-go at mu=0; +- Hamiltonian-level inequivalence to every alternative positive decomposition is + not proved; +- absence in a literature search cannot establish priority; +- a dedicated final-family harness and external proof review are still missing. + +After those checks, the result may support a short mathematical-physics note or a +rigorous progress report on challenge issue 121. The current package is not yet a +publication-ready condensed-matter result. + +The separate Perron-plus-second-compound construction in +`finite_density_extension.md` escapes the vacuum no-go locally, but its current +grand-canonical lattice realization is cell-factorized and conserves particle +number in every cell. Its one-particle-per-cell sector carries qutrit compass terms, +but projected qutrit positivity and itinerant intercell exchange are not proved. diff --git a/tracks/qmc/solutions/mao-kexiang-121/novelty_audit.md b/tracks/qmc/solutions/mao-kexiang-121/novelty_audit.md new file mode 100644 index 000000000..c2cbcf29c --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/novelty_audit.md @@ -0,0 +1,139 @@ +# Targeted novelty and priority audit for the polyhedral and Perron-compound criteria + +Date: 2026-07-29 + +Status: targeted primary-source search, not a proof of priority. No claim below is +based merely on the absence of a search hit. + +## 1. Search outcome + +The targeted search found no QMC paper that directly uses either + +1. a common l_infinity or general polyhedral/Banach contraction to prove + det(I+word)>=0 for arbitrary auxiliary-field words; or +2. a common proper Perron cone together with strict second-compound contraction to + prove det(I+word)>=0 while allowing one expanding one-particle mode. + +It also found no direct occurrence of the complete combination + + two S3 orbits + open parameter family + exact no-common-quadratic witness + + odd-dimensional full-span complex-CAR obstruction + interacting Fock twirl. + +These are negative targeted-search results, not exhaustive historical proofs. + +## 2. Closest QMC sources + +1. Z.-C. Wei, Semigroup approach to the sign problem in quantum Monte Carlo + simulations, Phys. Rev. B 110, 075146 (2024): + https://doi.org/10.1103/PhysRevB.110.075146 + + This is the fixed Hermitian indefinite-metric framework, including its stated + complex-orthogonal Majorana extension. The odd-n/full-span theorem in + `main_theorem.md` separates the supplied support from these + sufficient classes, not from every possible positive decomposition. + +2. L. Wang et al., Split orthogonal group: a guiding principle for sign-problem-free + fermionic simulations, Phys. Rev. Lett. 115, 250601 (2015): + https://arxiv.org/abs/1506.05349 + +3. Z.-C. Wei et al., Majorana positivity and the fermion sign problem, Phys. Rev. + Lett. 116, 250601 (2016): + https://arxiv.org/abs/1601.01994 + +4. Z.-X. Li, Y.-F. Jiang, and H. Yao, Majorana-time-reversal symmetries, Phys. Rev. + Lett. 117, 267002 (2016): + https://arxiv.org/abs/1601.05780 + +Items 2-4 are the principal group, reflection-positivity, and MTR baselines. + +5. X.-Y. Xu et al., Monte Carlo study of lattice compact quantum electrodynamics + with fermionic matter, Phys. Rev. X 9, 021022 (2019), Appendix A: + https://arxiv.org/abs/1807.07574 + + The appendix gives the pseudo-unitary SU(n,n) route constraining the determinant + to be real. It is prior art for complex pseudo-unitary phase constraints, not the + common-polyhedral real A/B positivity mechanism claimed here. + +6. Contemporary challenge PR #259 proves a tridiagonal Metzler/total-nonnegative + route and maps it to one-dimensional noncrossing/Jordan-Wigner physics: + https://github.com/QuantumBFS/quantum.harness/pull/259 + + That independently submitted route overlaps the exploratory + `total_nonnegative_semigroup` direction and is excluded from this package. It + does not use the signed A/B polyhedral family or the Perron-plus-compound + orientation criterion. + +## 3. Closest control and matrix sources + +1. F. Blanchini, Nonquadratic Lyapunov functions for robust control, Automatica 31, + 451-461 (1995): + https://doi.org/10.1016/0005-1098(94)00133-4 + +2. T. V. Nguyen et al., Relations between common quadratic Lyapunov functions and + common infinity-norm Lyapunov functions, Trans. SICE 40, 1067-1069 (2004), and + the discrete-time counterpart: + https://doi.org/10.1093/ietfec/e89-a.6.1794 + +3. P. Mason, Y. Chitour, and M. Sigalotti, On universal classes of Lyapunov + functions for linear switched systems, Automatica 155, 111155 (2023): + https://doi.org/10.1016/j.automatica.2023.111155 + +These sources make clear that polyhedral common Lyapunov functions and stable +switched families without a common quadratic metric are established control theory. +The bare l_infinity cone is not new mathematics. + +4. V. Yu. Protasov, Perron matrix semigroups (2025/2026): + https://arxiv.org/abs/2502.10571 + +5. O. Y. Kushel, Cone-theoretic generalization of total positivity, Linear Algebra + Appl. 436, 537-560 (2012): + https://arxiv.org/abs/1301.3731 + +6. C. Wu, I. Kanevskiy, and M. Margaliot, k-contraction: theory and applications, + Automatica 136, 110048 (2022): + https://arxiv.org/abs/2008.10321 + +7. F. Forni and R. Sepulchre, Differential dissipativity theory for dominance + analysis, IEEE Trans. Autom. Control 64, 2340-2351 (2019): + https://arxiv.org/abs/1710.01721 + +These are the closest ingredients for the Perron-compound direction. None of the +searched sources combines proper-cone Perron orientation with an absolute +second-compound bound for fermion determinant positivity. + +## 4. Defensible novelty statements + +For the polyhedral family: + +> We give an explicit open sign-free generator-support family certified by a +> non-Hilbert common norm and prove that, at generator level and for sufficiently +> small discrete time steps, it is not embeddable in Wei's fixed-metric complex-CAR +> semigroups. + +For the finite-density direction: + +> We introduce a Perron-compound positivity criterion: common proper-cone +> preservation fixes the orientation of the only allowed expanding mode, while a +> common second-compound contraction prevents any second unstable mode. + +Do not claim a new Lie group, a new theory of polyhedral Lyapunov functions, or a +Hamiltonian intrinsically beyond every HS, fermion-bag, Jordan-Wigner, stoquastic, +or other representation. + +## 5. Publication assessment + +The current package has potential as the basis of a mathematical-physics or +QMC-method note, but it is not publication-ready. The potentially publishable core +would combine: + +- an open arbitrary-depth determinant theorem; +- exact separation from common ellipsoids and a support-level argument against one + fixed complex-CAR Wei structure; +- an engineered interacting Hermitian two-twirl realization; +- a distinct Perron-compound theorem and exact no-go statements mapping its limits. + +Before an external preprint claim, the package still needs a dedicated A/B harness, +independent expert checking of the fixed-CAR proof, a more systematic priority +audit, and a sharper physical target. A condensed-matter venue would additionally +need a scalable intercell-hopping construction, a nontrivial phase or critical +point, and an algorithmic benchmark. diff --git a/tracks/qmc/solutions/mao-kexiang-121/physical_realization.md b/tracks/qmc/solutions/mao-kexiang-121/physical_realization.md new file mode 100644 index 000000000..25a4c6683 --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/physical_realization.md @@ -0,0 +1,161 @@ +# Physical classification and no-go results for the S3 twirl + +Date: 2026-07-29 + +Status: analytic companion note. No new numerical computation is used. + +## Why the complete S3 twirl is Hermitian + +Let rho_N be the S3 action in the N-particle sector. Restricting the Fock twirl to +that sector gives + + M_X^(N) + =(1/6) sum_(sigma in S3) + rho_N(sigma) (wedge^N exp(tau X)) rho_N(sigma)^(-1). + +Therefore M_X^(N) commutes with rho_N(S3). For N=0,1,2,3 the representations are, +respectively, + + trivial, + trivial direct-sum standard, + sign direct-sum standard, + sign. + +Every summand is of real type and occurs with multiplicity one. By Schur's lemma, +the group average acts as a real scalar on each irreducible block. It is therefore +Hermitian in the standard Fock inner product. A single sampled Gaussian orbit +vertex need not be Hermitian; Hermiticity appears only after the complete six-term +twirl. + +## 1. Complete local operator basis + +For three spinless modes, the S3 representations in fixed number sectors are + + N=0: trivial, + N=1: trivial + standard, + N=2: sign + standard, + N=3: sign. + +A Hermitian, number-conserving S3 scalar therefore has six real sector eigenvalues + + e_0, e_u, e_s, e_2sign, e_2std, e_3. + +Define + + N = sum_i n_i, + K = sum_(i!=j) c_i^dagger c_j, + Q_2 = sum_(i0. Similarity of A +and B implies that their determinants are identical. Hence every positive mixture +has + + W_h=(g_A+g_B) det(I-exp(tau A)) > 0. + +The three-body repulsion cannot be cancelled with positive safe coefficients. It +can vanish only on a boundary with an eigenvalue one, or by introducing negative +coefficients that invalidate the original positive-vertex expansion. + +## 4. Reduction and stoquastic checks + +For one triangle, a diagonal Fock-sign gauge can make h=-M stoquastic in the N=1 +sector only when alpha-beta>=0, and in N=2 only when d_2-gamma>0. The A and B +orbits violate opposite conditions at small tau. Their positive mixture has only a +narrow possible gauge-compatible window, different from the ratio that removes J. +Overlapping triangles introduce further global consistency conditions. + +The standard spinless fermion-bag and Majorana-QMC constructions in + +- https://arxiv.org/abs/1311.0034 +- https://arxiv.org/abs/1408.2269 + +use bipartite, half-filled, or particle-hole structures and do not directly cover +this nonbipartite triangular support. This is not a proof that no alternative bag or +non-diagonal stoquastic representation exists. + +## 5. Finite-density no-go inside the contraction route + +For an isolated triangle, every one-particle orbit factor U_sigma obeys + + ||U_sigma||_infinity<=q=exp(-kappa tau)<1. + +The induced exterior norm therefore gives + + ||wedge^N U_sigma||<=q^N + +in every N>=1 sector. Permutations are isometries for the same norm, so their +average M_X^(N) is also a contraction. The preceding Schur argument makes each +irreducible block a real scalar; hence every N>=1 eigenvalue lambda obeys +|lambda|<=q^N<=1. The vacuum block is exactly one. Since the complete twirl is +Hermitian, this proves I-M_X>=0 as an operator on Fock space. + +For positive couplings, + + H_0-E_vac = sum_Delta,X g_X [I-M_(X,Delta)] >= 0. + +Any deterministic one-body background dGamma(K) that remains safe under the same +contraction certificate has K>=0 and only reinforces the vacuum. A positive physical +chemical potential -mu N has one-particle propagation exp(+Delta tau mu), leaves the +contraction semigroup, and destroys this proof. + +Grand-canonical positivity also does not imply positivity at fixed filling because + + det(I+zT)=sum_N z^N Tr(wedge^N T) + +may be positive at z=1 while individual coefficients are negative. For example, +X=[[-1,-1],[1,-1]] at t=pi gives T=-exp(-pi)I: det(I+T)>0 but tr T<0. + +Therefore the S3 contraction family defines an engineered Hermitian interacting model +with an exact sign-free grand-canonical determinant-valued series expansion and a +rigorous vacuum ground state. It is not a standard auxiliary-field DQMC formulation +or a solved finite-density algorithm. Canonical finite density requires a new +exterior-power cone or another pairing mechanism. This no-go motivates the separate +Perron-compound construction. diff --git a/tracks/qmc/solutions/mao-kexiang-121/reduction_checklist.md b/tracks/qmc/solutions/mao-kexiang-121/reduction_checklist.md new file mode 100644 index 000000000..89a96fbbb --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/reduction_checklist.md @@ -0,0 +1,175 @@ +> Applied outcome (2026-07-29): the two-orbit support passes the fixed Wei +> complex-CAR nonembedding test at generator level and at sufficiently small time +> step, but Hamiltonian-level alternative decompositions remain open. The separate +> Perron-compound criterion is not a fixed-metric contraction. See +> `novelty_audit.md` and `main_theorem.md`. + +# Novelty filter for determinant-positive generator sets + +Date: 2026-07-29 + +Purpose: reject rediscoveries before numerical work. A candidate is not called new +merely because its defining inequalities or proof look different. It must survive +all reductions below and must produce a physical determinantal-QMC weight. + +## 1. Normalize the object being compared + +For every candidate record: + +```text +single-particle generator set C +semigroup S(C) generated by exp(C) +allowed similarities/gauge transformations +Fock trace or determinant being certified +whether particle number and Hermiticity are preserved +``` + +The comparison is made at the semigroup and Fock-representation levels, not only at +the syntax of the one-particle generator. + +## 2. Split-orthogonal reduction + +Search for one fixed nonsingular symmetric metric `eta` and one fixed similarity +`P` such that every transformed generator `X=P A P^-1` satisfies either + +```text +X^T eta + eta X = 0 +``` + +or the one-sided cone inequality + +```text +X^T eta + eta X >= 0 +``` + +with a consistent sign convention. Also test bipartite sign gauges, particle-hole +transformations, permutations, and positive diagonal similarities. If such fixed +data exist, the candidate is Wang et al. (2015) or its known semigroup extension. + +## 3. Kramers/complex-structure reduction + +Search for a fixed real or complex matrix `J` defining an antiunitary symmetry of +every slice, with `J J*=-I`. Equivalently, test whether a fixed basis makes every +slice quaternion-real or makes the determinant a product of complex-conjugate +factors. A realification block algebra commuting with one fixed complex structure +is not new: it is the ordinary Kramers mechanism in another basis. + +## 4. Majorana reflection-positivity reduction + +For a real number-conserving generator `X`, set + +```text +S=(X+X^T)/2, K=(X-X^T)/2. +``` + +With `c=(gamma_1+i gamma_2)/2`, direct expansion gives + +```text +c^dagger X c + = tr(X)/2 + + (1/4) Gamma^T [[K,iS],[-iS,K]] Gamma, + +Gamma=(gamma_1,gamma_2)^T. +``` + +Thus `S>=0` or `S<=0` places the slice exactly in the block kernel + +```text +[[A,iB],[-iB^T,A*]], +``` + +where `A` is complex antisymmetric and `B` is Hermitian semidefinite. This is +Theorem 1 of Wei, Wu, Li, Zhang and Xiang (2016), not a new mechanism. Repeat the +test after fixed Majorana permutations, sign gauges, particle-hole maps, and +similarities allowed by the fermionic canonical anticommutation relations. + +## 5. The 2024 contraction-semigroup reduction + +In Majorana form, search for fixed anti-commuting real orthogonal matrices `J_1,J_2` +with `J_2` skew-symmetric such that every complex skew kernel `V` satisfies + +```text +J_1^T V J_1 = conjugate(V), +i(J_2 V - conjugate(V) J_2) <= 0. +``` + +The equality case is a known symmetry class; symmetric `J_1` contains Majorana +reflection positivity; skew `J_1` contains the Kramers contraction class. Passing +only the canonical choice is insufficient: alternative common `J_1,J_2` choices +must be excluded before claiming novelty. A proof restricted to real orthogonal +Majorana frames must also say explicitly that genuinely complex orthogonal canonical +similarities remain unchecked. + +## 5a. Non-Euclidean norm-contraction reduction (current internal candidate) + +For every real candidate, test whether there is one fixed norm with logarithmic norm +`mu(A)<=0` for all generators. Then every product of exponentials is contractive, +all eigenvalues stay in the unit disk, and reality alone gives `det(I+T)>=0`. +The explicit polyhedral cases are + +```text +mu_infinity(A)=max_i(a_ii+sum_{j!=i}|a_ij|), +mu_1(A)=max_j(a_jj+sum_{i!=j}|a_ij|). +``` + +This is currently a candidate mechanism developed in this repository, not yet an +established QMC literature class. It contains the substochastic Markov wedge but +also genuinely signed matrices. Future candidates contained in it are not +independent discoveries. + +## 6. One-dimensional and trivial-sector reductions + +Check whether a fermionic ordering or Jordan-Wigner transformation removes the sign, +whether the determinant is merely a square from duplicated flavors, and whether a +triangular construction becomes diagonal once Hermiticity is imposed. Such results +may be useful formulations but do not meet the challenge's novelty target. + +## 7. Physical-realizability gate + +For an interacting Hamiltonian, write the exact positive-measure expansion or HS +identity. For each field value, show that every bilinear slice belongs to the +candidate set and that every scalar prefactor is nonnegative. Also state which +part of the candidate is genuinely outside all known cones. + +For real number-conserving slices, remember: + +```text +c^dagger X c is Hermitian iff X=X^T. +``` + +If a proposed positive support is closed under transpose and both `X` and `X^T` are +Markov subgenerators, then `S=(X+X^T)/2<=0`; this collapses to Majorana reflection +positivity. A proposed directed-Markov realization must explicitly evade this +no-go step rather than hiding the adjoint in notation. + +## 8. Current candidate ledger + +| Candidate | Determinant proof | Novelty result | Physical result | +|---|---|---|---| +| split orthogonal | known | reference class | known | +| semidefinite split cone | known | reference class | known | +| totally nonnegative semigroup | known/competing result | submitted independently in PR #259; overlaps Jordan-Wigner/noncrossing physics | excluded from this submission | +| `R_+ SO(m)` / `alpha I+so(m)` | proved here | rejected: Majorana reflection positive | current-square model rejected | +| symmetric graph Laplacian | proved here | rejected: Majorana reflection positive | fermion-boson model is known-class | +| full nonsymmetric substochastic Markov wedge | proved here | subsumed by the polyhedral infinity-norm wedge | naive adjoint closure is blocked | +| signed polyhedral infinity-norm wedge | proved here | classical common-polyhedral contraction cone; candidate QMC specialization only | fixed complex-CAR support separation proved only for the full-span odd-dimensional subfamily | +| three-site permutation-twirled Markov orbit | inherited Markov proof | retained as a simpler precursor | provisional Hermitian interacting model | +| minimal `S_3·A` signed orbit | inherited norm-contraction proof | rejected as polyhedral-only: exact common positive quadratic metric exists | Hermitian and interacting, but known quadratic-contraction reduction | +| augmented `A,D,F` support | inherited norm-contraction proof | rejected as Hamiltonian novelty certificate: `D,F` twirls are only one-body calibration | interacting `A` term plus deterministic one-body terms | +| two-orbit S_3 orbit of A union S_3 orbit of (SAS) | inherited norm-contraction proof | exact no-quadratic certificate and fixed complex-CAR nonembedding for the supplied support; alternative decompositions remain open | both twirls interacting; positive-coupling model has rigorous vacuum ground state | +| `det X=0` two-body boundary orbit | inherited norm-contraction proof | fermion-bag/alternative decomposition audit open | exact nonbipartite attractive spinless `t-V`, but vacuum no-go remains | +| fixed upper-triangular algebra | proved here | elementary common-flag mechanism | Hermitian part is diagonal | + +## 9. Evidence threshold for the word new + +A surviving candidate needs all of the following: + +1. explicit failure of the reduction tests above, preferably with basis-independent + invariants rather than a failed numerical search; +2. broad primary-literature search using both its matrix and physics vocabulary; +3. a proof of determinant nonnegativity for arbitrary product depth; +4. an exact interacting-model decomposition with nonnegative scalar measure; +5. randomized oracle tests, and exact certificates for every counterexample used. + +Until all five are present, use `candidate`, `unreduced`, or `provisionally distinct`, +never `new sign-problem-free class`. \ No newline at end of file diff --git a/tracks/qmc/solutions/mao-kexiang-121/requirements.txt b/tracks/qmc/solutions/mao-kexiang-121/requirements.txt new file mode 100644 index 000000000..77909df50 --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/requirements.txt @@ -0,0 +1,3 @@ +numpy +scipy +pytest diff --git a/tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py b/tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py new file mode 100644 index 000000000..ceabea0be --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py @@ -0,0 +1,951 @@ +"""Small exact oracles for fermionic determinant sign experiments. + +The central map is A -> sum_ij A_ij c_i^dagger c_j. It is evaluated +explicitly in the occupation-number basis, so the Fock-space trace and the +single-particle determinant are independent numerical calculations. +""" + +from __future__ import annotations + +import argparse +from collections.abc import Iterable, Sequence +from dataclasses import dataclass +import json +import os +from pathlib import Path +import re +import resource +import time + +import numpy as np +from scipy.linalg import expm + + +Array = np.ndarray + + +def _as_square_matrix(matrix: Array) -> Array: + result = np.asarray(matrix) + if result.ndim != 2 or result.shape[0] != result.shape[1]: + raise ValueError("a generator must be a square matrix") + return result + + +def split_metric(n: int) -> Array: + """Return eta = diag(I_n, -I_n).""" + if n < 1: + raise ValueError("n must be positive") + return np.diag(np.concatenate((np.ones(n), -np.ones(n)))) + + +def o11_generator(rapidity: float) -> Array: + """Return the general Lie-algebra generator in the identity component.""" + return np.array([[0.0, rapidity], [rapidity, 0.0]]) + + +def o11_analytic_determinant(rapidities: Iterable[float]) -> float: + """Analytic det(I + product exp(A_i)) for commuting o(1,1) boosts.""" + total = float(np.sum(np.asarray(list(rapidities), dtype=float))) + return float(2.0 + 2.0 * np.cosh(total)) + + +def product_of_exponentials(generators: Sequence[Array]) -> Array: + """Multiply exp(A_1) exp(A_2) ... in the supplied order.""" + if not generators: + raise ValueError("at least one generator is required") + + matrices = [_as_square_matrix(generator) for generator in generators] + dimension = matrices[0].shape[0] + if any(matrix.shape != (dimension, dimension) for matrix in matrices): + raise ValueError("all generators must have the same shape") + + dtype = np.result_type(*(matrix.dtype for matrix in matrices), np.float64) + product = np.eye(dimension, dtype=dtype) + for matrix in matrices: + product = product @ expm(matrix) + return product + + +def product_with_split_group_residual( + generators: Sequence[Array], + eta: Array, +) -> tuple[Array, float]: + """Multiply factors and evaluate M.T eta M-eta in extended precision. + + SciPy supplies each matrix exponential in double precision. Accumulating + the factors and the quadratic-form residual in long double prevents the + absolute residual from being dominated by condition-amplified matrix + multiplication roundoff. + """ + if not generators: + raise ValueError("at least one generator is required") + + matrices = [_as_square_matrix(generator) for generator in generators] + dimension = matrices[0].shape[0] + if any(matrix.shape != (dimension, dimension) for matrix in matrices): + raise ValueError("all generators must have the same shape") + metric = _as_square_matrix(eta) + if metric.shape != (dimension, dimension): + raise ValueError("eta and the generators must have the same shape") + + is_complex = any(np.iscomplexobj(matrix) for matrix in matrices) + extended_dtype = np.clongdouble if is_complex else np.longdouble + output_dtype = np.complex128 if is_complex else np.float64 + product = np.eye(dimension, dtype=extended_dtype) + for matrix in matrices: + factor = np.asarray(expm(matrix), dtype=extended_dtype) + product = product @ factor + + extended_metric = np.asarray(metric, dtype=extended_dtype) + residual_matrix = product.T @ extended_metric @ product - extended_metric + residual = float(np.sqrt(np.sum(np.abs(residual_matrix) ** 2))) + return np.asarray(product, dtype=output_dtype), residual + + +def determinant_weight(generators: Sequence[Array]): + """Compute det(I + exp(A_1) exp(A_2) ...).""" + product = product_of_exponentials(generators) + return np.linalg.det(np.eye(product.shape[0], dtype=product.dtype) + product) + + +def bilinear_fock_operator(generator: Array) -> Array: + """Lift A to sum_ij A_ij c_i^dagger c_j in the full Fock space. + + Basis states are integers whose bit j is the occupation of orbital j. + Hence the one-particle states appear in the order |10...>, |01...>, ... + and the one-particle block of the returned operator is exactly A. + """ + matrix = _as_square_matrix(generator) + orbitals = matrix.shape[0] + dimension = 1 << orbitals + dtype = np.result_type(matrix.dtype, np.float64) + lifted = np.zeros((dimension, dimension), dtype=dtype) + + for state in range(dimension): + for j in range(orbitals): + if not (state & (1 << j)): + continue + + lower_j = state & ((1 << j) - 1) + phase_annihilate = -1 if lower_j.bit_count() % 2 else 1 + intermediate = state ^ (1 << j) + + for i in range(orbitals): + coefficient = matrix[i, j] + if coefficient == 0 or (intermediate & (1 << i)): + continue + + lower_i = intermediate & ((1 << i) - 1) + phase_create = -1 if lower_i.bit_count() % 2 else 1 + destination = intermediate | (1 << i) + lifted[destination, state] += ( + coefficient * phase_annihilate * phase_create + ) + + return lifted + + +def fock_trace_weight(generators: Sequence[Array]): + """Compute Tr_Fock product exp(sum_ij A_ij c_i^dagger c_j).""" + if not generators: + raise ValueError("at least one generator is required") + + matrices = [_as_square_matrix(generator) for generator in generators] + orbitals = matrices[0].shape[0] + if any(matrix.shape != (orbitals, orbitals) for matrix in matrices): + raise ValueError("all generators must have the same shape") + + dimension = 1 << orbitals + dtype = np.result_type(*(matrix.dtype for matrix in matrices), np.float64) + product = np.eye(dimension, dtype=dtype) + for matrix in matrices: + product = product @ expm(bilinear_fock_operator(matrix)) + return np.trace(product) + + +def random_split_generator( + n: int, + rng: np.random.Generator, + *, + scale: float = 1.0, +) -> Array: + """Sample A = [[C, B], [B.T, D]] from the full o(n,n) algebra.""" + if n < 1: + raise ValueError("n must be positive") + b = rng.normal(size=(n, n)) + c_raw = rng.normal(size=(n, n)) + d_raw = rng.normal(size=(n, n)) + c = c_raw - c_raw.T + d = d_raw - d_raw.T + return float(scale) * np.block([[c, b], [b.T, d]]) + + +def _split_dimension_and_metric(matrix: Array, eta: Array | None) -> tuple[int, Array]: + square = _as_square_matrix(matrix) + dimension = square.shape[0] + if dimension % 2: + raise ValueError("a split-orthogonal matrix must have even dimension") + + n = dimension // 2 + metric = split_metric(n) if eta is None else _as_square_matrix(eta) + if metric.shape != square.shape: + raise ValueError("eta and the matrix must have the same shape") + return n, metric + + +def split_lie_residual(generator: Array, eta: Array | None = None) -> float: + """Frobenius residual of A.T eta + eta A = 0.""" + matrix = _as_square_matrix(generator) + _, metric = _split_dimension_and_metric(matrix, eta) + residual = matrix.T @ metric + metric @ matrix + return float(np.linalg.norm(residual, ord="fro")) + + +def split_group_residual(matrix: Array, eta: Array | None = None) -> float: + """Frobenius residual of M.T eta M = eta.""" + square = _as_square_matrix(matrix) + _, metric = _split_dimension_and_metric(square, eta) + residual = square.T @ metric @ square - metric + return float(np.linalg.norm(residual, ord="fro")) + + +def determinant_i_plus(matrix: Array): + """Compute det(I + M) for an already formed evolution matrix M.""" + square = _as_square_matrix(matrix) + identity = np.eye(square.shape[0], dtype=np.result_type(square.dtype, float)) + return np.linalg.det(identity + square) + + +def classify_split_component( + matrix: Array, + eta: Array | None = None, + *, + atol: float = 1e-9, +) -> str: + """Classify M in O(n,n) by signs of det(M_11) and det(M_22).""" + square = _as_square_matrix(matrix) + n, metric = _split_dimension_and_metric(square, eta) + if split_group_residual(square, metric) > atol: + raise ValueError("matrix is not in O(n,n) within the requested tolerance") + + sign_11, _ = np.linalg.slogdet(square[:n, :n]) + sign_22, _ = np.linalg.slogdet(square[n:, n:]) + if sign_11 == 0 or sign_22 == 0: + raise ValueError("a diagonal block is numerically singular") + return ("+" if sign_11 > 0 else "-") + ("+" if sign_22 > 0 else "-") + + +def split_component_representative(n: int, component: str) -> Array: + """Return a diagonal representative of one of the four O(n,n) components.""" + if n < 1: + raise ValueError("n must be positive") + if component not in {"++", "--", "-+", "+-"}: + raise ValueError("component must be one of ++, --, -+, +-") + + diagonal = np.ones(2 * n) + if component[0] == "-": + diagonal[0] = -1.0 + if component[1] == "-": + diagonal[n] = -1.0 + return np.diag(diagonal) + + +@dataclass(frozen=True) +class HubbardVertex: + """One continuous-time auxiliary-field insertion.""" + + tau: float + site: int + field: int + + +_HUBBARD_ORBITAL_ORDER = ( + (0, "up"), + (2, "up"), + (1, "down"), + (3, "down"), + (1, "up"), + (3, "up"), + (0, "down"), + (2, "down"), +) + + +def four_site_orbital_order() -> tuple[tuple[int, str], ...]: + """Return the (A up, B down | B up, A down) split ordering.""" + return _HUBBARD_ORBITAL_ORDER + + +def hubbard_orbital_index(site: int, spin: str) -> int: + """Index a site-spin orbital in the split ordering.""" + try: + return _HUBBARD_ORBITAL_ORDER.index((int(site), spin)) + except ValueError as exc: + raise ValueError("site must be 0..3 and spin must be up or down") from exc + + +def four_site_hopping_matrix(*, t_up: float, t_down: float) -> Array: + """Single-particle K for the PBC ring, with H_0 = c^dagger K c.""" + matrix = np.zeros((8, 8)) + edges = ((0, 1), (1, 2), (2, 3), (3, 0)) + for spin, hopping in (("up", t_up), ("down", t_down)): + for site_i, site_j in edges: + i = hubbard_orbital_index(site_i, spin) + j = hubbard_orbital_index(site_j, spin) + matrix[i, j] = -float(hopping) + matrix[j, i] = -float(hopping) + return matrix + + +def spin_flip_vertex( + site: int, + field: int, + *, + u: float, + gamma: float, +) -> Array: + """Return Lambda_i^s = s lambda (|up> 0") + + coupling = float(np.arccosh(1.0 + u / (2.0 * gamma))) + up = hubbard_orbital_index(site, "up") + down = hubbard_orbital_index(site, "down") + vertex = np.zeros((8, 8)) + vertex[up, down] = field * coupling + vertex[down, up] = field * coupling + return vertex + + +def onsite_spin_flip_decomposition_residual(*, u: float, gamma: float) -> float: + """Directly check -v = Gamma/2 sum_s exp(s lambda S_x) on one site.""" + if u <= 0 or gamma <= 0: + raise ValueError("this real spin-flip decomposition requires U,Gamma > 0") + + number_up = np.diag([0.0, 1.0, 0.0, 1.0]) + number_down = np.diag([0.0, 0.0, 1.0, 1.0]) + identity = np.eye(4) + interaction = ( + u * (number_up @ number_down - 0.5 * (number_up + number_down)) + - gamma * identity + ) + + spin_flip_one_body = np.array([[0.0, 1.0], [1.0, 0.0]]) + spin_flip_fock = bilinear_fock_operator(spin_flip_one_body) + coupling = float(np.arccosh(1.0 + u / (2.0 * gamma))) + auxiliary_sum = 0.5 * gamma * ( + expm(coupling * spin_flip_fock) + expm(-coupling * spin_flip_fock) + ) + return float(np.linalg.norm(-interaction - auxiliary_sum, ord="fro")) + + +def generate_hubbard_configurations( + *, + count: int, + beta: float, + seed: int, +) -> tuple[tuple[HubbardVertex, ...], ...]: + """Generate the preregistered k=index mod 9 configuration sequence.""" + if count < 1 or beta <= 0: + raise ValueError("count and beta must be positive") + + rng = np.random.default_rng(seed) + configurations: list[tuple[HubbardVertex, ...]] = [] + for index in range(count): + order = index % 9 + times = np.sort(rng.uniform(0.0, beta, size=order)) + sites = rng.integers(0, 4, size=order) + fields = rng.choice(np.array([-1, 1]), size=order) + configurations.append( + tuple( + HubbardVertex(float(tau), int(site), int(field)) + for tau, site, field in zip(times, sites, fields, strict=True) + ) + ) + return tuple(configurations) + + +def hubbard_configuration_generators( + vertices: Sequence[HubbardVertex], + *, + beta: float, + hopping: Array, + u: float, + gamma: float, +) -> tuple[Array, ...]: + """Build e^{-(beta-tau_k)K} e^{Lambda_k} ... e^{-tau_1 K}.""" + hopping_matrix = _as_square_matrix(hopping) + if hopping_matrix.shape != (8, 8): + raise ValueError("the four-site hopping matrix must be 8 by 8") + if beta <= 0: + raise ValueError("beta must be positive") + + ordered = tuple(vertices) + previous = 0.0 + for vertex in ordered: + if not (previous <= vertex.tau <= beta): + raise ValueError("vertices must be sorted within [0,beta]") + previous = vertex.tau + + generators: list[Array] = [] + later_time = float(beta) + for vertex in reversed(ordered): + generators.append(-(later_time - vertex.tau) * hopping_matrix) + generators.append( + spin_flip_vertex(vertex.site, vertex.field, u=u, gamma=gamma) + ) + later_time = vertex.tau + generators.append(-later_time * hopping_matrix) + return tuple(generators) + + +def four_site_free_propagator( + delta_tau: float, + *, + t_up: float, + t_down: float, + dtype=np.longdouble, +) -> Array: + """Analytic exp(-delta_tau K) for the four-site periodic ring.""" + if delta_tau < 0: + raise ValueError("delta_tau must be nonnegative") + + cast = np.dtype(dtype).type + propagator = np.eye(8, dtype=dtype) + for spin, hopping in (("up", t_up), ("down", t_down)): + amplitude = cast(str(delta_tau)) * cast(str(hopping)) + cosh_two = np.cosh(cast(2) * amplitude) + sinh_two = np.sinh(cast(2) * amplitude) + first_row = ( + (cosh_two + cast(1)) / cast(2), + sinh_two / cast(2), + (cosh_two - cast(1)) / cast(2), + sinh_two / cast(2), + ) + block = np.empty((4, 4), dtype=dtype) + for row in range(4): + for column in range(4): + block[row, column] = first_row[(column - row) % 4] + indices = [hubbard_orbital_index(site, spin) for site in range(4)] + propagator[np.ix_(indices, indices)] = block + return propagator + + +def spin_flip_propagator( + site: int, + field: int, + *, + u: float, + gamma: float, + dtype=np.longdouble, +) -> Array: + """Analytic exp(Lambda_i^s) in its two-dimensional orbital block.""" + spin_flip_vertex(site, field, u=u, gamma=gamma) + cast = np.dtype(dtype).type + coupling = np.arccosh( + cast(1) + cast(str(u)) / (cast(2) * cast(str(gamma))) + ) + diagonal = np.cosh(coupling) + off_diagonal = cast(field) * np.sinh(coupling) + up = hubbard_orbital_index(site, "up") + down = hubbard_orbital_index(site, "down") + propagator = np.eye(8, dtype=dtype) + propagator[up, up] = diagonal + propagator[down, down] = diagonal + propagator[up, down] = off_diagonal + propagator[down, up] = off_diagonal + return propagator + + +def hubbard_configuration_evolution( + vertices: Sequence[HubbardVertex], + *, + beta: float, + t_up: float, + t_down: float, + u: float, + gamma: float, +) -> tuple[Array, float]: + """Form the physical evolution and its absolute group residual in longdouble.""" + if beta <= 0: + raise ValueError("beta must be positive") + ordered = tuple(vertices) + previous = 0.0 + for vertex in ordered: + if not (previous <= vertex.tau <= beta): + raise ValueError("vertices must be sorted within [0,beta]") + previous = vertex.tau + + evolution = np.eye(8, dtype=np.longdouble) + later_time = float(beta) + for vertex in reversed(ordered): + evolution = evolution @ four_site_free_propagator( + later_time - vertex.tau, + t_up=t_up, + t_down=t_down, + ) + evolution = evolution @ spin_flip_propagator( + vertex.site, + vertex.field, + u=u, + gamma=gamma, + ) + later_time = vertex.tau + evolution = evolution @ four_site_free_propagator( + later_time, + t_up=t_up, + t_down=t_down, + ) + + eta = np.asarray(split_metric(4), dtype=np.longdouble) + residual_matrix = evolution.T @ eta @ evolution - eta + residual = float(np.sqrt(np.sum(residual_matrix * residual_matrix))) + return np.asarray(evolution, dtype=np.float64), residual + + +def _atomic_write_text(path: Path, text: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + temporary = path.with_name(path.name + ".tmp") + temporary.write_text(text, encoding="utf-8") + os.replace(temporary, path) + + +def _atomic_write_json(path: Path, payload: object) -> None: + _atomic_write_text(path, json.dumps(payload, indent=2, sort_keys=True) + "\n") + + +def _configuration_to_json(vertices: Sequence[HubbardVertex]) -> list[dict]: + return [ + {"tau": vertex.tau, "site": vertex.site, "field": vertex.field} + for vertex in vertices + ] + + +def _weights_svg(weights: Sequence[float], orders: Sequence[int]) -> str: + width, height = 960, 500 + left, right, top, bottom = 78, 28, 38, 62 + plot_width = width - left - right + plot_height = height - top - bottom + logs = np.log10(np.maximum(np.asarray(weights, dtype=float), np.finfo(float).tiny)) + y_min = float(np.floor(np.min(logs))) + y_max = float(np.ceil(np.max(logs))) + if y_max <= y_min: + y_max = y_min + 1.0 + + palette = ( + "#355cde", + "#00a6a6", + "#00a65a", + "#9aaf00", + "#f0a000", + "#ef6c35", + "#d33f6a", + "#8b52c7", + "#4f6070", + ) + elements = [ + f'', + '', + 'Four-site Hubbard configuration weights', + ] + for tick in range(int(y_min), int(y_max) + 1): + y = top + (y_max - tick) / (y_max - y_min) * plot_height + elements.append( + f'' + ) + elements.append( + f'{tick}' + ) + elements.extend( + [ + f'', + f'', + ] + ) + count = len(weights) + for index, (value, order) in enumerate(zip(logs, orders, strict=True)): + x = left + (index / max(count - 1, 1)) * plot_width + y = top + (y_max - float(value)) / (y_max - y_min) * plot_height + elements.append( + f'' + ) + for x_tick in (0, 64, 128, 192, 255): + x = left + (x_tick / max(count - 1, 1)) * plot_width + elements.append( + f'{x_tick}' + ) + elements.extend( + [ + f'configuration index', + f'log10 det(I + T)', + 'color: expansion order k=0,...,8', + "", + ] + ) + return "\n".join(elements) + "\n" + + +def _diagnostics_svg(diagnostics: Sequence[tuple[str, float, float]]) -> str: + width, height = 960, 440 + left, right, top, bottom = 250, 40, 50, 45 + usable_width = width - left - right + row_height = (height - top - bottom) / len(diagnostics) + max_score = 18.0 + elements = [ + f'', + '', + 'Structural residuals (longer bars are smaller errors)', + ] + for index, (label, value, tolerance) in enumerate(diagnostics): + score = min(max_score, max(0.0, -np.log10(max(value, 1e-18)))) + tolerance_score = min(max_score, max(0.0, -np.log10(tolerance))) + y = top + index * row_height + 8 + bar_width = score / max_score * usable_width + tolerance_x = left + tolerance_score / max_score * usable_width + color = "#16856b" if value <= tolerance else "#c0392b" + elements.extend( + [ + f'{label}', + f'', + f'', + f'', + f'{value:.3e}', + ] + ) + elements.extend( + [ + f'-log10(residual); black marker is preregistered tolerance', + "", + ] + ) + return "\n".join(elements) + "\n" + + +def _run_parameters(run: dict) -> dict[str, object]: + couplings = run["model"]["couplings"] + settings = run["method"]["settings"] + cross_check_indices = [ + int(value) + for value in re.findall(r"\d+", settings["fock_cross_checks"]) + ] + parameters = { + "t_up": float(couplings["$t_\\uparrow$"]), + "t_down": float(couplings["$t_\\downarrow$"]), + "u": float(couplings["$U$"]), + "gamma": float(couplings["$\\Gamma$"]), + "beta": float(couplings["$\\beta$"]), + "mu": float(couplings["$\\mu$"]), + "count": int(settings["configuration_count"]), + "seed": int(settings["random_seed"]), + "cross_check_indices": cross_check_indices, + "lie_tolerance": float(settings["lie_tolerance"]), + "group_tolerance": float(settings["group_tolerance"]), + "trace_tolerance": float(settings["trace_determinant_tolerance"]), + "weight_tolerance": float(settings["weight_tolerance"]), + } + if parameters["mu"] != 0.0: + raise ValueError("the approved half-filled run requires mu=0") + return parameters + + +def run_approved_hubbard_oracle(run_dir: Path) -> dict: + """Execute the preregistered run and update its single source, run.json.""" + run_path = run_dir / "run.json" + run = json.loads(run_path.read_text(encoding="utf-8")) + parameters = _run_parameters(run) + + t_up = parameters["t_up"] + t_down = parameters["t_down"] + u = parameters["u"] + gamma = parameters["gamma"] + beta = parameters["beta"] + count = parameters["count"] + seed = parameters["seed"] + lie_tolerance = parameters["lie_tolerance"] + group_tolerance = parameters["group_tolerance"] + trace_tolerance = parameters["trace_tolerance"] + weight_tolerance = parameters["weight_tolerance"] + cross_check_indices = parameters["cross_check_indices"] + + start_total = time.perf_counter() + eta = split_metric(4) + hopping = four_site_hopping_matrix(t_up=t_up, t_down=t_down) + hopping_lie_residual = split_lie_residual(hopping, eta) + vertex_lie_residuals = [ + split_lie_residual( + spin_flip_vertex(site, field, u=u, gamma=gamma), + eta, + ) + for site in range(4) + for field in (-1, 1) + ] + onsite_residual = onsite_spin_flip_decomposition_residual(u=u, gamma=gamma) + configurations = generate_hubbard_configurations( + count=count, + beta=beta, + seed=seed, + ) + + print( + f"setup: L=4 beta={beta:g} U={u:g} Gamma={gamma:g} " + f"configs={count} seed={seed}", + flush=True, + ) + determinant_start = time.perf_counter() + records: list[dict] = [] + weights: list[float] = [] + orders: list[int] = [] + max_generator_residual = 0.0 + for index, vertices in enumerate(configurations): + generators = hubbard_configuration_generators( + vertices, + beta=beta, + hopping=hopping, + u=u, + gamma=gamma, + ) + generator_residual = max( + split_lie_residual(generator, eta) for generator in generators + ) + max_generator_residual = max(max_generator_residual, generator_residual) + evolution, group_residual = hubbard_configuration_evolution( + vertices, + beta=beta, + t_up=t_up, + t_down=t_down, + u=u, + gamma=gamma, + ) + component = classify_split_component( + evolution, + eta, + atol=max(group_tolerance * 10.0, 1e-9), + ) + determinant = float(np.real_if_close(determinant_i_plus(evolution))) + scalar_prefactor = float((gamma / 2.0) ** len(vertices)) + weight = scalar_prefactor * determinant + weights.append(weight) + orders.append(len(vertices)) + records.append( + { + "index": index, + "order": len(vertices), + "vertices": _configuration_to_json(vertices), + "determinant": determinant, + "scalar_prefactor": scalar_prefactor, + "weight": weight, + "component": component, + "generator_lie_residual": generator_residual, + "group_residual": group_residual, + } + ) + if (index + 1) % 64 == 0 or index + 1 == count: + print( + f"single-particle: {index + 1}/{count}; " + f"min_weight={min(weights):.6e}; " + f"max_group_residual={max(item['group_residual'] for item in records):.3e}", + flush=True, + ) + determinant_wall = time.perf_counter() - determinant_start + + fock_start = time.perf_counter() + fock_checks: list[dict] = [] + for index in cross_check_indices: + vertices = configurations[index] + generators = hubbard_configuration_generators( + vertices, + beta=beta, + hopping=hopping, + u=u, + gamma=gamma, + ) + fock_trace = float(np.real_if_close(fock_trace_weight(generators))) + determinant = records[index]["determinant"] + absolute_error = abs(fock_trace - determinant) + relative_error = absolute_error / max(1.0, abs(determinant)) + fock_checks.append( + { + "index": index, + "order": len(vertices), + "fock_trace": fock_trace, + "determinant": determinant, + "absolute_error": absolute_error, + "relative_error": relative_error, + } + ) + print( + f"fock-check: index={index} k={len(vertices)} " + f"relative_error={relative_error:.3e}", + flush=True, + ) + fock_wall = time.perf_counter() - fock_start + total_wall = time.perf_counter() - start_total + + component_counts = { + component: sum(record["component"] == component for record in records) + for component in ("++", "--", "-+", "+-") + } + negative_count = sum(weight < -weight_tolerance for weight in weights) + near_zero_count = sum(abs(weight) <= weight_tolerance for weight in weights) + max_group_residual = max(record["group_residual"] for record in records) + max_trace_relative_error = max( + check["relative_error"] for check in fock_checks + ) + max_vertex_lie_residual = max(vertex_lie_residuals) + max_memory_gb = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / (1024.0**2) + + checks = { + "onsite_decomposition": onsite_residual <= lie_tolerance, + "hopping_lie_algebra": hopping_lie_residual <= lie_tolerance, + "vertex_lie_algebra": max_vertex_lie_residual <= lie_tolerance, + "all_generator_lie_algebra": max_generator_residual <= lie_tolerance, + "group_preservation": max_group_residual <= group_tolerance, + "identity_component": component_counts["++"] == count, + "nonnegative_weight": negative_count == 0, + "fock_trace_identity": max_trace_relative_error <= trace_tolerance, + } + passed = all(checks.values()) + + numerical_change = ( + "Initial SciPy double-precision factors exposed condition-amplified " + "roundoff in the absolute group residual. The final evaluation uses " + "the analytic C4 free propagator and analytic 2x2 spin-flip propagator, " + "accumulated in NumPy longdouble; the model, configurations, determinant " + "definition, and preregistered 1e-10 threshold stay fixed." + ) + result = { + "status": "passed" if passed else "failed", + "parameters": parameters, + "checks": checks, + "changes": [numerical_change], + "diagnostics": { + "onsite_decomposition_residual": onsite_residual, + "hopping_lie_residual": hopping_lie_residual, + "max_vertex_lie_residual": max_vertex_lie_residual, + "max_generator_lie_residual": max_generator_residual, + "max_group_residual": max_group_residual, + "max_fock_trace_relative_error": max_trace_relative_error, + "min_weight": min(weights), + "max_weight": max(weights), + "negative_weight_count": negative_count, + "near_zero_weight_count": near_zero_count, + "component_counts": component_counts, + }, + "theorem_anchors": { + "o11_identity_component_weight": 16.0 / 3.0, + "o11_negative_component_weight": -4.0 / 3.0, + "o11_mixed_component_weight": 0.0, + }, + "timing": { + "single_particle_wall_seconds": determinant_wall, + "fock_wall_seconds": fock_wall, + "total_wall_seconds": total_wall, + "max_memory_gb": max_memory_gb, + }, + "fock_checks": fock_checks, + "configurations": records, + } + + _atomic_write_json(run_dir / "data" / "results.json", result) + _atomic_write_text( + run_dir / "figs" / "configuration_weights.svg", + _weights_svg(weights, orders), + ) + diagnostics_for_plot = ( + ("on-site HS identity", onsite_residual, lie_tolerance), + ("hopping Lie residual", hopping_lie_residual, lie_tolerance), + ("vertex Lie residual", max_vertex_lie_residual, lie_tolerance), + ("product group residual", max_group_residual, group_tolerance), + ("Fock/determinant error", max_trace_relative_error, trace_tolerance), + ) + _atomic_write_text( + run_dir / "figs" / "diagnostic_residuals.svg", + _diagnostics_svg(diagnostics_for_plot), + ) + + rerun = f"python {Path(__file__)} --run-dir {run_dir}" + run["actual"] = [ + { + "point": "256 single-particle configurations", + "wall": f"{determinant_wall:.3f} s", + "memory": f"{max_memory_gb:.3f} GB peak process RSS", + }, + { + "point": "3 direct 256-dimensional Fock checks", + "wall": f"{fock_wall:.3f} s", + "memory": f"{max_memory_gb:.3f} GB peak process RSS", + }, + ] + verdict = "yes" if passed else "no" + run["figures"][0]["results"] = { + "figure": "figs/configuration_weights.svg", + "numbers": { + "configurations": count, + "O++ configurations": component_counts["++"], + "negative weights": negative_count, + "minimum weight": f"{min(weights):.12e}", + "maximum weight": f"{max(weights):.12e}", + "max group residual": f"{max_group_residual:.3e}", + "max Fock relative error": f"{max_trace_relative_error:.3e}", + }, + "match": verdict, + "why": ( + "All preregistered physical configurations stayed in O++(4,4), " + "had nonnegative weights, and the independent Fock checks passed." + if passed + else "At least one preregistered structural or sign check failed." + ), + "wall": f"{total_wall:.3f} s total", + "changes": [numerical_change], + "rerun": rerun, + } + run["figures"][1]["results"] = { + "figure": "figs/diagnostic_residuals.svg", + "numbers": { + "on-site HS residual": f"{onsite_residual:.3e}", + "hopping Lie residual": f"{hopping_lie_residual:.3e}", + "max vertex Lie residual": f"{max_vertex_lie_residual:.3e}", + "max generator Lie residual": f"{max_generator_residual:.3e}", + "max group residual": f"{max_group_residual:.3e}", + "max Fock relative error": f"{max_trace_relative_error:.3e}", + }, + "match": verdict, + "why": ( + "The interaction identity, every generator, every group product, " + "and the Fock-space trace all met their preregistered tolerances." + if passed + else "At least one preregistered residual exceeded its tolerance." + ), + "wall": f"{total_wall:.3f} s total", + "changes": [numerical_change], + "rerun": rerun, + } + _atomic_write_json(run_path, run) + + print( + f"complete: status={result['status']} total={total_wall:.3f}s " + f"min_weight={min(weights):.6e} negatives={negative_count}", + flush=True, + ) + return result + + +def main(argv: Sequence[str] | None = None) -> int: + parser = argparse.ArgumentParser( + description="Run the approved four-site Hubbard sign-problem oracle." + ) + parser.add_argument( + "--run-dir", + type=Path, + required=True, + help="Directory containing the approved run.json.", + ) + args = parser.parse_args(argv) + result = run_approved_hubbard_oracle(args.run_dir.resolve()) + return 0 if result["status"] == "passed" else 2 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py b/tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py new file mode 100644 index 000000000..78bff2160 --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py @@ -0,0 +1,297 @@ +"""Theorem-grade anchors for the sign-problem determinant oracle.""" + +from fractions import Fraction +from pathlib import Path +import sys + +import numpy as np + +SOLUTION_DIR = Path(__file__).resolve().parent +sys.path.insert(0, str(SOLUTION_DIR)) + +import sign_problem_hunter as sph + + +def test_o11_analytic_benchmark_for_a_product(): + rapidities = np.array([0.7, -0.2, 1.1, -0.4]) + generators = [sph.o11_generator(value) for value in rapidities] + + numeric = sph.determinant_weight(generators) + analytic = sph.o11_analytic_determinant(rapidities) + + assert np.isclose(numeric, analytic, rtol=1e-13, atol=1e-13) + assert analytic >= 0.0 + + +def test_o11_generators_satisfy_split_lie_algebra_condition(): + eta = sph.split_metric(1) + + for value in (-2.0, 0.0, 0.3, 4.0): + generator = sph.o11_generator(value) + residual = generator.T @ eta + eta @ generator + assert np.linalg.norm(residual, ord="fro") < 1e-14 + + +def test_fock_lift_preserves_the_matrix_commutator(): + rng = np.random.default_rng(121) + a = rng.normal(size=(3, 3)) + b = rng.normal(size=(3, 3)) + + a_hat = sph.bilinear_fock_operator(a) + b_hat = sph.bilinear_fock_operator(b) + matrix_commutator_hat = sph.bilinear_fock_operator(a @ b - b @ a) + fock_commutator = a_hat @ b_hat - b_hat @ a_hat + + assert np.allclose( + fock_commutator, + matrix_commutator_hat, + rtol=1e-13, + atol=1e-13, + ) + + +def test_fock_trace_equals_single_particle_determinant_for_a_product(): + rng = np.random.default_rng(2026) + generators = [0.2 * rng.normal(size=(3, 3)) for _ in range(4)] + + fock_trace = sph.fock_trace_weight(generators) + determinant = sph.determinant_weight(generators) + + assert np.isclose(fock_trace, determinant, rtol=1e-12, atol=1e-12) + + +def test_vacuum_and_one_particle_sectors_have_expected_action(): + a = np.array( + [ + [0.3, -0.2], + [0.4, 0.7], + ] + ) + a_hat = sph.bilinear_fock_operator(a) + + # Occupation-basis order is |00>, |10>, |01>, |11>. + assert np.isclose(a_hat[0, 0], 0.0) + assert np.allclose(a_hat[np.ix_([1, 2], [1, 2])], a) + assert np.isclose(a_hat[3, 3], np.trace(a)) + + +def test_invalid_generator_shapes_are_rejected(): + for bad in (np.ones(3), np.ones((2, 3))): + try: + sph.bilinear_fock_operator(bad) + except ValueError: + pass + else: + raise AssertionError("a non-square generator must be rejected") + + +def test_random_split_generators_remain_in_identity_component(): + rng = np.random.default_rng(150605349) + + for n in (1, 2, 3): + eta = sph.split_metric(n) + for _ in range(12): + generators = [ + sph.random_split_generator(n, rng, scale=0.25) + for _ in range(5) + ] + for generator in generators: + assert sph.split_lie_residual(generator, eta) < 1e-13 + + product = sph.product_of_exponentials(generators) + assert sph.split_group_residual(product, eta) < 1e-11 + assert sph.classify_split_component(product, eta) == "++" + assert sph.determinant_i_plus(product) >= -1e-11 + + +def test_all_four_o11_components_have_the_theorem_signs(): + # This rational boost obeys M^T eta M = eta exactly: + # (5/3)^2 - (4/3)^2 = 1. + boost = np.array([[5 / 3, 4 / 3], [4 / 3, 5 / 3]]) + expected_sign = {"++": 1, "--": -1, "-+": 0, "+-": 0} + + for component, sign in expected_sign.items(): + matrix = sph.split_component_representative(1, component) @ boost + assert sph.classify_split_component(matrix) == component + weight = sph.determinant_i_plus(matrix) + if sign > 0: + assert weight > 0 + elif sign < 0: + assert weight < 0 + else: + assert np.isclose(weight, 0.0, atol=1e-14) + + +def test_o11_negative_control_has_an_exact_rational_certificate(): + # M = -[[5/3, 4/3], [4/3, 5/3]] is in O^{--}(1,1). + m00 = Fraction(-5, 3) + m01 = Fraction(-4, 3) + m10 = Fraction(-4, 3) + m11 = Fraction(-5, 3) + determinant = (1 + m00) * (1 + m11) - m01 * m10 + + assert determinant == Fraction(-4, 3) + + +def test_component_classifier_rejects_a_matrix_outside_the_group(): + not_split_orthogonal = np.array([[1.0, 0.2], [0.0, 1.0]]) + + try: + sph.classify_split_component(not_split_orthogonal) + except ValueError: + pass + else: + raise AssertionError("classification outside O(n,n) must be rejected") + + +def test_four_site_hubbard_generators_respect_the_split_grading(): + order = sph.four_site_orbital_order() + assert order == ( + (0, "up"), + (2, "up"), + (1, "down"), + (3, "down"), + (1, "up"), + (3, "up"), + (0, "down"), + (2, "down"), + ) + + eta = sph.split_metric(4) + hopping = sph.four_site_hopping_matrix(t_up=1.0, t_down=0.5) + assert sph.split_lie_residual(hopping, eta) < 1e-14 + assert hopping[sph.hubbard_orbital_index(0, "up"), sph.hubbard_orbital_index(1, "up")] == -1.0 + assert hopping[sph.hubbard_orbital_index(0, "down"), sph.hubbard_orbital_index(1, "down")] == -0.5 + + for site in range(4): + for field in (-1, 1): + vertex = sph.spin_flip_vertex(site, field, u=4.0, gamma=2.0) + assert sph.split_lie_residual(vertex, eta) < 1e-14 + + +def test_local_spin_flip_decomposition_is_an_operator_identity(): + residual = sph.onsite_spin_flip_decomposition_residual(u=4.0, gamma=2.0) + assert residual < 1e-13 + + +def test_configuration_protocol_covers_orders_zero_through_eight(): + configurations = sph.generate_hubbard_configurations( + count=18, + beta=2.0, + seed=121, + ) + + assert [len(config) for config in configurations] == list(range(9)) * 2 + for config in configurations: + assert all(0.0 <= vertex.tau <= 2.0 for vertex in config) + assert all(config[i].tau <= config[i + 1].tau for i in range(len(config) - 1)) + assert all(vertex.site in range(4) for vertex in config) + assert all(vertex.field in (-1, 1) for vertex in config) + + +def test_four_site_configuration_matches_direct_fock_trace(): + eta = sph.split_metric(4) + hopping = sph.four_site_hopping_matrix(t_up=1.0, t_down=0.5) + vertices = ( + sph.HubbardVertex(tau=0.35, site=2, field=1), + sph.HubbardVertex(tau=1.40, site=1, field=-1), + ) + generators = sph.hubbard_configuration_generators( + vertices, + beta=2.0, + hopping=hopping, + u=4.0, + gamma=2.0, + ) + + assert all(sph.split_lie_residual(generator, eta) < 1e-13 for generator in generators) + evolution = sph.product_of_exponentials(generators) + assert sph.split_group_residual(evolution, eta) < 1e-10 + assert sph.classify_split_component(evolution, eta) == "++" + + determinant = sph.determinant_i_plus(evolution) + fock_trace = sph.fock_trace_weight(generators) + assert determinant >= -1e-10 + assert np.isclose(fock_trace, determinant, rtol=1e-10, atol=1e-10) + + +def test_longdouble_group_diagnostic_handles_the_worst_approved_configuration(): + eta = sph.split_metric(4) + hopping = sph.four_site_hopping_matrix(t_up=1.0, t_down=0.5) + vertices = ( + sph.HubbardVertex(0.0687759266190473, 0, -1), + sph.HubbardVertex(0.6618829428460011, 0, -1), + sph.HubbardVertex(0.9252722309765289, 1, 1), + sph.HubbardVertex(1.3853364030460855, 0, 1), + sph.HubbardVertex(1.73922510662912, 0, 1), + sph.HubbardVertex(1.9050223820533136, 0, 1), + ) + generators = sph.hubbard_configuration_generators( + vertices, + beta=2.0, + hopping=hopping, + u=4.0, + gamma=2.0, + ) + + evolution, group_residual = sph.product_with_split_group_residual( + generators, + eta, + ) + + assert group_residual < 1e-10 + assert sph.classify_split_component(evolution, eta, atol=1e-9) == "++" + + +def test_structured_hubbard_propagators_match_scipy_expm(): + delta_tau = 0.37 + hopping = sph.four_site_hopping_matrix(t_up=1.0, t_down=0.5) + free_structured = sph.four_site_free_propagator( + delta_tau, + t_up=1.0, + t_down=0.5, + ) + assert np.allclose( + np.asarray(free_structured, dtype=float), + sph.expm(-delta_tau * hopping), + rtol=1e-13, + atol=1e-13, + ) + + vertex_generator = sph.spin_flip_vertex(3, -1, u=4.0, gamma=2.0) + vertex_structured = sph.spin_flip_propagator( + 3, + -1, + u=4.0, + gamma=2.0, + ) + assert np.allclose( + np.asarray(vertex_structured, dtype=float), + sph.expm(vertex_generator), + rtol=1e-13, + atol=1e-13, + ) + + +def test_structured_evolution_passes_the_worst_k8_absolute_residual(): + vertices = ( + sph.HubbardVertex(0.32142634473061626, 1, 1), + sph.HubbardVertex(0.49554339080676724, 1, 1), + sph.HubbardVertex(0.5546101111731154, 1, 1), + sph.HubbardVertex(0.9122143871600221, 0, -1), + sph.HubbardVertex(0.9503244428638153, 0, -1), + sph.HubbardVertex(1.5170827567965983, 3, 1), + sph.HubbardVertex(1.8229847193141804, 2, 1), + sph.HubbardVertex(1.854364905203545, 2, -1), + ) + evolution, group_residual = sph.hubbard_configuration_evolution( + vertices, + beta=2.0, + t_up=1.0, + t_down=0.5, + u=4.0, + gamma=2.0, + ) + + assert group_residual < 1e-10 + assert sph.classify_split_component(evolution, atol=1e-9) == "++" diff --git a/tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json b/tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json new file mode 100644 index 000000000..adb6b71ce --- /dev/null +++ b/tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json @@ -0,0 +1,33 @@ +{ + "figures": [ + { + "id": "Eq. (4) oracle", + "results": {} + }, + { + "id": "Eq. (10) Hubbard realization", + "results": {} + } + ], + "method": { + "settings": { + "configuration_count": 256, + "fock_cross_checks": "configuration indices 0, 1, and 4", + "group_tolerance": 1e-10, + "lie_tolerance": 1e-12, + "random_seed": 121, + "trace_determinant_tolerance": 1e-10, + "weight_tolerance": 1e-10 + } + }, + "model": { + "couplings": { + "$U$": 4.0, + "$\\Gamma$": 2.0, + "$\\beta$": 2.0, + "$\\mu$": 0.0, + "$t_\\downarrow$": 0.5, + "$t_\\uparrow$": 1.0 + } + } +} From 7f3050e2afd326574c5ca610b67131ccd1a2d4a1 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Wed, 29 Jul 2026 22:48:53 +0800 Subject: [PATCH 02/13] qmc: clarify issue 121 claim status --- tracks/qmc/solutions/mao-kexiang-121/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tracks/qmc/solutions/mao-kexiang-121/README.md b/tracks/qmc/solutions/mao-kexiang-121/README.md index 86cc6f5d8..6410e17f1 100644 --- a/tracks/qmc/solutions/mao-kexiang-121/README.md +++ b/tracks/qmc/solutions/mao-kexiang-121/README.md @@ -12,7 +12,7 @@ | Row | | |---|---| | **Challenge** | Find structured fermionic Gaussian-vertex sets with det(I + product exp(A_i)) >= 0 beyond the known split-orthogonal and fixed-metric semigroup principles, and map any survivor to an interacting QMC weight. | -| **Catalog issue** | `Addresses #121` — “Sign-problem free hunter,” released by Lei Wang, Institute of Physics, Chinese Academy of Sciences. | +| **Catalog issue** | Addresses #121 - Sign-problem free hunter, released by Lei Wang, Institute of Physics, Chinese Academy of Sciences. | | **Track** | `tracks/qmc/` — from the issue's `Method: Quantum Monte Carlo` field. | ## Bottom line @@ -148,4 +148,4 @@ Final A/B-specific randomized validation is not yet included; the earlier A/D/F | Exclude every alternative positive decomposition of the same Hamiltonian | Incomplete and not claimed. | | Public MathOverflow/arXiv endgame and external review | Not yet done. | -For these reasons the PR uses `Addresses #121`, not `Closes #121`. The core matrix question has a serious candidate answer; the strongest physical interpretation of the challenge has not yet been solved. +For these reasons this is a non-closing PR that addresses #121. The core matrix question has a serious candidate answer; the strongest physical interpretation of the challenge has not yet been solved. From 8d8874d8e27100d220154289f33ac3a8d7f7c18c Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Wed, 29 Jul 2026 22:57:24 +0800 Subject: [PATCH 03/13] qmc: rename team to Genshin_Impact --- .../{mao-kexiang-121 => Genshin_Impact-121}/README.md | 10 +++++----- .../finite_density_extension.md | 0 .../main_theorem.md | 0 .../novelty_audit.md | 0 .../physical_realization.md | 0 .../reduction_checklist.md | 0 .../requirements.txt | 0 .../sign_problem_hunter.py | 0 .../test_sign_problem_hunter.py | 0 .../wang2015_run_template.json | 0 10 files changed, 5 insertions(+), 5 deletions(-) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/README.md (96%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/finite_density_extension.md (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/main_theorem.md (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/novelty_audit.md (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/physical_realization.md (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/reduction_checklist.md (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/requirements.txt (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/sign_problem_hunter.py (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/test_sign_problem_hunter.py (100%) rename tracks/qmc/solutions/{mao-kexiang-121 => Genshin_Impact-121}/wang2015_run_template.json (100%) diff --git a/tracks/qmc/solutions/mao-kexiang-121/README.md b/tracks/qmc/solutions/Genshin_Impact-121/README.md similarity index 96% rename from tracks/qmc/solutions/mao-kexiang-121/README.md rename to tracks/qmc/solutions/Genshin_Impact-121/README.md index 6410e17f1..aa5d4852d 100644 --- a/tracks/qmc/solutions/mao-kexiang-121/README.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/README.md @@ -4,7 +4,7 @@ | | | |---|---| -| **Team name** | Mao-Kexiang | +| **Team name** | Genshin_Impact | | **Members** | Kexiang Mao ([@Mao-Kexiang](https://github.com/Mao-Kexiang)) | ## Challenge @@ -108,16 +108,16 @@ It includes analytic O(1,1), randomized O(n,n) identity-component positive contr The code was developed with Python 3.13.9. From the repository root, install the minimal dependencies and run the regression tests with ```bash -python -m pip install -r tracks/qmc/solutions/mao-kexiang-121/requirements.txt -python -m pytest -q tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py +python -m pip install -r tracks/qmc/solutions/Genshin_Impact-121/requirements.txt +python -m pytest -q tracks/qmc/solutions/Genshin_Impact-121/test_sign_problem_hunter.py ``` These team-local tests are not discovered by the repository's default `make test` target. To reproduce the complete preregistered Wang-2015 baseline of 256 configurations at orders 0 through 8, including three independent 256-dimensional Fock checks, use the committed manifest: ```bash run_dir="$(mktemp -d)" -cp tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json "$run_dir/run.json" -python tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py --run-dir "$run_dir" +cp tracks/qmc/solutions/Genshin_Impact-121/wang2015_run_template.json "$run_dir/run.json" +python tracks/qmc/solutions/Genshin_Impact-121/sign_problem_hunter.py --run-dir "$run_dir" ``` Final A/B-specific randomized validation is not yet included; the earlier A/D/F development harness was excluded as superseded. The arbitrary-word A/B statement currently rests on the analytic common-norm proof and the internal proof audit. No new scientific calculation was run merely to prepare this PR. diff --git a/tracks/qmc/solutions/mao-kexiang-121/finite_density_extension.md b/tracks/qmc/solutions/Genshin_Impact-121/finite_density_extension.md similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/finite_density_extension.md rename to tracks/qmc/solutions/Genshin_Impact-121/finite_density_extension.md diff --git a/tracks/qmc/solutions/mao-kexiang-121/main_theorem.md b/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/main_theorem.md rename to tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md diff --git a/tracks/qmc/solutions/mao-kexiang-121/novelty_audit.md b/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/novelty_audit.md rename to tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md diff --git a/tracks/qmc/solutions/mao-kexiang-121/physical_realization.md b/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/physical_realization.md rename to tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md diff --git a/tracks/qmc/solutions/mao-kexiang-121/reduction_checklist.md b/tracks/qmc/solutions/Genshin_Impact-121/reduction_checklist.md similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/reduction_checklist.md rename to tracks/qmc/solutions/Genshin_Impact-121/reduction_checklist.md diff --git a/tracks/qmc/solutions/mao-kexiang-121/requirements.txt b/tracks/qmc/solutions/Genshin_Impact-121/requirements.txt similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/requirements.txt rename to tracks/qmc/solutions/Genshin_Impact-121/requirements.txt diff --git a/tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py b/tracks/qmc/solutions/Genshin_Impact-121/sign_problem_hunter.py similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/sign_problem_hunter.py rename to tracks/qmc/solutions/Genshin_Impact-121/sign_problem_hunter.py diff --git a/tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py b/tracks/qmc/solutions/Genshin_Impact-121/test_sign_problem_hunter.py similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/test_sign_problem_hunter.py rename to tracks/qmc/solutions/Genshin_Impact-121/test_sign_problem_hunter.py diff --git a/tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json b/tracks/qmc/solutions/Genshin_Impact-121/wang2015_run_template.json similarity index 100% rename from tracks/qmc/solutions/mao-kexiang-121/wang2015_run_template.json rename to tracks/qmc/solutions/Genshin_Impact-121/wang2015_run_template.json From 9fe85a6317132983b48c12cbe3628b2da2945a19 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 02:10:29 +0800 Subject: [PATCH 04/13] qmc: preregister issue 121 full verification --- .../external_review_draft.md | 280 ++ .../finite_density_extension.md | 97 +- .../Genshin_Impact-121/issue121_full_run.json | 240 ++ .../issue121_verification.py | 2317 +++++++++++++++++ .../Genshin_Impact-121/main_theorem.md | 205 +- .../Genshin_Impact-121/novelty_audit.md | 61 +- .../physical_realization.md | 347 ++- .../Genshin_Impact-121/reduction_checklist.md | 27 +- .../Genshin_Impact-121/requirements.txt | 1 + .../test_issue121_verification.py | 494 ++++ 10 files changed, 4009 insertions(+), 60 deletions(-) create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/test_issue121_verification.py diff --git a/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md b/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md new file mode 100644 index 000000000..4c51d8eac --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md @@ -0,0 +1,280 @@ +# External expert review draft: a contractive matrix family for issue #121 + +Status: draft for public technical review. + +This text evaluates the mathematical and physical claims on their present scope. +It is not an endorsement of novelty or a substitute for independent reproduction. + +## Executive assessment + +The submission proposes an explicit open family of real one-body generators. +Every finite word generated from that family has a nonnegative determinant weight. +The relevant weight is det(I+T), with T a product of one-particle propagators. + +The main positivity mechanism is a common ell_infinity contraction, not total nonnegativity. +This distinction is conceptually useful for quantum Monte Carlo sign-problem searches. +The construction also includes algebraic tests intended to separate it from familiar sufficient criteria. + +Those separation tests are meaningful only within the precisely stated representation class. +They do not prove that the family has never appeared in an equivalent formulation. + +The proposed many-body realization uses overlapping S3-twirled Gaussian vertices. +It is interacting and non-Gaussian at the operator level for sufficiently small positive tau. +Its continuous-time operator-string expansion nevertheless has nonnegative configuration weights. + +In my view, the package is promising enough for specialist review after full reproducibility artifacts are posted. +The current appropriate recommendation is "major technical verification," not unconditional acceptance. + +## Background and relation to issue #121 + +Issue #121 asks for useful sets of matrices whose finite products obey + + det(I+T) >= 0. + +Here T has the ordered-product form + + T = exp(A_m) ... exp(A_2) exp(A_1). + +In auxiliary-field or continuous-time fermion methods, this determinant is a Fock-space trace. +For number-conserving bilinears, the identity is + + Tr_Fock[Gamma(T)] = det(I+T). + +Thus a matrix-semigroup condition can become a configuration-wise sign-free condition. +The challenge is not positivity for one specially chosen matrix. +The challenge is positivity for arbitrary word length, ordering, times, embeddings, and allowed parameters. +The proposed answer addresses that stronger closure requirement. + +## The A/B family + +The wider seven-parameter generator is + + A(theta) = [ -a-b-delta_1 a -b ] + [ 0 -c-delta_2 c ] + [ d 0 -d-delta_3 ], + +where a,b,c,d,delta_1,delta_2,delta_3 are positive. +Let + + S = diag(1,1,-1) + +and define + + B(theta) = S A(theta) S. + +Permutation conjugates P A P^T and P B P^T are included in the local alphabet. + +The concrete rational point used in the draft is a specialization, not an isolated solution. +It sets a=c=1, d=2, b=epsilon, and delta_1=delta_2=delta_3=kappa. +At that point + + A(epsilon,kappa) = [ -1-epsilon-kappa 1 -epsilon ] + [ 0 -1-kappa 1 ] + [ 2 0 -2-kappa ]. + +The displayed numerical example epsilon=1/100 and kappa=1/1000 lies inside an open parameter region. +It should therefore be presented as a convenient exact certificate point. +It should not be described as the only matrix that works. + +## Arbitrary-depth positivity from a common ell_infinity contraction + +For any real matrix X, define its logarithmic ell_infinity norm by + + mu_infinity(X) = max_i [X_ii + sum_(j != i) |X_ij|]. + +Each row of A(theta) has logarithmic rate exactly -delta_i. +Conjugation by S changes signs but preserves the absolute row sums. +Permutation conjugation merely reorders the same row estimates. + +Consequently every allowed local generator X obeys + + mu_infinity(X) <= -delta_min < 0, + +where delta_min=min(delta_1,delta_2,delta_3). +For propagation time t>=0, the logarithmic-norm estimate gives + + ||exp(tX)||_infinity <= exp(-t delta_min) <= 1. + +Submultiplicativity then applies to every finite word without a depth restriction. +For a strictly three-dimensional word with positive total time, one obtains ||T||_infinity<1. + +For a local three-site block embedded in a larger one-particle space, spectator directions contribute identity blocks. +The embedded factor therefore satisfies the non-strict bound ||T_factor||_infinity<=1. +Products of differently embedded factors retain ||T||_infinity<=1. + +Hence every eigenvalue lambda of T satisfies |lambda|<=1. +Real eigenvalues contribute factors 1+lambda>=0 to det(I+T). +Nonreal eigenvalues occur in conjugate pairs and contribute |1+lambda|^2>=0. + +It follows that + + det(I+T) >= 0 + +for arbitrary finite depth and arbitrary ordering of allowed factors. + +This proof allows a zero determinant when an embedded word develops an eigenvalue -1. +It does not replace nonnegativity by an unjustified strict-positivity claim. + +It also makes clear why the exact entries of the example are not essential. +Positivity persists throughout any parameter region that keeps all row rates negative. + +## Separation from several standard sufficient structures + +The draft supplies a no-common-H certificate for the A/B orbit. +The tested condition is the existence of one positive-definite quadratic form H shared by every generator. +At the rational point, the A and B inequalities reduce to incompatible exact rational bounds. + +The seven-parameter version uses a test vector x=(1,1,t), with 00, the A inequality requires a scalar r<0 while the B inequality requires r>0. + +Equivalently, the exact Farkas combination gives + + (p_t+q_t)G_t <= 0, + +contradicting p_t>0, q_t>0, and G_t>0. + +At the stated point and t=3/4, the draft records + + G_t=1679/16000, + p_t=10109/16000, + q_t=15375/16000. + +These values should be regenerated by exact rational arithmetic in the public verifier. + +The orbit also reportedly has exact rational span rank nine in M_3(R). +That full-span result rules out an explanation confined to a proper linear subspace of 3x3 matrices. +Together, full span and no common H strengthen the claim that the ell_infinity mechanism is structurally distinct. + +The draft further gives a fixed, same-dimensional Wei/CAR separation argument. +The intended conclusion is limited: no single allowed same-dimensional one-body basis change places the full alphabet in the compared Wei cone. +The sign convention for the Wei linear matrix inequality must be stated explicitly. +Using eta versus -eta reverses the displayed inequality and can otherwise look like a sign error. + +This separation does not cover enlarged ancilla spaces. +It does not cover configuration-dependent changes of basis. +It does not cover nonlinear rewritings or a different Hubbard-Stratonovich decomposition. +It also does not establish global inequivalence to every known sign-free formulation. + +## Interacting S3-twirled physical model + +For X=A or B, define the local Fock-space twirl + + M_X(tau) = (1/6) sum_(sigma in S3) Gamma(exp(tau P_sigma X P_sigma^T)). + +The individual Gaussian vertices need not be Hermitian. +The complete S3 average is Hermitian by its sector decomposition. +Overlapping copies are placed on triangular subsets of a lattice or hypergraph. + +With positive couplings g_A and g_B, the shifted Hamiltonian is + + H_bar = sum_Delta [g_A(I-M_A,Delta)+g_B(I-M_B,Delta)] + = G_0 I - V. + +Here V is the positive linear combination of all resolved Gaussian vertices. +The identity shift is physically and statistically important. + +Each twirl acts as one on the Fock vacuum, so H_bar annihilates the vacuum. +For the finite four-site benchmark, the verifier should check H_bar>=0 within tolerance. +The operator is not merely a quadratic free-fermion Hamiltonian. + +At epsilon=1/100 and kappa=1/1000, exact Taylor coefficients give interaction certificates + + I_A=15062013/3000000, + I_B=3056033/3000000, + +and non-Gaussian certificates + + G_A=363599/360000, + G_B=797/120000. + +All four multiply tau^2 at leading nonzero order. +Their nonzero values imply interaction and failure of Gaussian closure for sufficiently small positive tau. +This is an analytic local statement, not evidence that every tau is admissible. + +## Positive continuous-time expansion + +Write the resolved vertex activities as lambda_alpha>0 and let G_0=sum_alpha lambda_alpha. +Expanding exp(-beta H_bar) gives the ordered-string series + + Z_bar = exp(-beta G_0) sum_m beta^m/m! sum_(alpha_1...alpha_m) lambda_alpha_1...lambda_alpha_m det(I+U_m...U_1). + +Every scalar coefficient is nonnegative. +Every determinant is nonnegative by the common ell_infinity argument. +Thus every resolved configuration has nonnegative weight. + +An equivalent audit samples m from Poisson(beta G_0). +Conditional labels are sampled with probability lambda_alpha/G_0. +Under that normalized measure, the unbiased estimator of Z_bar is simply det(I+U_m...U_1). + +No extra factor exp(+beta G_0) belongs in the shifted estimator. +The one-particle determinant should also be compared with an independent direct Fock-space trace. +Time ordering should be identical in those two calculations. + +## Reproducibility package expected for review + +- Issue discussion: [quantum.harness issue #121](https://github.com/QuantumBFS/quantum.harness/issues/121) +- Verifier source: [permanent source link to be inserted](VERIFIER_PERMALINK_TBD) +- Preregistered manifest: [manifest permalink to be inserted](MANIFEST_PERMALINK_TBD) +- Exact certificate output: [artifact link to be inserted](EXACT_CERTIFICATE_ARTIFACT_TBD) +- Full sampled report and hashes: [artifact link to be inserted](FULL_REPORT_ARTIFACT_TBD) +- Independent archival snapshot: [DOI or immutable archive to be inserted](ARCHIVE_DOI_TBD) + +The verifier should preregister dimensions, word depths, parameter regimes, and sample counts. +It should include center, near-boundary, weak-damping, and random interior points. +It should include d<=8 direct Fock checks and exact Fraction certificates. + +Known O(n,n) and Wei-semigroup controls should appear as positive and negative controls. +All four O(n,n) connected components should be sampled, including negative and exact-zero branches. +Near-singular determinants should trigger reproducible high-precision rebuilding rather than clipping. + +Every cell should be atomically written with a deterministic seed and content hash. +A COMPLETE sentinel should be created only after all preregistered checks pass. +Until those immutable artifacts exist, numerical statements should be labeled planned or provisional. + +## Scope and limitations + +This work does not by itself prove literature priority. +A documented search can support novelty assessment but cannot establish universal absence. + +The fixed-dimensional separation does not exclude an ancilla-assisted representation. +It does not exclude an alternative Hubbard-Stratonovich channel. +It does not exclude a different Gaussian support for the same many-body operator. + +The demonstrated shifted model has a vacuum state with zero energy. +The present benchmark is therefore not a finite-density metallic example. +The construction is not the standard repulsive or attractive Hubbard model. +Calling it "Hubbard" without qualification would obscure its S3-twirled multi-site structure. + +The finite four-site calculation is a validation fixture, not a thermodynamic phase study. +Sign-free configuration weights do not alone imply an efficient autocorrelation time. +The physical accessibility of the interactions remains a separate question. + +## Questions for the authors + +1. Please state the exact maximal open parameter cone currently proved, rather than only sufficient slices of it. + +2. Please write the fixed same-dimensional Wei/CAR separation as a standalone theorem with its sign convention and allowed transformations explicit. + +3. Please identify which parts of the novelty search were checked against primary literature and which possible equivalences remain unresolved. + +4. Please provide an independent reproduction of every Fraction certificate, all four O(n,n) controls, and the full preregistered row counts from the immutable manifest. + +5. Please determine whether a non-vacuum or finite-density extension preserves configuration-wise positivity without doubling by a conjugate flavor. + +6. Please identify lattice-scale observables or phases that distinguish this model from a formally sign-free but physically trivial projector construction. + +## Provisional recommendation + +The arbitrary-depth contraction proof is short, transparent, and potentially reusable. +The open seven-parameter family makes the result more meaningful than one numerical matrix. +The no-common-H and full-span certificates are valuable diagnostics when kept within scope. +The interacting twirl supplies a concrete route from matrix algebra to a many-body operator expansion. + +Publication value will depend on three remaining standards. + +First, the theorem and representation-class boundaries must survive specialist scrutiny. +Second, the complete preregistered verifier must be independently reproducible. +Third, the literature audit must justify a carefully worded novelty claim. + +Subject to those conditions, I would encourage a full technical submission rather than dismiss the construction as a numerical curiosity. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/finite_density_extension.md b/tracks/qmc/solutions/Genshin_Impact-121/finite_density_extension.md index 6858b2043..beac13b3c 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/finite_density_extension.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/finite_density_extension.md @@ -7,7 +7,10 @@ the local spectra, and the exclusion of a common one-particle indefinite metric proved below. The current lattice construction is a grand-canonical, cell-factorized fermion embedding with no intercell hopping. Positivity after projection to one particle per cell, equivalence to every possible 6-by-6 Majorana/MTR representation, -and literature priority are not proved. +and literature priority are not proved. Finite density is an optional physical +extension, not an acceptance condition of issue #121. Nothing in this note should +be read as weakening the complete interacting finite-temperature realization in +`physical_realization.md`. ## Executive result @@ -111,6 +114,50 @@ This allows a finite z>1 window. It does not allow a fixed positive chemical potential for all inverse temperatures, because z=exp(beta mu) is unbounded as beta tends to infinity. +### Exact particle-sector ceiling from a low compound contraction + +The determinant theorem and the ground-state filling question are distinct. The +following proposition gives the precise obstruction for Hermitian positive +Gaussian Hamiltonian terms. + +Let G_a be real symmetric positive definite, let g_a≥0, and define + + H=−sum_a g_a Γ(G_a). + +Fix r≥1. If one Euclidean exterior norm obeys + + ||wedge^r G_a||₂≤q<1 + +for every a, then no sector with N≥r can be a ground sector. Indeed, if +s₁≥...≥s_n>0 are the singular values of G_a, then + + s₁...s_r≤q, s_r<1, + +and for every N≥r, + + ||wedge^N G_a||₂=s₁...s_N≤s₁...s_r≤q. + +Since wedge^N G_a is positive definite, + + E_min(H restricted to wedge^N V)≥−q sum_a g_a + >−sum_a g_a=E_vac. (4) + +The same proof applies to a Hermitian twirl or positive convex average when every +resolved positive Gaussian obeys the same bound. Thus r=1 reproduces the vacuum +no-go. A global r=2 certificate permits at most one particle in the ground state; +a fixed r can never support nonzero density as the volume tends to infinity. To +place N≈νn particles using this particular ceiling mechanism, r must exceed N and +therefore scale at least linearly with n. + +For one D4 cell, r=2 and q=ab<1, so (4) excludes N≥2 while the Perron direction +allows N=1 to beat the vacuum. This is the intended local escape. It must not be +misstated as a global total-particle bound for the cell-factorized lattice: a local +embedding has spectator identity directions, and a direct sum of two cells has +wedge² components G_i tensor G_j. Two cells may each have one expanding Perron mode, +so the strict global second-compound bound fails. Extensive occupancy in the +current model comes only from fixed-cell factorization, not from tensorization of +the one-expanding-mode theorem. + ## 2. Exact D4 polyhedral family Work in R^3 with basis e0,e1,e2 and the square cone @@ -366,6 +413,44 @@ Allowing one-particle hopping between cells destroys block factorization. A scal replacement must control an extensive number of expanding channels without reducing to a fixed occupied subspace, total nonnegativity, or a Kramers square. +### Exact cell-hopping no-go for the present certificate + +The absence of intercell hopping is not merely a choice made in the example. It is +forced by preserving the full one-particle-per-cell subspace. Let + + V=direct-sum_(i=1)^L V_i, dim V_i≥2, + +and identify + + W=(wedge^1 V₁) wedge ... wedge (wedge^1 V_L) + +with the Fock subspace containing exactly one particle in every cell. If a +number-conserving one-body generator h satisfies + + dGamma(h)W is a subset of W, (5) + +then h is block diagonal in the cells. + +To prove this, write h_ij:V_j→V_i for an off-diagonal block. Acting on +v₁ wedge ... wedge v_L, h_ij replaces v_j by h_ij v_j and produces a component +with two particles in cell i and a hole in cell j. Different occupancy patterns +are linearly independent and cannot cancel. If h_ij v_j is nonzero, dim V_i≥2 +allows v_i to be chosen nonparallel to it, so the wedge is nonzero. Condition (5) +for every vector in W therefore forces h_ij=0 for every i≠j. + +The same conclusion holds if the certificate preserves a full-dimensional proper +cone C_cell inside W: span(C_cell)=W, so linear invariance of the cone implies (5). +Discrete permutations of entire cells can preserve W, but they are disconnected +relabelings and become qutrit/spin exchange after fixing one particle per cell; +they are not continuous charge hopping. + +This proposition concerns the whole subspace W, not one decomposable wedge ray. A +single fixed ray only forces a block-triangular invariant plane, and must not be +used to claim block diagonalization. Genuine itinerancy therefore requires a new +cone spanning charge-fluctuating cell sectors, or a word-dependent extensive +unstable bundle; it cannot be obtained by a small hopping perturbation that keeps +the present tensor-cell certificate. + ## 7. General fixed-splitting no-go Suppose the one-particle space has one common invariant splitting @@ -413,6 +498,16 @@ of T has even algebraic multiplicity. Complex pairs contribute positive quadrati factors, positive real eigenvalues never vanish for z>0, and an odd-multiplicity negative eigenvalue creates a sign-changing positive root z=-1/lambda. +Strict positivity for all z>0 is equivalent to having no negative real eigenvalue. +For a real 3-by-3 word with detT>0, all-z nonnegativity therefore permits either no +negative real spectrum or one exactly degenerate negative pair; two distinct +negative eigenvalues create a negative interval between their positive roots. + +For the S3 Hamiltonian in `physical_realization.md`, a uniform chemical potential +produces z=exp(βμ). Hence fixed μ>0 over arbitrarily large β requires this criterion +for every word. The current z=1 contraction proof does not establish it, so that +finite-density route remains open rather than disproved. + Thus positivity at z=1 is much weaker than positivity at arbitrary positive chemical potential for all beta. A common norm alone cannot provide the latter. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json b/tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json new file mode 100644 index 000000000..89d9c8f58 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json @@ -0,0 +1,240 @@ +{ + "schema_version": 1, + "protocol_name": "Genshin_Impact issue 121 full preregistered audit", + "seed": 1212026, + "candidate": { + "description": "Locally embedded three-mode A/B orbit words", + "dimensions": [ + 3, + 4, + 6, + 8, + 12 + ], + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "samples_per_cell": 256, + "regimes": [ + { + "id": "center", + "kind": "fixed", + "epsilon": "1/100", + "kappa": "1/1000" + }, + { + "id": "near_boundary", + "kind": "fixed", + "epsilon": "1/100", + "kappa": "1599/59000", + "note": "40 epsilon + 59 kappa = 1999/1000" + }, + { + "id": "kappa_to_zero", + "kind": "fixed", + "epsilon": "1/100", + "kappa": "1/1000000" + }, + { + "id": "dirichlet_open_triangle", + "kind": "dirichlet_open_triangle", + "alpha": [ + 1.0, + 1.0, + 1.0 + ], + "map": "epsilon=x/20, kappa=2y/59" + } + ], + "time_distribution": { + "kind": "log_uniform", + "minimum": "1e-3", + "maximum": "5" + } + }, + "positive_anchors": { + "split_orthogonal": { + "description": "Identity component of O(n,n)", + "n_values": [ + 1, + 2, + 3, + 4 + ], + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "samples_per_cell": 64, + "generator_scale": 0.15, + "time_distribution": { + "kind": "log_uniform", + "minimum": "1e-3", + "maximum": "0.5" + } + }, + "semigroup_cone": { + "description": "Wei semigroup A^T eta + eta A positive semidefinite", + "n_values": [ + 1, + 2, + 3, + 4 + ], + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "samples_per_cell": 64, + "split_generator_scale": 0.1, + "dissipation_strength": { + "minimum": 0.01, + "maximum": 0.15 + }, + "rank_tolerance": "1e-10", + "time_distribution": { + "kind": "log_uniform", + "minimum": "1e-3", + "maximum": "0.5" + } + } + }, + "component_controls": { + "description": "All four O(1,1) components", + "components": [ + "++", + "--", + "-+", + "+-" + ], + "n_values": [ + 1 + ], + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "samples_per_cell": 32, + "generator_scale": 0.15, + "time_distribution": { + "kind": "log_uniform", + "minimum": "1e-3", + "maximum": "0.5" + } + }, + "fock_oracle": { + "maximum_dimension": 8, + "sample_indices": [ + 0, + 127, + 255 + ], + "absolute_tolerance": "5e-8", + "relative_tolerance": "5e-9" + }, + "thresholds": { + "contraction_abs": "5e-10", + "split_lie_abs": "5e-10", + "split_group_abs": "5e-8", + "semigroup_generator_eigenvalue_abs": "5e-10", + "semigroup_product_eigenvalue_abs": "5e-8", + "component_zero_sigma": "5e-9" + }, + "determinant_precision": { + "sigma_min_escalation": "1e-9", + "mpmath_dps": 100, + "high_precision_zero_tolerance": "1e-60", + "high_precision_imag_tolerance": "1e-60" + }, + "twirl_checks": { + "epsilon": "1/100", + "kappa": "1/1000", + "tau": "1/10", + "hermiticity_tolerance": "1e-11", + "nongaussian_gap_minimum_abs": "1e-8" + }, + "physical_benchmark": { + "description": "Four-site OBC shifted-Hbar convention", + "sites": 4, + "boundary": "open", + "triangles": [ + [ + 0, + 1, + 2 + ], + [ + 1, + 2, + 3 + ] + ], + "epsilon": "1/100", + "kappa": "1/1000", + "tau": "1/10", + "couplings": { + "A": "1/4", + "B": "1/4" + }, + "chemical_potential": "0", + "betas": [ + "1/4", + "1/2", + "1", + "2" + ], + "seed": 1212026, + "poisson_samples_per_beta": 4096, + "confidence_sigma": 8.0, + "relative_error_floor": 0.01, + "weight_tolerance": "1e-9", + "hermiticity_tolerance": "1e-11", + "partition_imag_tolerance": "1e-9", + "deterministic_truncation_order": 24, + "deterministic_roundoff_allowance": "1e-10" + }, + "expected_workload": { + "candidate_cells": 140, + "candidate_words": 35840, + "split_cells": 28, + "split_words": 1792, + "semigroup_cells": 28, + "semigroup_words": 1792, + "component_cells": 28, + "component_words": 896, + "total_cells": 224, + "total_words": 40320, + "fock_oracle_checks": 336, + "physical_poisson_words": 16384, + "total_random_words_including_physical": 56704 + }, + "execution": { + "platform": "t02-server Slurm CPU job", + "cpus_per_task": 1, + "memory_mb": 2048, + "time_limit_minutes": 20, + "gpus": 0, + "durability": "atomic cells, protocol-bound resume, all-pass COMPLETE" + } +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py b/tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py new file mode 100644 index 000000000..ae610d2f0 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py @@ -0,0 +1,2317 @@ +#!/usr/bin/env python3 +"""Preregistered verification harness for quantum.harness issue 121. + +Random-word runs are implementation audits, not proofs. Exact certificates +record the algebraic statements used by the theorem draft. Durable outputs are +atomic and COMPLETE is created only when every preregistered cell passes. +""" + +from __future__ import annotations + +import argparse +import csv +import hashlib +from itertools import combinations, permutations +import json +import math +import os +from dataclasses import dataclass +from datetime import datetime, timezone +from fractions import Fraction +from pathlib import Path +import subprocess +import sys +import time +from typing import Any, Sequence + +import mpmath as mp +import numpy as np +import scipy +from scipy.linalg import expm + +SOLUTION_DIR = Path(__file__).resolve().parent +sys.path.insert(0, str(SOLUTION_DIR)) +import sign_problem_hunter as sph + +Array = np.ndarray +CSV_FIELDS = ( + "cell_id", "kind", "sample", "dimension", "n", "depth", "regime", + "component", "det_class", "det_method", "det_sign", "log_abs_det", + "determinant_decimal", "sigma_min_i_plus_t", "structural_diagnostic", + "fock_checked", "fock_abs_error", "word_sha256", +) + + +@dataclass(frozen=True) +class Cell: + cell_id: str + kind: str + parameters: dict[str, Any] + + +def utc_now() -> str: + return datetime.now(timezone.utc).isoformat() + + +def canonical_json(payload: object) -> str: + return json.dumps(payload, sort_keys=True, separators=(",", ":"), ensure_ascii=False) + + +def sha256_bytes(data: bytes) -> str: + return hashlib.sha256(data).hexdigest() + + +def sha256_file(path: Path) -> str: + digest = hashlib.sha256() + with path.open("rb") as handle: + for block in iter(lambda: handle.read(1 << 20), b""): + digest.update(block) + return digest.hexdigest() + + +def atomic_write_text(path: Path, text: str) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + temporary = path.with_name(f".{path.name}.tmp-{os.getpid()}") + temporary.write_text(text, encoding="utf-8") + os.replace(temporary, path) + + +def atomic_write_json(path: Path, payload: object) -> None: + atomic_write_text(path, json.dumps(payload, indent=2, sort_keys=True) + "\n") + + +def atomic_write_csv(path: Path, rows: Sequence[dict[str, Any]]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + temporary = path.with_name(f".{path.name}.tmp-{os.getpid()}") + with temporary.open("w", newline="", encoding="utf-8") as handle: + writer = csv.DictWriter(handle, fieldnames=CSV_FIELDS, extrasaction="raise") + writer.writeheader() + writer.writerows(rows) + os.replace(temporary, path) + + +def parse_fraction(value: Any) -> Fraction: + if isinstance(value, Fraction): + return value + if isinstance(value, int): + return Fraction(value) + if isinstance(value, float): + return Fraction(str(value)) + if isinstance(value, str): + return Fraction(value) + raise TypeError(f"cannot parse Fraction from {type(value).__name__}") + +def fraction_string(value: Fraction) -> str: + return str(value.numerator) if value.denominator == 1 else f"{value.numerator}/{value.denominator}" + + +def permutation_matrices_3() -> tuple[tuple[tuple[int, ...], Array], ...]: + return tuple( + (perm, np.eye(3, dtype=float)[list(perm), :]) + for perm in permutations(range(3)) + ) + + +def ab_generator(epsilon: Any, kappa: Any, family: str = "A") -> Array: + eps = float(parse_fraction(epsilon)) + kap = float(parse_fraction(kappa)) + if eps <= 0.0 or kap <= 0.0 or 40.0 * eps + 59.0 * kap >= 2.0: + raise ValueError( + "A/B parameters require epsilon>0, kappa>0, " + "40 epsilon + 59 kappa < 2" + ) + matrix = np.array( + [ + [-1.0 - eps - kap, 1.0, -eps], + [0.0, -1.0 - kap, 1.0], + [2.0, 0.0, -2.0 - kap], + ] + ) + if family == "A": + return matrix + if family == "B": + signs = np.diag([1.0, 1.0, -1.0]) + return signs @ matrix @ signs + raise ValueError("family must be A or B") + + +def ab_orbit(epsilon: Any, kappa: Any) -> tuple[tuple[str, int, Array], ...]: + result: list[tuple[str, int, Array]] = [] + for family in ("A", "B"): + base = ab_generator(epsilon, kappa, family) + for index, (_, permutation_matrix) in enumerate(permutation_matrices_3()): + result.append( + (family, index, permutation_matrix @ base @ permutation_matrix.T) + ) + return tuple(result) + + +def mu_infinity(matrix: Array) -> float: + square = np.asarray(matrix, dtype=float) + diagonal = np.diag(square) + row_values = diagonal + np.sum(np.abs(square), axis=1) - np.abs(diagonal) + return float(np.max(row_values)) + + +def fraction_ab_generator( + epsilon: Fraction, + kappa: Fraction, + family: str, +) -> list[list[Fraction]]: + matrix = [ + [-1 - epsilon - kappa, Fraction(1), -epsilon], + [Fraction(0), -1 - kappa, Fraction(1)], + [Fraction(2), Fraction(0), -2 - kappa], + ] + if family == "A": + return matrix + if family != "B": + raise ValueError("family must be A or B") + signs = (Fraction(1), Fraction(1), Fraction(-1)) + return [ + [signs[i] * matrix[i][j] * signs[j] for j in range(3)] + for i in range(3) + ] + + +def permute_fraction_matrix( + matrix: Sequence[Sequence[Fraction]], + perm: Sequence[int], +) -> list[list[Fraction]]: + return [[matrix[perm[i]][perm[j]] for j in range(3)] for i in range(3)] + + +def fraction_rank(rows: Sequence[Sequence[Fraction]]) -> int: + work = [list(map(parse_fraction, row)) for row in rows] + if not work: + return 0 + rank = 0 + column_count = len(work[0]) + for column in range(column_count): + pivot = next( + (row for row in range(rank, len(work)) if work[row][column] != 0), + None, + ) + if pivot is None: + continue + work[rank], work[pivot] = work[pivot], work[rank] + pivot_value = work[rank][column] + work[rank] = [value / pivot_value for value in work[rank]] + for row in range(len(work)): + if row == rank or work[row][column] == 0: + continue + multiplier = work[row][column] + work[row] = [ + work[row][entry] - multiplier * work[rank][entry] + for entry in range(column_count) + ] + rank += 1 + if rank == len(work): + break + return rank + + +def matmul_fraction( + left: Sequence[Sequence[Fraction]], + right: Sequence[Sequence[Fraction]], +) -> list[list[Fraction]]: + rows = len(left) + inner = len(right) + columns = len(right[0]) + return [ + [sum(left[i][k] * right[k][j] for k in range(inner)) for j in range(columns)] + for i in range(rows) + ] + + +def trace_fraction(matrix: Sequence[Sequence[Fraction]]) -> Fraction: + return sum(matrix[index][index] for index in range(len(matrix))) + + +def twirl_tau2_coefficients( + matrix: Sequence[Sequence[Fraction]], +) -> tuple[Fraction, Fraction]: + square = matmul_fraction(matrix, matrix) + a_value = sum(sum(row) for row in matrix) / 3 + b_value = sum(sum(row) for row in square) / 3 + trace_value = trace_fraction(matrix) + square_trace = trace_fraction(square) + interaction = ( + (trace_value**2 - square_trace) / 2 + - trace_value * a_value + + b_value + ) + non_gaussian = interaction - (trace_value - a_value) ** 2 / 4 + return interaction, non_gaussian + + +def determinant_2_fraction(matrix: Sequence[Sequence[Fraction]]) -> Fraction: + return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0] + + +def matmul_2_fraction( + left: Sequence[Sequence[Fraction]], + right: Sequence[Sequence[Fraction]], +) -> list[list[Fraction]]: + return [ + [sum(left[i][k] * right[k][j] for k in range(2)) for j in range(2)] + for i in range(2) + ] + + +def exact_component_weights() -> dict[str, str]: + boost = [ + [Fraction(5, 3), Fraction(4, 3)], + [Fraction(4, 3), Fraction(5, 3)], + ] + representatives = { + "++": [[Fraction(1), Fraction(0)], [Fraction(0), Fraction(1)]], + "--": [[Fraction(-1), Fraction(0)], [Fraction(0), Fraction(-1)]], + "-+": [[Fraction(-1), Fraction(0)], [Fraction(0), Fraction(1)]], + "+-": [[Fraction(1), Fraction(0)], [Fraction(0), Fraction(-1)]], + } + weights: dict[str, str] = {} + for component, representative in representatives.items(): + product = matmul_2_fraction(representative, boost) + shifted = [ + [ + product[i][j] + (Fraction(1) if i == j else Fraction(0)) + for j in range(2) + ] + for i in range(2) + ] + weights[component] = fraction_string(determinant_2_fraction(shifted)) + return weights + + +def exact_certificates(manifest: dict[str, Any]) -> dict[str, Any]: + center = next( + item for item in manifest["candidate"]["regimes"] if item["id"] == "center" + ) + epsilon = parse_fraction(center["epsilon"]) + kappa = parse_fraction(center["kappa"]) + numerator = 2 - 40 * epsilon - 59 * kappa + upper = -numerator / (13 * (2 - 8 * epsilon - 13 * kappa)) + lower = numerator / (7 * (6 + 8 * epsilon + 7 * kappa)) + + support: list[list[Fraction]] = [] + row_rates: list[Fraction] = [] + for family in ("A", "B"): + base = fraction_ab_generator(epsilon, kappa, family) + for perm in permutations(range(3)): + matrix = permute_fraction_matrix(base, perm) + support.append([value for row in matrix for value in row]) + for row in range(3): + row_rates.append( + matrix[row][row] + + sum( + abs(matrix[row][column]) + for column in range(3) + if column != row + ) + ) + + epsilon_star = Fraction(2, 3) + polynomial_minimum = ( + 2 * epsilon_star**3 + epsilon_star**2 - 4 * epsilon_star + 3 + ) + components = exact_component_weights() + + twirl_coefficients = { + family: twirl_tau2_coefficients( + fraction_ab_generator(epsilon, kappa, family) + ) + for family in ("A", "B") + } + expected_twirl_coefficients = { + "A": (Fraction(15062013, 3000000), Fraction(363599, 360000)), + "B": (Fraction(3056033, 3000000), Fraction(797, 120000)), + } + + t_value = Fraction(3, 4) + a_value = Fraction(1) + b_value = epsilon + c_value = Fraction(1) + d_value = Fraction(2) + delta_1 = delta_2 = delta_3 = kappa + g_value = ( + d_value * t_value * (1 - t_value) + - b_value * (1 + t_value) + - c_value * (1 - t_value) + - delta_1 - delta_2 - delta_3 * t_value**2 + ) + p_value = (2 + t_value) * ( + (1 - t_value) * (d_value - c_value) + - b_value * (1 + t_value) + - delta_1 - delta_2 - delta_3 * t_value + ) + q_value = (2 - t_value) * ( + (1 - t_value) * (c_value + d_value) + + b_value * (1 + t_value) + + delta_1 + delta_2 - delta_3 * t_value + ) + checks = { + "open_region": ( + epsilon > 0 and kappa > 0 and 40 * epsilon + 59 * kappa < 2 + ), + "all_exact_row_rates_minus_kappa": all( + value == -kappa for value in row_rates + ), + "opposite_edge_product": -2 * epsilon < 0, + "full_support_fraction_rank_9": fraction_rank(support) == 9, + "no_common_quadratic_bounds_disjoint": upper < 0 < lower, + "standard_polynomial_minimum_positive": ( + polynomial_minimum == Fraction(37, 27) + ), + "split_boost_identity": ( + Fraction(25, 9) - Fraction(16, 9) == 1 + ), + "component_weights": components + == {"++": "16/3", "--": "-4/3", "-+": "0", "+-": "0"}, + "twirl_tau2_coefficients": ( + twirl_coefficients == expected_twirl_coefficients + ), + "seven_parameter_t_3_4": ( + (g_value, p_value, q_value) + == (Fraction(1679, 16000), Fraction(10109, 16000), Fraction(15375, 16000)) + ), + } + return { + "schema_version": 1, + "status": "pass" if all(checks.values()) else "fail", + "parameters": { + "epsilon": fraction_string(epsilon), + "kappa": fraction_string(kappa), + }, + "certificates": { + "mu_infinity": fraction_string(-kappa), + "opposite_edge_product_A13_A31": fraction_string(-2 * epsilon), + "support_span_rank": fraction_rank(support), + "no_common_H_upper_bound": fraction_string(upper), + "no_common_H_lower_bound": fraction_string(lower), + "standard_polynomial": "2 epsilon^3 + epsilon^2 - 4 epsilon + 3", + "standard_polynomial_minimizer_nonnegative_axis": "2/3", + "standard_polynomial_minimum": fraction_string(polynomial_minimum), + "o11_component_det_I_plus": components, + "twirl_tau2": { + family: { + "interaction": fraction_string(values[0]), + "non_gaussian": fraction_string(values[1]), + } + for family, values in twirl_coefficients.items() + }, + "seven_parameter_at_t_3_4": { + "G": fraction_string(g_value), + "p": fraction_string(p_value), + "q": fraction_string(q_value), + }, + }, + "checks": checks, + "interpretation": ( + "Exact Fraction arithmetic; these certify formulas, not " + "literature priority." + ), + } + + +def load_manifest(path: Path) -> dict[str, Any]: + payload = json.loads(path.read_text(encoding="utf-8")) + validate_manifest(payload) + return payload + + +def validate_manifest(manifest: dict[str, Any]) -> None: + if manifest.get("schema_version") != 1: + raise ValueError("unsupported manifest schema_version") + candidate = manifest["candidate"] + regime_ids = [item["id"] for item in candidate["regimes"]] + if len(regime_ids) != len(set(regime_ids)) or "center" not in regime_ids: + raise ValueError("candidate regime ids must be unique and include center") + if min(candidate["dimensions"]) < 3: + raise ValueError("candidate dimensions must be at least three") + sample_count = int(candidate["samples_per_cell"]) + indices = list(manifest["fock_oracle"]["sample_indices"]) + if len(indices) != 3 or len(set(indices)) != 3: + raise ValueError("exactly three distinct Fock sample indices are required") + if min(indices) < 0 or max(indices) >= sample_count: + raise ValueError("Fock sample index is outside its candidate cell") + for regime in candidate["regimes"]: + if regime["kind"] != "fixed": + continue + epsilon = parse_fraction(regime["epsilon"]) + kappa = parse_fraction(regime["kappa"]) + if not (epsilon > 0 and kappa > 0 and 40 * epsilon + 59 * kappa < 2): + raise ValueError(f"fixed regime {regime['id']} is outside the open triangle") + + expected = manifest["expected_workload"] + candidate_cells = ( + len(candidate["dimensions"]) + * len(candidate["depths"]) + * len(candidate["regimes"]) + ) + candidate_words = candidate_cells * sample_count + split = manifest["positive_anchors"]["split_orthogonal"] + semigroup = manifest["positive_anchors"]["semigroup_cone"] + controls = manifest["component_controls"] + if set(controls["components"]) != {"++", "--", "-+", "+-"}: + raise ValueError("component controls must cover all four O(n,n) components") + + split_cells = len(split["n_values"]) * len(split["depths"]) + semigroup_cells = len(semigroup["n_values"]) * len(semigroup["depths"]) + component_cells = ( + len(controls["n_values"]) + * len(controls["depths"]) + * len(controls["components"]) + ) + split_words = split_cells * int(split["samples_per_cell"]) + semigroup_words = semigroup_cells * int(semigroup["samples_per_cell"]) + component_words = component_cells * int(controls["samples_per_cell"]) + total_cells = candidate_cells + split_cells + semigroup_cells + component_cells + + fock_maximum_dimension = int(manifest["fock_oracle"]["maximum_dimension"]) + fock_candidate_cells = ( + sum( + int(dimension) <= fock_maximum_dimension + for dimension in candidate["dimensions"] + ) + * len(candidate["depths"]) + * len(candidate["regimes"]) + ) + fock_oracle_checks = fock_candidate_cells * len(indices) + + physical = manifest["physical_benchmark"] + if int(physical["sites"]) != 4 or physical["boundary"] != "open": + raise ValueError("physical benchmark must be the four-site open chain") + if parse_fraction(physical["chemical_potential"]) != 0: + raise ValueError("physical benchmark must remain at chemical potential zero") + if any(parse_fraction(value) <= 0 for value in physical["couplings"].values()): + raise ValueError("physical benchmark couplings must be positive") + physical_words = ( + len(physical["betas"]) * int(physical["poisson_samples_per_beta"]) + ) + core_words = candidate_words + split_words + semigroup_words + component_words + computed = { + "candidate_cells": candidate_cells, + "candidate_words": candidate_words, + "split_cells": split_cells, + "split_words": split_words, + "semigroup_cells": semigroup_cells, + "semigroup_words": semigroup_words, + "component_cells": component_cells, + "component_words": component_words, + "total_cells": total_cells, + "total_words": core_words, + "fock_oracle_checks": fock_oracle_checks, + "physical_poisson_words": physical_words, + "total_random_words_including_physical": core_words + physical_words, + } + for key, value in computed.items(): + if int(expected[key]) != value: + raise ValueError(f"expected_workload.{key}={expected[key]} but protocol gives {value}") + + +def build_cells(manifest: dict[str, Any]) -> tuple[Cell, ...]: + cells: list[Cell] = [] + candidate = manifest["candidate"] + for regime in candidate["regimes"]: + for dimension in candidate["dimensions"]: + for depth in candidate["depths"]: + cells.append( + Cell( + f"candidate__{regime['id']}__d{dimension:02d}__m{depth:03d}", + "candidate", + { + "regime": regime["id"], + "dimension": int(dimension), + "depth": int(depth), + }, + ) + ) + + for kind, key in ( + ("split_orthogonal", "split_orthogonal"), + ("semigroup_cone", "semigroup_cone"), + ): + config = manifest["positive_anchors"][key] + for n in config["n_values"]: + for depth in config["depths"]: + cells.append( + Cell( + f"{kind}__n{n:02d}__m{depth:03d}", + kind, + {"n": int(n), "dimension": 2 * int(n), "depth": int(depth)}, + ) + ) + + controls = manifest["component_controls"] + for component in controls["components"]: + for n in controls["n_values"]: + for depth in controls["depths"]: + label = component.replace("+", "p").replace("-", "m") + cells.append( + Cell( + f"component__{label}__n{n:02d}__m{depth:03d}", + "component_control", + { + "component": component, + "n": int(n), + "dimension": 2 * int(n), + "depth": int(depth), + }, + ) + ) + return tuple(cells) + + +def derive_seed(base_seed: int, cell_id: str) -> int: + digest = hashlib.sha256(f"{base_seed}:{cell_id}".encode("utf-8")).digest() + return int.from_bytes(digest[:8], "big", signed=False) + + +def regime_by_id(manifest: dict[str, Any], regime_id: str) -> dict[str, Any]: + return next( + item for item in manifest["candidate"]["regimes"] if item["id"] == regime_id + ) + + +def sample_ab_parameters( + regime: dict[str, Any], + rng: np.random.Generator, +) -> tuple[float, float]: + if regime["kind"] == "fixed": + return float(parse_fraction(regime["epsilon"])), float(parse_fraction(regime["kappa"])) + if regime["kind"] != "dirichlet_open_triangle": + raise ValueError(f"unsupported candidate regime kind {regime['kind']}") + alpha = np.asarray(regime["alpha"], dtype=float) + x, y, _ = rng.dirichlet(alpha) + epsilon = float(x / 20.0) + kappa = float(2.0 * y / 59.0) + if not (epsilon > 0.0 and kappa > 0.0 and 40.0 * epsilon + 59.0 * kappa < 2.0): + raise RuntimeError("Dirichlet map left the open A/B triangle") + return epsilon, kappa + + +def sample_log_uniform( + rng: np.random.Generator, + distribution: dict[str, Any], +) -> float: + if distribution["kind"] != "log_uniform": + raise ValueError("only log_uniform time distributions are supported") + minimum = float(distribution["minimum"]) + maximum = float(distribution["maximum"]) + if not (0.0 < minimum <= maximum): + raise ValueError("log_uniform bounds must obey 0 < minimum <= maximum") + return float(math.exp(rng.uniform(math.log(minimum), math.log(maximum)))) + + +def mp_matrix(matrix: Array) -> mp.matrix: + square = np.asarray(matrix) + return mp.matrix( + [ + [mp.mpf(format(float(square[i, j]), ".17g")) for j in range(square.shape[1])] + for i in range(square.shape[0]) + ] + ) + + +def high_precision_product( + factor_specs: Sequence[dict[str, Any]], + dimension: int, +) -> mp.matrix: + product = mp.eye(dimension) + for spec in factor_specs: + matrix = mp_matrix(spec["matrix"]) + if spec["kind"] == "exponential": + factor = mp.expm(matrix) + elif spec["kind"] == "matrix": + factor = matrix + else: + raise ValueError(f"unknown high-precision factor kind {spec['kind']}") + product = factor * product + return product + + +def stable_determinant_i_plus( + product: Array, + factor_specs: Sequence[dict[str, Any]], + precision: dict[str, Any], +) -> dict[str, Any]: + square = np.asarray(product, dtype=float) + shifted = np.eye(square.shape[0]) + square + sign, log_abs = np.linalg.slogdet(shifted) + singular_values = np.linalg.svd(shifted, compute_uv=False) + sigma_min = float(singular_values[-1]) + threshold = float(precision["sigma_min_escalation"]) + needs_high_precision = ( + not np.isfinite(log_abs) or sign <= 0 or sigma_min < threshold + ) + + base = { + "double_sign": int(sign), + "double_log_abs_det": float(log_abs), + "sigma_min_i_plus_t": sigma_min, + "escalated": bool(needs_high_precision), + } + if not needs_high_precision: + maximum_log = math.log(sys.float_info.max) + if float(log_abs) <= maximum_log: + determinant: float | None = float(sign * math.exp(float(log_abs))) + determinant_decimal = format(determinant, ".17g") + method = "numpy_slogdet" + else: + log_ten = math.log(10.0) + exponent = math.floor(float(log_abs) / log_ten) + mantissa = float(sign) * math.exp(float(log_abs) - exponent * log_ten) + determinant = None + determinant_decimal = f"{mantissa:.16g}e{exponent:+d}" + method = "numpy_slogdet_log_only" + return { + **base, + "classification": "positive" if sign > 0 else "negative", + "method": method, + "sign": int(sign), + "log_abs_det": float(log_abs), + "determinant_decimal": determinant_decimal, + "determinant_float": determinant, + } + + if not factor_specs: + return { + **base, + "classification": "inconclusive", + "method": "unavailable_high_precision_rebuild", + "sign": 0, + "log_abs_det": float(log_abs), + "determinant_decimal": "unresolved", + "determinant_float": None, + } + + dps = int(precision["mpmath_dps"]) + zero_tolerance = mp.mpf(str(precision["high_precision_zero_tolerance"])) + imaginary_tolerance = mp.mpf(str(precision["high_precision_imag_tolerance"])) + try: + with mp.workdps(dps): + rebuilt = high_precision_product(factor_specs, square.shape[0]) + determinant_mp = mp.det(mp.eye(square.shape[0]) + rebuilt) + imaginary = abs(mp.im(determinant_mp)) + real = mp.re(determinant_mp) + if imaginary > imaginary_tolerance: + classification = "inconclusive" + resolved_sign = 0 + elif abs(real) <= zero_tolerance: + classification = "inconclusive" + resolved_sign = 0 + else: + classification = "positive" if real > 0 else "negative" + resolved_sign = 1 if real > 0 else -1 + log_mp = mp.log(abs(real)) if real != 0 else mp.ninf + decimal = mp.nstr(real, 40) + determinant_float = float(real) if abs(real) < mp.mpf("1e308") else None + return { + **base, + "classification": classification, + "method": f"mpmath_{dps}dps", + "sign": resolved_sign, + "log_abs_det": float(log_mp), + "determinant_decimal": decimal, + "determinant_float": determinant_float, + "high_precision_imag_abs": mp.nstr(imaginary, 12), + } + except Exception as error: + return { + **base, + "classification": "inconclusive", + "method": f"mpmath_{dps}dps_failed", + "sign": 0, + "log_abs_det": float(log_abs), + "determinant_decimal": "unresolved", + "determinant_float": None, + "high_precision_error": f"{type(error).__name__}: {error}", + } + + +def sector_indices(orbitals: int, particles: int) -> list[int]: + return [state for state in range(1 << orbitals) if state.bit_count() == particles] + + +def direct_fock_trace(factor_specs: Sequence[dict[str, Any]]) -> complex: + if not factor_specs or any(spec["kind"] != "exponential" for spec in factor_specs): + raise ValueError("direct Fock oracle requires a nonempty exponential word") + orbitals = np.asarray(factor_specs[0]["matrix"]).shape[0] + indices = [sector_indices(orbitals, particles) for particles in range(orbitals + 1)] + sector_products = { + particles: np.eye(len(indices[particles]), dtype=float) + for particles in range(orbitals + 1) + } + for spec in factor_specs: + generator = np.asarray(spec["matrix"], dtype=float) + lifted = sph.bilinear_fock_operator(generator) + for particles in range(orbitals + 1): + block_indices = indices[particles] + block = lifted[np.ix_(block_indices, block_indices)] + sector_products[particles] = expm(block) @ sector_products[particles] + return complex(sum(np.trace(block) for block in sector_products.values())) + + +def exterior_representation(matrix: Array, particles: int) -> Array: + dimension = np.asarray(matrix).shape[0] + subsets = list(combinations(range(dimension), particles)) + if particles == 0: + return np.ones((1, 1)) + result = np.zeros((len(subsets), len(subsets))) + for row, destination in enumerate(subsets): + for column, source in enumerate(subsets): + result[row, column] = np.linalg.det( + np.asarray(matrix)[np.ix_(destination, source)] + ) + return result + + +def twirl_sector_diagnostics(matrix: Array, tau: float) -> dict[str, float]: + operator = np.zeros((8, 8)) + for _, permutation_matrix in permutation_matrices_3(): + generator = tau * permutation_matrix @ matrix @ permutation_matrix.T + operator += expm(sph.bilinear_fock_operator(generator)) + operator /= 6.0 + one_indices = sector_indices(3, 1) + two_indices = sector_indices(3, 2) + block_one = operator[np.ix_(one_indices, one_indices)] + block_two = operator[np.ix_(two_indices, two_indices)] + permutation_data = permutation_matrices_3() + p_trivial = sum( + exterior_representation(permutation_matrix, 1) + for _, permutation_matrix in permutation_data + ) / 6.0 + p_sign = sum( + int(round(np.linalg.det(permutation_matrix))) + * exterior_representation(permutation_matrix, 2) + for _, permutation_matrix in permutation_data + ) / 6.0 + alpha = float(np.trace(p_trivial @ block_one)) + beta = float((np.trace(block_one) - alpha) / 2.0) + d_two = float(np.trace(p_sign @ block_two)) + gamma = float((np.trace(block_two) - d_two) / 2.0) + zeta = float(operator[7, 7]) + return { + "vacuum": float(operator[0, 0]), + "alpha": alpha, + "beta": beta, + "gamma": gamma, + "d2": d_two, + "zeta": zeta, + "gaussian_gap_d2_minus_beta2": d_two - beta * beta, + "gaussian_gap_gamma_minus_alpha_beta": gamma - alpha * beta, + "gaussian_gap_zeta_minus_alpha_beta2": zeta - alpha * beta * beta, + "hermiticity_residual_fro": float( + np.linalg.norm(operator - operator.T.conj(), ord="fro") + ), + } + + +def run_twirl_checks(manifest: dict[str, Any]) -> dict[str, Any]: + config = manifest["twirl_checks"] + epsilon = config["epsilon"] + kappa = config["kappa"] + tau = float(parse_fraction(config["tau"])) + results = { + family: twirl_sector_diagnostics(ab_generator(epsilon, kappa, family), tau) + for family in ("A", "B") + } + hermiticity_tolerance = float(config["hermiticity_tolerance"]) + nongaussian_minimum = float(config["nongaussian_gap_minimum_abs"]) + checks = { + family: { + "hermitian": values["hermiticity_residual_fro"] <= hermiticity_tolerance, + "non_gaussian": abs(values["gaussian_gap_d2_minus_beta2"]) + >= nongaussian_minimum, + } + for family, values in results.items() + } + return { + "schema_version": 1, + "status": "pass" if all(all(item.values()) for item in checks.values()) else "fail", + "parameters": {"epsilon": epsilon, "kappa": kappa, "tau": tau}, + "families": results, + "checks": checks, + } + + +def embed_generator(local: Array, sites: Sequence[int], dimension: int) -> Array: + result = np.zeros((dimension, dimension)) + result[np.ix_(sites, sites)] = local + return result + + +def embedded_factor(local_generator: Array, sites: Sequence[int], dimension: int) -> Array: + result = np.eye(dimension) + result[np.ix_(sites, sites)] = expm(local_generator) + return result + + +def word_digest(descriptor: object) -> str: + return sha256_bytes(canonical_json(descriptor).encode("utf-8")) + + +def sample_candidate_word( + manifest: dict[str, Any], + cell: Cell, + rng: np.random.Generator, +) -> tuple[Array, list[dict[str, Any]], list[dict[str, Any]], float]: + config = manifest["candidate"] + dimension = int(cell.parameters["dimension"]) + depth = int(cell.parameters["depth"]) + regime = regime_by_id(manifest, str(cell.parameters["regime"])) + triples = tuple(combinations(range(dimension), 3)) + permutation_data = permutation_matrices_3() + product = np.eye(dimension) + factor_specs: list[dict[str, Any]] = [] + descriptor: list[dict[str, Any]] = [] + sum_kappa_time = 0.0 + for _ in range(depth): + epsilon, kappa = sample_ab_parameters(regime, rng) + family = "A" if int(rng.integers(0, 2)) == 0 else "B" + permutation_index = int(rng.integers(0, len(permutation_data))) + triple_index = int(rng.integers(0, len(triples))) + sites = triples[triple_index] + propagation_time = sample_log_uniform(rng, config["time_distribution"]) + permutation_matrix = permutation_data[permutation_index][1] + local = permutation_matrix @ ab_generator(epsilon, kappa, family) @ permutation_matrix.T + local_generator = propagation_time * local + full_generator = embed_generator(local_generator, sites, dimension) + product = embedded_factor(local_generator, sites, dimension) @ product + factor_specs.append({"kind": "exponential", "matrix": full_generator}) + descriptor.append( + { + "family": family, + "permutation": permutation_index, + "triple": triple_index, + "epsilon": format(epsilon, ".17g"), + "kappa": format(kappa, ".17g"), + "time": format(propagation_time, ".17g"), + } + ) + sum_kappa_time += kappa * propagation_time + return product, factor_specs, descriptor, sum_kappa_time + + +def result_row( + cell: Cell, + sample: int, + determinant: dict[str, Any], + *, + structural_diagnostic: float, + digest: str, + fock_checked: bool = False, + fock_abs_error: float | None = None, +) -> dict[str, Any]: + return { + "cell_id": cell.cell_id, + "kind": cell.kind, + "sample": sample, + "dimension": cell.parameters.get("dimension", ""), + "n": cell.parameters.get("n", ""), + "depth": cell.parameters.get("depth", ""), + "regime": cell.parameters.get("regime", ""), + "component": cell.parameters.get("component", ""), + "det_class": determinant["classification"], + "det_method": determinant["method"], + "det_sign": determinant["sign"], + "log_abs_det": format(float(determinant["log_abs_det"]), ".17g"), + "determinant_decimal": determinant["determinant_decimal"], + "sigma_min_i_plus_t": format( + float(determinant["sigma_min_i_plus_t"]), ".17g" + ), + "structural_diagnostic": format(float(structural_diagnostic), ".17g"), + "fock_checked": int(fock_checked), + "fock_abs_error": "" if fock_abs_error is None else format(fock_abs_error, ".17g"), + "word_sha256": digest, + } + + +def run_candidate_cell( + manifest: dict[str, Any], + cell: Cell, + rng: np.random.Generator, +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + config = manifest["candidate"] + thresholds = manifest["thresholds"] + precision = manifest["determinant_precision"] + sample_count = int(config["samples_per_cell"]) + dimension = int(cell.parameters["dimension"]) + fock_config = manifest["fock_oracle"] + fock_indices = ( + set(map(int, fock_config["sample_indices"])) + if dimension <= int(fock_config["maximum_dimension"]) + else set() + ) + contraction_tolerance = float(thresholds["contraction_abs"]) + fock_atol = float(fock_config["absolute_tolerance"]) + fock_rtol = float(fock_config["relative_tolerance"]) + rows: list[dict[str, Any]] = [] + passed = True + minimum_log_abs = math.inf + maximum_norm_violation = 0.0 + maximum_fock_error = 0.0 + high_precision_count = 0 + inconclusive_count = 0 + fock_count = 0 + + for sample in range(sample_count): + product, factor_specs, descriptor, sum_kappa_time = sample_candidate_word( + manifest, cell, rng + ) + determinant = stable_determinant_i_plus(product, factor_specs, precision) + high_precision_count += int(determinant["escalated"]) + inconclusive_count += int(determinant["classification"] == "inconclusive") + norm = float(np.linalg.norm(product, ord=np.inf)) + bound = math.exp(-sum_kappa_time) if dimension == 3 else 1.0 + norm_violation = max(0.0, norm - bound) + maximum_norm_violation = max(maximum_norm_violation, norm_violation) + minimum_log_abs = min(minimum_log_abs, float(determinant["log_abs_det"])) + sample_pass = ( + determinant["classification"] == "positive" + and norm_violation <= contraction_tolerance + ) + fock_checked = sample in fock_indices + fock_error: float | None = None + if fock_checked: + fock_count += 1 + fock_trace = direct_fock_trace(factor_specs) + determinant_float = determinant["determinant_float"] + if determinant_float is None: + sample_pass = False + fock_error = math.inf + else: + fock_error = abs(fock_trace - determinant_float) + imaginary_ok = abs(fock_trace.imag) <= fock_atol + tolerance = fock_atol + fock_rtol * abs(determinant_float) + sample_pass = sample_pass and imaginary_ok and fock_error <= tolerance + maximum_fock_error = max(maximum_fock_error, float(fock_error)) + passed = passed and sample_pass + rows.append( + result_row( + cell, + sample, + determinant, + structural_diagnostic=norm - bound, + digest=word_digest(descriptor), + fock_checked=fock_checked, + fock_abs_error=fock_error, + ) + ) + + expected_fock = 3 if dimension <= int(fock_config["maximum_dimension"]) else 0 + passed = passed and fock_count == expected_fock + summary = { + "schema_version": 1, + "cell_id": cell.cell_id, + "kind": cell.kind, + "parameters": cell.parameters, + "status": "pass" if passed else "fail", + "sample_count": sample_count, + "minimum_log_abs_det": minimum_log_abs, + "maximum_infinity_norm_violation": maximum_norm_violation, + "high_precision_escalations": high_precision_count, + "inconclusive_determinants": inconclusive_count, + "fock_checks": fock_count, + "maximum_abs_fock_error": maximum_fock_error, + "theorem_boundary": ( + "d=3 uses exp(-sum kappa_j t_j); embedded d>3 words use the " + "non-strict common infinity-norm bound 1." + ), + } + return summary, rows + + +def sample_split_word( + n: int, + depth: int, + rng: np.random.Generator, + config: dict[str, Any], +) -> tuple[Array, list[dict[str, Any]], list[dict[str, Any]], float]: + dimension = 2 * n + eta = sph.split_metric(n) + product = np.eye(dimension) + factor_specs: list[dict[str, Any]] = [] + descriptor: list[dict[str, Any]] = [] + maximum_lie_residual = 0.0 + for _ in range(depth): + generator = sph.random_split_generator( + n, + rng, + scale=float(config["generator_scale"]), + ) + propagation_time = sample_log_uniform(rng, config["time_distribution"]) + timed_generator = propagation_time * generator + product = expm(timed_generator) @ product + factor_specs.append({"kind": "exponential", "matrix": timed_generator}) + maximum_lie_residual = max( + maximum_lie_residual, + float(np.linalg.norm(timed_generator.T @ eta + eta @ timed_generator, ord="fro")), + ) + descriptor.append( + { + "time": format(propagation_time, ".17g"), + "generator_sha256": sha256_bytes(timed_generator.tobytes()), + } + ) + return product, factor_specs, descriptor, maximum_lie_residual + + +def run_split_cell( + manifest: dict[str, Any], + cell: Cell, + rng: np.random.Generator, +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + config = manifest["positive_anchors"]["split_orthogonal"] + thresholds = manifest["thresholds"] + precision = manifest["determinant_precision"] + sample_count = int(config["samples_per_cell"]) + n = int(cell.parameters["n"]) + depth = int(cell.parameters["depth"]) + eta = sph.split_metric(n) + lie_tolerance = float(thresholds["split_lie_abs"]) + group_tolerance = float(thresholds["split_group_abs"]) + rows: list[dict[str, Any]] = [] + passed = True + maximum_lie_residual = 0.0 + maximum_group_residual = 0.0 + high_precision_count = 0 + inconclusive_count = 0 + + for sample in range(sample_count): + product, factor_specs, descriptor, lie_residual = sample_split_word( + n, depth, rng, config + ) + determinant = stable_determinant_i_plus(product, factor_specs, precision) + group_residual = float( + np.linalg.norm(product.T @ eta @ product - eta, ord="fro") + ) + maximum_lie_residual = max(maximum_lie_residual, lie_residual) + maximum_group_residual = max(maximum_group_residual, group_residual) + high_precision_count += int(determinant["escalated"]) + inconclusive_count += int(determinant["classification"] == "inconclusive") + try: + component = sph.classify_split_component( + product, + eta, + atol=max(group_tolerance * 10.0, 1e-9), + ) + except ValueError: + component = "unclassified" + sample_pass = ( + determinant["classification"] == "positive" + and component == "++" + and lie_residual <= lie_tolerance + and group_residual <= group_tolerance + ) + passed = passed and sample_pass + rows.append( + result_row( + cell, + sample, + determinant, + structural_diagnostic=group_residual, + digest=word_digest(descriptor), + ) + ) + + summary = { + "schema_version": 1, + "cell_id": cell.cell_id, + "kind": cell.kind, + "parameters": cell.parameters, + "status": "pass" if passed else "fail", + "sample_count": sample_count, + "maximum_generator_lie_residual": maximum_lie_residual, + "maximum_group_residual": maximum_group_residual, + "high_precision_escalations": high_precision_count, + "inconclusive_determinants": inconclusive_count, + } + return summary, rows + + +def sample_semigroup_word( + n: int, + depth: int, + sample_index: int, + rng: np.random.Generator, + config: dict[str, Any], +) -> tuple[Array, list[dict[str, Any]], list[dict[str, Any]], float, int, int, int]: + """Sample the Lie wedge A^T eta + eta A >= 0. + + Writing A = K + eta Q/2 with K in o(n,n) and Q positive semidefinite + makes the infinitesimal inequality exactly Q >= 0. Full-rank and + rank-deficient Q alternate deterministically within every cell. A random + QR basis with nonzero eigenvalues in [0.25, 1] avoids accidental Wishart + ill-conditioning, and the realized numerical rank is still checked against + the intended rank. + """ + dimension = 2 * n + eta = sph.split_metric(n) + product = np.eye(dimension) + factor_specs: list[dict[str, Any]] = [] + descriptor: list[dict[str, Any]] = [] + minimum_generator_eigenvalue = math.inf + full_rank_factors = 0 + deficient_rank_factors = 0 + rank_validation_failures = 0 + strength_config = config["dissipation_strength"] + + for factor_index in range(depth): + full_rank = (sample_index + factor_index) % 2 == 0 + row_count = dimension if full_rank else max(1, n) + raw_basis = rng.normal(size=(dimension, dimension)) + orthogonal_basis, _ = np.linalg.qr(raw_basis) + basis = orthogonal_basis[:, :row_count] + unscaled_eigenvalues = rng.uniform(0.25, 1.0, size=row_count) + q_matrix = (basis * unscaled_eigenvalues) @ basis.T + maximum_eigenvalue = float(np.max(unscaled_eigenvalues)) + strength = float( + rng.uniform( + float(strength_config["minimum"]), + float(strength_config["maximum"]), + ) + ) + q_matrix *= strength / maximum_eigenvalue + + split_part = sph.random_split_generator( + n, + rng, + scale=float(config["split_generator_scale"]), + ) + generator = split_part + 0.5 * eta @ q_matrix + propagation_time = sample_log_uniform(rng, config["time_distribution"]) + timed_generator = propagation_time * generator + lmi = timed_generator.T @ eta + eta @ timed_generator + lmi = 0.5 * (lmi + lmi.T) + minimum_generator_eigenvalue = min( + minimum_generator_eigenvalue, + float(np.linalg.eigvalsh(lmi)[0]), + ) + product = expm(timed_generator) @ product + factor_specs.append({"kind": "exponential", "matrix": timed_generator}) + numerical_rank = int( + np.linalg.matrix_rank( + q_matrix, + tol=float(config["rank_tolerance"]), + ) + ) + expected_rank = dimension if full_rank else row_count + rank_valid = numerical_rank == expected_rank + full_rank_factors += int(numerical_rank == dimension) + deficient_rank_factors += int(numerical_rank < dimension) + rank_validation_failures += int(not rank_valid) + descriptor.append( + { + "time": format(propagation_time, ".17g"), + "q_rank": numerical_rank, + "q_expected_rank": expected_rank, + "q_rank_valid": rank_valid, + "q_kind": "full" if full_rank else "rank_deficient", + "q_sampler": "qr_bounded_spectrum", + "q_strength": format(strength, ".17g"), + "q_unscaled_eigenvalue_floor": format( + float(np.min(unscaled_eigenvalues)), ".17g" + ), + "generator_sha256": sha256_bytes(timed_generator.tobytes()), + } + ) + + return ( + product, + factor_specs, + descriptor, + minimum_generator_eigenvalue, + full_rank_factors, + deficient_rank_factors, + rank_validation_failures, + ) + + +def run_semigroup_cell( + manifest: dict[str, Any], + cell: Cell, + rng: np.random.Generator, +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + config = manifest["positive_anchors"]["semigroup_cone"] + thresholds = manifest["thresholds"] + precision = manifest["determinant_precision"] + sample_count = int(config["samples_per_cell"]) + n = int(cell.parameters["n"]) + eta = sph.split_metric(n) + generator_tolerance = float(thresholds["semigroup_generator_eigenvalue_abs"]) + product_tolerance = float(thresholds["semigroup_product_eigenvalue_abs"]) + rows: list[dict[str, Any]] = [] + passed = True + minimum_generator_eigenvalue = math.inf + minimum_product_eigenvalue = math.inf + high_precision_count = 0 + inconclusive_count = 0 + full_rank_factors = 0 + deficient_rank_factors = 0 + rank_validation_failures = 0 + + for sample in range(sample_count): + ( + product, + factor_specs, + descriptor, + generator_eigenvalue, + sample_full_rank, + sample_deficient_rank, + sample_rank_failures, + ) = sample_semigroup_word(n, int(cell.parameters["depth"]), sample, rng, config) + determinant = stable_determinant_i_plus(product, factor_specs, precision) + product_lmi = product.T @ eta @ product - eta + product_lmi = 0.5 * (product_lmi + product_lmi.T) + product_eigenvalue = float(np.linalg.eigvalsh(product_lmi)[0]) + minimum_generator_eigenvalue = min( + minimum_generator_eigenvalue, generator_eigenvalue + ) + minimum_product_eigenvalue = min( + minimum_product_eigenvalue, product_eigenvalue + ) + high_precision_count += int(determinant["escalated"]) + inconclusive_count += int(determinant["classification"] == "inconclusive") + full_rank_factors += sample_full_rank + deficient_rank_factors += sample_deficient_rank + rank_validation_failures += sample_rank_failures + sample_pass = ( + determinant["classification"] == "positive" + and generator_eigenvalue >= -generator_tolerance + and product_eigenvalue >= -product_tolerance + and sample_rank_failures == 0 + ) + passed = passed and sample_pass + rows.append( + result_row( + cell, + sample, + determinant, + structural_diagnostic=product_eigenvalue, + digest=word_digest(descriptor), + ) + ) + + passed = ( + passed + and full_rank_factors > 0 + and deficient_rank_factors > 0 + and rank_validation_failures == 0 + ) + summary = { + "schema_version": 1, + "cell_id": cell.cell_id, + "kind": cell.kind, + "parameters": cell.parameters, + "status": "pass" if passed else "fail", + "sample_count": sample_count, + "minimum_generator_lmi_eigenvalue": minimum_generator_eigenvalue, + "minimum_product_lmi_eigenvalue": minimum_product_eigenvalue, + "full_rank_q_factors": full_rank_factors, + "rank_deficient_q_factors": deficient_rank_factors, + "q_rank_validation_failures": rank_validation_failures, + "high_precision_escalations": high_precision_count, + "inconclusive_determinants": inconclusive_count, + } + return summary, rows + + +def run_component_cell( + manifest: dict[str, Any], + cell: Cell, + rng: np.random.Generator, +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + config = manifest["component_controls"] + thresholds = manifest["thresholds"] + precision = manifest["determinant_precision"] + n = int(cell.parameters["n"]) + depth = int(cell.parameters["depth"]) + component = str(cell.parameters["component"]) + eta = sph.split_metric(n) + representative = sph.split_component_representative(n, component) + group_tolerance = float(thresholds["split_group_abs"]) + zero_sigma_tolerance = float(thresholds["component_zero_sigma"]) + rows: list[dict[str, Any]] = [] + passed = True + maximum_group_residual = 0.0 + maximum_zero_sigma = 0.0 + classified_counts: dict[str, int] = {} + determinant_counts: dict[str, int] = {} + + high_precision_count = 0 + inconclusive_count = 0 + is_expected_exact_zero_component = component in {"-+", "+-"} + expected_exact_zero_controls = 0 + unexpected_inconclusive_count = 0 + for sample in range(int(config["samples_per_cell"])): + identity_product, identity_specs, descriptor, _ = sample_split_word( + n, depth, rng, config + ) + product = representative @ identity_product + factor_specs = [*identity_specs, {"kind": "matrix", "matrix": representative}] + descriptor = [*descriptor, {"component_representative": component}] + determinant = stable_determinant_i_plus(product, factor_specs, precision) + high_precision_count += int(determinant["escalated"]) + inconclusive_count += int(determinant["classification"] == "inconclusive") + expected_exact_zero_controls += int(is_expected_exact_zero_component) + unexpected_inconclusive_count += int( + determinant["classification"] == "inconclusive" + and not is_expected_exact_zero_component + ) + group_residual = float( + np.linalg.norm(product.T @ eta @ product - eta, ord="fro") + ) + maximum_group_residual = max(maximum_group_residual, group_residual) + try: + classified = sph.classify_split_component( + product, + eta, + atol=max(group_tolerance * 10.0, 1e-9), + ) + except ValueError: + classified = "unclassified" + classified_counts[classified] = classified_counts.get(classified, 0) + 1 + det_class = str(determinant["classification"]) + determinant_counts[det_class] = determinant_counts.get(det_class, 0) + 1 + + if component == "++": + determinant_ok = det_class == "positive" + elif component == "--": + determinant_ok = det_class == "negative" + else: + determinant_ok = ( + det_class == "inconclusive" + and float(determinant["sigma_min_i_plus_t"]) + <= zero_sigma_tolerance + ) + maximum_zero_sigma = max( + maximum_zero_sigma, + float(determinant["sigma_min_i_plus_t"]), + ) + sample_pass = ( + classified == component + and group_residual <= group_tolerance + and determinant_ok + ) + passed = passed and sample_pass + rows.append( + result_row( + cell, + sample, + determinant, + structural_diagnostic=group_residual, + digest=word_digest(descriptor), + ) + ) + + summary = { + "schema_version": 1, + "cell_id": cell.cell_id, + "kind": cell.kind, + "parameters": cell.parameters, + "status": "pass" if passed else "fail", + "sample_count": int(config["samples_per_cell"]), + "maximum_group_residual": maximum_group_residual, + "maximum_mixed_component_sigma_min": maximum_zero_sigma, + "classified_component_counts": classified_counts, + "determinant_class_counts": determinant_counts, + "high_precision_escalations": high_precision_count, + "inconclusive_determinants": inconclusive_count, + "raw_inconclusive_determinants": inconclusive_count, + "expected_exact_zero_controls": expected_exact_zero_controls, + "unexpected_inconclusive_determinants": unexpected_inconclusive_count, + "expected_weight": ( + "strictly_positive" if component == "++" else + "strictly_negative" if component == "--" else + "exactly_zero_by_component_theorem" + ), + } + return summary, rows + + +def physical_vertex_catalog( + config: dict[str, Any], +) -> tuple[list[dict[str, Any]], Array, Array]: + sites = int(config["sites"]) + if sites != 4 or str(config["boundary"]) != "open": + raise ValueError("the preregistered physical benchmark is the four-site open chain") + epsilon = config["epsilon"] + kappa = config["kappa"] + tau = float(parse_fraction(config["tau"])) + chemical_potential = parse_fraction(config["chemical_potential"]) + if chemical_potential != 0: + raise ValueError("the positive Poisson benchmark is preregistered at mu=0") + triangles = [tuple(map(int, triangle)) for triangle in config["triangles"]] + permutation_data = permutation_matrices_3() + catalog: list[dict[str, Any]] = [] + fock_dimension = 1 << sites + interaction_operator = np.zeros((fock_dimension, fock_dimension)) + one_particle_twirl = np.zeros((sites, sites)) + + for triangle_index, triangle in enumerate(triangles): + if len(triangle) != 3 or len(set(triangle)) != 3: + raise ValueError("every benchmark triangle must contain three distinct sites") + if min(triangle) < 0 or max(triangle) >= sites: + raise ValueError("benchmark triangle site is outside the chain") + for family in ("A", "B"): + coupling = float(parse_fraction(config["couplings"][family])) + if coupling <= 0.0: + raise ValueError("physical benchmark couplings must be positive") + scalar_weight = coupling / len(permutation_data) + base = ab_generator(epsilon, kappa, family) + for permutation_index, (_, permutation_matrix) in enumerate(permutation_data): + local_generator = tau * permutation_matrix @ base @ permutation_matrix.T + generator = embed_generator(local_generator, triangle, sites) + one_particle_factor = expm(generator) + fock_factor = expm(sph.bilinear_fock_operator(generator)) + interaction_operator += scalar_weight * fock_factor + one_particle_twirl += scalar_weight * one_particle_factor + catalog.append( + { + "id": ( + f"triangle{triangle_index}_{family}_" + f"perm{permutation_index}" + ), + "triangle": triangle, + "family": family, + "permutation": permutation_index, + "weight": scalar_weight, + "generator": generator, + "one_particle_factor": one_particle_factor, + "fock_factor": fock_factor, + } + ) + return catalog, interaction_operator, one_particle_twirl + + +def deterministic_partition_expansion( + interaction_operator: Array, + beta: float, + order: int, + energy_shift: float, +) -> dict[str, Any]: + """Controlled Taylor fixture for Z_bar=Tr exp[-beta(G0 I-V)].""" + dimension = interaction_operator.shape[0] + power = np.eye(dimension) + coefficient = 1.0 + series = complex(np.trace(power)) + terms = [{"order": 0, "real": float(series.real), "imag_abs": float(abs(series.imag))}] + for expansion_order in range(1, order + 1): + power = power @ interaction_operator + coefficient *= beta / expansion_order + term = coefficient * complex(np.trace(power)) + series += term + terms.append( + { + "order": expansion_order, + "real": float(term.real), + "imag_abs": float(abs(term.imag)), + } + ) + normalization = math.exp(-beta * energy_shift) + z_bar_series = normalization * series + for term in terms: + term["real"] *= normalization + term["imag_abs"] *= normalization + norm_argument = beta * float(np.linalg.norm(interaction_operator, ord=2)) + remainder_bound = ( + normalization + * dimension + * math.exp(norm_argument) + * norm_argument ** (order + 1) + / math.factorial(order + 1) + ) + return { + "order": order, + "energy_shift_G0": energy_shift, + "shift_normalization_exp_minus_beta_G0": normalization, + "z_bar_estimate_real": float(z_bar_series.real), + "z_bar_estimate_imag_abs": float(abs(z_bar_series.imag)), + "partition_estimate_real": float(z_bar_series.real), + "partition_estimate_imag_abs": float(abs(z_bar_series.imag)), + "operator_norm_argument": norm_argument, + "remainder_bound": remainder_bound, + "terms": terms, + } + + +def poisson_partition_estimate( + catalog: Sequence[dict[str, Any]], + beta: float, + sample_count: int, + rng: np.random.Generator, + precision: dict[str, Any], +) -> dict[str, Any]: + """Estimate shifted Z_bar with the normalized positive Poisson expansion.""" + weights = np.asarray([float(vertex["weight"]) for vertex in catalog]) + total_weight = float(np.sum(weights)) + probabilities = weights / total_weight + sites = np.asarray(catalog[0]["one_particle_factor"]).shape[0] + fock_dimension = np.asarray(catalog[0]["fock_factor"]).shape[0] + contributions = np.empty(sample_count) + minimum_fock_weight = math.inf + minimum_determinant_weight = math.inf + minimum_record: dict[str, Any] | None = None + maximum_fock_determinant_error = 0.0 + maximum_fock_imaginary_part = 0.0 + negative_or_unresolved = 0 + orders: list[int] = [] + + for sample in range(sample_count): + expansion_order = int(rng.poisson(beta * total_weight)) + labels = ( + rng.choice(len(catalog), size=expansion_order, p=probabilities) + if expansion_order + else np.empty(0, dtype=int) + ) + one_particle_product = np.eye(sites) + fock_product = np.eye(fock_dimension) + factor_specs: list[dict[str, Any]] = [] + identifiers: list[str] = [] + for label_value in labels: + vertex = catalog[int(label_value)] + one_particle_product = ( + np.asarray(vertex["one_particle_factor"]) @ one_particle_product + ) + fock_product = np.asarray(vertex["fock_factor"]) @ fock_product + factor_specs.append( + {"kind": "exponential", "matrix": np.asarray(vertex["generator"])} + ) + identifiers.append(str(vertex["id"])) + + determinant = stable_determinant_i_plus( + one_particle_product, + factor_specs, + precision, + ) + fock_weight = complex(np.trace(fock_product)) + maximum_fock_imaginary_part = max( + maximum_fock_imaginary_part, + float(abs(fock_weight.imag)), + ) + determinant_float = determinant["determinant_float"] + if determinant_float is None: + mismatch = math.inf + negative_or_unresolved += 1 + determinant_value = math.nan + else: + determinant_value = float(determinant_float) + mismatch = abs(fock_weight - determinant_value) + if determinant["classification"] != "positive": + negative_or_unresolved += 1 + maximum_fock_determinant_error = max( + maximum_fock_determinant_error, + float(mismatch), + ) + contributions[sample] = float(fock_weight.real) + orders.append(expansion_order) + minimum_fock_weight = min(minimum_fock_weight, float(fock_weight.real)) + if np.isfinite(determinant_value): + minimum_determinant_weight = min( + minimum_determinant_weight, determinant_value + ) + if ( + minimum_record is None + or float(fock_weight.real) < float(minimum_record["fock_weight"]) + ): + minimum_record = { + "sample": sample, + "order": expansion_order, + "fock_weight": float(fock_weight.real), + "determinant_decimal": determinant["determinant_decimal"], + "word_sha256": word_digest(identifiers), + } + + standard_error = ( + float(np.std(contributions, ddof=1) / math.sqrt(sample_count)) + if sample_count > 1 + else math.inf + ) + z_bar_estimate = float(np.mean(contributions)) + return { + "sample_count": sample_count, + "poisson_mean_beta_G0": beta * total_weight, + "poisson_mean": beta * total_weight, + "energy_shift_G0": total_weight, + "total_vertex_weight": total_weight, + "z_bar_estimate": z_bar_estimate, + "partition_estimate": z_bar_estimate, + "standard_error": standard_error, + "minimum_fock_configuration_weight": minimum_fock_weight, + "minimum_determinant_configuration_weight": minimum_determinant_weight, + "minimum_configuration": minimum_record, + "maximum_fock_determinant_abs_error": maximum_fock_determinant_error, + "maximum_fock_imaginary_part": maximum_fock_imaginary_part, + "negative_or_unresolved_configurations": negative_or_unresolved, + "minimum_sampled_order": min(orders), + "maximum_sampled_order": max(orders), + } + + +def run_physical_benchmark(manifest: dict[str, Any]) -> dict[str, Any]: + config = manifest["physical_benchmark"] + catalog, interaction_operator, one_particle_twirl = physical_vertex_catalog(config) + energy_shift = float(sum(float(vertex["weight"]) for vertex in catalog)) + h_bar = energy_shift * np.eye(interaction_operator.shape[0]) - interaction_operator + hermiticity_residual = float(np.linalg.norm(h_bar - h_bar.T.conj(), ord="fro")) + hermitian_h_bar = 0.5 * (h_bar + h_bar.T.conj()) + minimum_h_bar_eigenvalue = float(np.linalg.eigvalsh(hermitian_h_bar)[0]) + precision = manifest["determinant_precision"] + fock_config = manifest["fock_oracle"] + samples = int(config["poisson_samples_per_beta"]) + confidence_sigma = float(config["confidence_sigma"]) + relative_error_floor = float(config["relative_error_floor"]) + weight_tolerance = float(config["weight_tolerance"]) + expansion_order = int(config["deterministic_truncation_order"]) + results: list[dict[str, Any]] = [] + passed = ( + hermiticity_residual <= float(config["hermiticity_tolerance"]) + and minimum_h_bar_eigenvalue >= -weight_tolerance + ) + + for beta_value in config["betas"]: + beta = float(parse_fraction(beta_value)) + exact_complex = complex(np.trace(expm(-beta * h_bar))) + exact_z_bar = float(exact_complex.real) + deterministic = deterministic_partition_expansion( + interaction_operator, beta, expansion_order, energy_shift + ) + deterministic_error = abs(deterministic["z_bar_estimate_real"] - exact_z_bar) + beta_seed = derive_seed( + int(config["seed"]), + f"physical_beta_{fraction_string(parse_fraction(beta_value))}", + ) + poisson = poisson_partition_estimate( + catalog, + beta, + samples, + np.random.default_rng(beta_seed), + precision, + ) + statistical_error = abs(poisson["z_bar_estimate"] - exact_z_bar) + statistical_allowance = max( + confidence_sigma * poisson["standard_error"], + relative_error_floor * abs(exact_z_bar), + ) + beta_pass = ( + abs(exact_complex.imag) <= float(config["partition_imag_tolerance"]) + and poisson["negative_or_unresolved_configurations"] == 0 + and poisson["minimum_fock_configuration_weight"] >= -weight_tolerance + and poisson["maximum_fock_imaginary_part"] + <= float(config["partition_imag_tolerance"]) + and poisson["maximum_fock_determinant_abs_error"] + <= float(fock_config["absolute_tolerance"]) + + float(fock_config["relative_tolerance"]) + * max(1.0, poisson["minimum_fock_configuration_weight"]) + and statistical_error <= statistical_allowance + and deterministic_error + <= deterministic["remainder_bound"] + + float(config["deterministic_roundoff_allowance"]) + ) + passed = passed and beta_pass + results.append( + { + "beta": fraction_string(parse_fraction(beta_value)), + "status": "pass" if beta_pass else "fail", + "exact_z_bar": exact_z_bar, + "exact_fock_partition_function": exact_z_bar, + "exact_partition_imag_abs": float(abs(exact_complex.imag)), + "poisson": poisson, + "poisson_abs_error": statistical_error, + "poisson_allowed_error": statistical_allowance, + "deterministic_expansion": deterministic, + "deterministic_abs_error": deterministic_error, + } + ) + + return { + "schema_version": 1, + "status": "pass" if passed else "fail", + "interpretation": ( + "For H_bar=G0 I-V, the exact 16-dimensional Z_bar is compared " + "with the normalized positive Poisson operator-string estimator " + "and a controlled shifted deterministic expansion." + ), + "parameters": config, + "catalog_size": len(catalog), + "hamiltonian_dimension": int(h_bar.shape[0]), + "energy_shift_G0": energy_shift, + "minimum_h_bar_eigenvalue": minimum_h_bar_eigenvalue, + "h_bar_psd_tolerance": weight_tolerance, + "hamiltonian_hermiticity_residual_fro": hermiticity_residual, + "one_particle_twirl_sha256": sha256_bytes(one_particle_twirl.tobytes()), + "interaction_V_sha256": sha256_bytes(interaction_operator.tobytes()), + "h_bar_sha256": sha256_bytes(h_bar.tobytes()), + "hamiltonian_sha256": sha256_bytes(h_bar.tobytes()), + "beta_results": results, + } + + +def run_cell( + manifest: dict[str, Any], + cell: Cell, + rng: np.random.Generator, +) -> tuple[dict[str, Any], list[dict[str, Any]]]: + if cell.kind == "candidate": + return run_candidate_cell(manifest, cell, rng) + if cell.kind == "split_orthogonal": + return run_split_cell(manifest, cell, rng) + if cell.kind == "semigroup_cone": + return run_semigroup_cell(manifest, cell, rng) + if cell.kind == "component_control": + return run_component_cell(manifest, cell, rng) + raise ValueError(f"unknown cell kind {cell.kind}") + + +def expected_cell_samples(manifest: dict[str, Any], cell: Cell) -> int: + if cell.kind == "candidate": + return int(manifest["candidate"]["samples_per_cell"]) + if cell.kind in {"split_orthogonal", "semigroup_cone"}: + return int(manifest["positive_anchors"][cell.kind]["samples_per_cell"]) + if cell.kind == "component_control": + return int(manifest["component_controls"]["samples_per_cell"]) + raise ValueError(f"unknown cell kind {cell.kind}") + + +def git_revision() -> str: + try: + completed = subprocess.run( + ["git", "rev-parse", "HEAD"], + cwd=SOLUTION_DIR, + check=True, + text=True, + capture_output=True, + ) + return completed.stdout.strip() + except (OSError, subprocess.CalledProcessError): + return "unavailable" + + +def csv_row_count(path: Path) -> int: + with path.open(newline="", encoding="utf-8") as handle: + reader = csv.DictReader(handle) + if tuple(reader.fieldnames or ()) != CSV_FIELDS: + raise ValueError(f"unexpected CSV schema in {path}") + return sum(1 for _ in reader) + + +def load_reusable_cell( + summary_path: Path, + rows_path: Path, + *, + cell: Cell, + expected_samples: int, + protocol_id: str, +) -> dict[str, Any] | None: + if not summary_path.is_file() or not rows_path.is_file(): + return None + try: + summary = json.loads(summary_path.read_text(encoding="utf-8")) + valid = ( + summary["cell_id"] == cell.cell_id + and summary["protocol_id"] == protocol_id + and int(summary["sample_count"]) == expected_samples + and int(summary["row_count"]) == expected_samples + and summary["rows_sha256"] == sha256_file(rows_path) + and csv_row_count(rows_path) == expected_samples + ) + except (OSError, ValueError, KeyError, json.JSONDecodeError): + return None + return summary if valid else None + + +def run_or_resume_stage( + output_path: Path, + builder: Any, + *, + protocol_id: str, +) -> dict[str, Any]: + if output_path.is_file(): + try: + existing = json.loads(output_path.read_text(encoding="utf-8")) + if existing.get("protocol_id") == protocol_id: + return existing + except (OSError, json.JSONDecodeError): + pass + started = time.monotonic() + result = builder() + result["protocol_id"] = protocol_id + result["completed_at"] = utc_now() + result["elapsed_seconds"] = time.monotonic() - started + atomic_write_json(output_path, result) + return result + + +def consolidate_rows( + output_path: Path, + cells: Sequence[Cell], + row_paths: dict[str, Path], + summaries: dict[str, dict[str, Any]], +) -> int: + rows: list[dict[str, Any]] = [] + for cell in cells: + if cell.cell_id not in summaries: + continue + with row_paths[cell.cell_id].open(newline="", encoding="utf-8") as handle: + reader = csv.DictReader(handle) + if tuple(reader.fieldnames or ()) != CSV_FIELDS: + raise ValueError(f"unexpected row schema for {cell.cell_id}") + rows.extend(dict(row) for row in reader) + atomic_write_csv(output_path, rows) + return len(rows) + + +def artifact_entry(path: Path, output_dir: Path, *, rows: int | None = None) -> dict[str, Any]: + entry: dict[str, Any] = { + "path": str(path.relative_to(output_dir)), + "bytes": path.stat().st_size, + "sha256": sha256_file(path), + } + if rows is not None: + entry["rows"] = rows + return entry + + +def aggregate_cell_results( + cells: Sequence[Cell], + summaries: dict[str, dict[str, Any]], +) -> dict[str, Any]: + kind_counts: dict[str, dict[str, int]] = {} + high_precision_escalations = 0 + raw_inconclusive_determinants = 0 + expected_exact_zero_controls = 0 + unexpected_inconclusive_determinants = 0 + fock_checks = 0 + maximum_fock_error = 0.0 + for cell in cells: + summary = summaries.get(cell.cell_id) + if summary is None: + continue + counts = kind_counts.setdefault(cell.kind, {"pass": 0, "fail": 0}) + counts[str(summary["status"])] += 1 + high_precision_escalations += int(summary.get("high_precision_escalations", 0)) + raw_inconclusive = int(summary.get("inconclusive_determinants", 0)) + expected_exact_zero = int(summary.get("expected_exact_zero_controls", 0)) + unexpected_inconclusive = int( + summary.get( + "unexpected_inconclusive_determinants", + max(0, raw_inconclusive - expected_exact_zero), + ) + ) + raw_inconclusive_determinants += raw_inconclusive + expected_exact_zero_controls += expected_exact_zero + unexpected_inconclusive_determinants += unexpected_inconclusive + fock_checks += int(summary.get("fock_checks", 0)) + maximum_fock_error = max( + maximum_fock_error, + float(summary.get("maximum_abs_fock_error", 0.0)), + ) + return { + "cell_status_by_kind": kind_counts, + "high_precision_escalations": high_precision_escalations, + "inconclusive_determinants": raw_inconclusive_determinants, + "raw_inconclusive_determinants": raw_inconclusive_determinants, + "expected_exact_zero_controls": expected_exact_zero_controls, + "unexpected_inconclusive_determinants": unexpected_inconclusive_determinants, + "fock_checks": fock_checks, + "maximum_abs_fock_error": maximum_fock_error, + } + + +def report_markdown(report: dict[str, Any]) -> str: + lines = [ + "# Issue 121 preregistered verification report", + "", + f"- Status: {report['status']}", + f"- Protocol: `{report['protocol_id']}`", + f"- Completed cells: {report['completed_cells']} / {report['total_cells']}", + f"- Consolidated random-word rows: {report['sample_rows']}", + f"- Exact certificates: {report['stage_status']['exact_certificates']}", + f"- Twirl checks: {report['stage_status']['twirl_checks']}", + f"- Four-site physical benchmark: {report['stage_status']['physical_benchmark']}", + ( + "- Raw numeric inconclusive classifications: " + f"{report['aggregates']['raw_inconclusive_determinants']}" + ), + ( + "- Expected exact-zero mixed O(1,1) controls: " + f"{report['aggregates']['expected_exact_zero_controls']}" + ), + f"- Unexpected inconclusive determinants: {report['aggregates']['unexpected_inconclusive_determinants']}", + "", + "Random-word checks are implementation audits, not proofs. The exact", + "Fraction certificates and theorem documents carry the algebraic claims.", + "A COMPLETE sentinel is emitted only for an all-pass full protocol.", + "", + ] + if report["failed_cells"]: + lines.extend(["## Failed cells", ""]) + lines.extend(f"- `{cell_id}`" for cell_id in report["failed_cells"]) + lines.append("") + if report["pending_cells"]: + lines.extend(["## Pending cells", ""]) + lines.extend(f"- `{cell_id}`" for cell_id in report["pending_cells"]) + lines.append("") + return "\n".join(lines) + + +def run_verification( + manifest_path: Path, + output_dir: Path, + *, + max_new_cells: int | None = None, + cell_ids: Sequence[str] | None = None, +) -> dict[str, Any]: + manifest = load_manifest(manifest_path) + cells = build_cells(manifest) + cell_by_id = {cell.cell_id: cell for cell in cells} + requested_cell_ids = ( + None if cell_ids is None else list(dict.fromkeys(map(str, cell_ids))) + ) + if requested_cell_ids is not None: + unknown_cell_ids = [ + cell_id for cell_id in requested_cell_ids if cell_id not in cell_by_id + ] + if unknown_cell_ids: + raise ValueError( + "unknown --cell-id value(s): " + ", ".join(unknown_cell_ids) + ) + environment_signature = { + "python_major": int(sys.version_info.major), + "python_full": sys.version, + "numpy": np.__version__, + "scipy": scipy.__version__, + "mpmath": mp.__version__, + } + manifest_hash = sha256_bytes(canonical_json(manifest).encode("utf-8")) + verifier_hash = sha256_file(Path(__file__)) + support_module_hash = sha256_file(SOLUTION_DIR / "sign_problem_hunter.py") + protocol_id = sha256_bytes( + canonical_json( + { + "manifest_sha256": manifest_hash, + "verifier_sha256": verifier_hash, + "sign_problem_hunter_sha256": support_module_hash, + "environment_signature": environment_signature, + } + ).encode("utf-8") + ) + output_dir.mkdir(parents=True, exist_ok=True) + complete_path = output_dir / "COMPLETE" + report_path = output_dir / "report.json" + report_md_path = output_dir / "report.md" + if complete_path.exists(): + try: + sentinel = json.loads(complete_path.read_text(encoding="utf-8")) + prior_report = json.loads(report_path.read_text(encoding="utf-8")) + current_report_hash = sha256_file(report_path) + current_report_md_hash = sha256_file(report_md_path) + except (OSError, json.JSONDecodeError) as error: + raise RuntimeError( + "COMPLETE exists but its report artifacts are invalid" + ) from error + if ( + sentinel.get("protocol_id") == protocol_id + and prior_report.get("protocol_id") == protocol_id + and prior_report.get("status") == "pass" + and sentinel.get("report_json_sha256") == current_report_hash + and sentinel.get("report_markdown_sha256") == current_report_md_hash + ): + return prior_report + raise RuntimeError("COMPLETE sentinel or report integrity check failed") + + manifest_copy = output_dir / "manifest.json" + if manifest_copy.is_file(): + existing_manifest = json.loads(manifest_copy.read_text(encoding="utf-8")) + existing_hash = sha256_bytes(canonical_json(existing_manifest).encode("utf-8")) + if existing_hash != manifest_hash: + raise RuntimeError("output directory contains a different manifest") + else: + atomic_write_json(manifest_copy, manifest) + + run_path = output_dir / "run.json" + if run_path.is_file(): + run_payload = json.loads(run_path.read_text(encoding="utf-8")) + if run_payload.get("protocol_id") != protocol_id: + raise RuntimeError("output directory was created by a different verifier") + else: + run_payload = { + "schema_version": 1, + "status": "running", + "started_at": utc_now(), + "protocol_id": protocol_id, + "manifest_sha256": manifest_hash, + "verifier_sha256": verifier_hash, + "sign_problem_hunter_sha256": support_module_hash, + "git_revision": git_revision(), + "base_seed": int(manifest["seed"]), + "total_cells": len(cells), + "environment_signature": environment_signature, + "environment": environment_signature, + } + atomic_write_json(run_path, run_payload) + + stage_specs = ( + ("exact_certificates", exact_certificates), + ("twirl_checks", run_twirl_checks), + ("physical_benchmark", run_physical_benchmark), + ) + stages: dict[str, dict[str, Any]] = {} + stage_paths: dict[str, Path] = {} + for stage_name, builder in stage_specs: + stage_path = output_dir / f"{stage_name}.json" + stages[stage_name] = run_or_resume_stage( + stage_path, + lambda builder=builder: builder(manifest), + protocol_id=protocol_id, + ) + stage_paths[stage_name] = stage_path + + cell_dir = output_dir / "cells" + row_dir = output_dir / "cell_rows" + cell_dir.mkdir(parents=True, exist_ok=True) + row_dir.mkdir(parents=True, exist_ok=True) + summaries: dict[str, dict[str, Any]] = {} + row_paths = {cell.cell_id: row_dir / f"{cell.cell_id}.csv" for cell in cells} + summary_paths = {cell.cell_id: cell_dir / f"{cell.cell_id}.json" for cell in cells} + + for cell in cells: + reusable = load_reusable_cell( + summary_paths[cell.cell_id], + row_paths[cell.cell_id], + cell=cell, + expected_samples=expected_cell_samples(manifest, cell), + protocol_id=protocol_id, + ) + if reusable is not None: + summaries[cell.cell_id] = reusable + + pending = [cell for cell in cells if cell.cell_id not in summaries] + selected_pending = ( + pending + if requested_cell_ids is None + else [ + cell for cell in pending if cell.cell_id in set(requested_cell_ids) + ] + ) + if max_new_cells is not None: + if max_new_cells < 0: + raise ValueError("max_new_cells must be nonnegative") + pending_to_run = selected_pending[:max_new_cells] + else: + pending_to_run = selected_pending + + progress_path = output_dir / "progress.json" + progress_stride = max(1, math.ceil(len(cells) / 25)) + for new_cell_index, cell in enumerate(pending_to_run, start=1): + seed = derive_seed(int(manifest["seed"]), cell.cell_id) + started = time.monotonic() + summary, rows = run_cell( + manifest, + cell, + np.random.default_rng(seed), + ) + if len(rows) != expected_cell_samples(manifest, cell): + raise RuntimeError(f"cell {cell.cell_id} emitted the wrong row count") + atomic_write_csv(row_paths[cell.cell_id], rows) + summary.update( + { + "protocol_id": protocol_id, + "seed": seed, + "completed_at": utc_now(), + "elapsed_seconds": time.monotonic() - started, + "row_count": len(rows), + "rows_file": str(row_paths[cell.cell_id].relative_to(output_dir)), + "rows_sha256": sha256_file(row_paths[cell.cell_id]), + } + ) + atomic_write_json(summary_paths[cell.cell_id], summary) + summaries[cell.cell_id] = summary + atomic_write_json( + progress_path, + { + "schema_version": 1, + "protocol_id": protocol_id, + "updated_at": utc_now(), + "completed_cells": len(summaries), + "total_cells": len(cells), + "last_completed_cell": cell.cell_id, + }, + ) + + if ( + new_cell_index % progress_stride == 0 + or new_cell_index == len(pending_to_run) + ): + print( + canonical_json( + { + "event": "cell_progress", + "completed_cells": len(summaries), + "total_cells": len(cells), + "new_cells_this_invocation": new_cell_index, + "last_completed_cell": cell.cell_id, + } + ), + flush=True, + ) + samples_path = output_dir / "samples.csv" + sample_rows = consolidate_rows(samples_path, cells, row_paths, summaries) + failed_cells = [ + cell.cell_id + for cell in cells + if summaries.get(cell.cell_id, {}).get("status") == "fail" + ] + pending_cells = [cell.cell_id for cell in cells if cell.cell_id not in summaries] + stages_pass = all(stage["status"] == "pass" for stage in stages.values()) + if pending_cells: + status = "partial" + elif failed_cells or not stages_pass: + status = "fail" + else: + status = "pass" + + artifacts = { + "manifest": artifact_entry(manifest_copy, output_dir), + "samples": artifact_entry(samples_path, output_dir, rows=sample_rows), + } + artifacts.update( + { + stage_name: artifact_entry(stage_paths[stage_name], output_dir) + for stage_name in stage_paths + } + ) + report = { + "schema_version": 1, + "status": status, + "generated_at": utc_now(), + "protocol_id": protocol_id, + "manifest_sha256": manifest_hash, + "verifier_sha256": verifier_hash, + "sign_problem_hunter_sha256": support_module_hash, + "environment_signature": environment_signature, + "total_cells": len(cells), + "completed_cells": len(summaries), + "requested_cell_ids": requested_cell_ids, + "failed_cells": failed_cells, + "pending_cells": pending_cells, + "sample_rows": sample_rows, + "expected_full_sample_rows": int(manifest["expected_workload"]["total_words"]), + "stage_status": {name: stage["status"] for name, stage in stages.items()}, + "aggregates": aggregate_cell_results(cells, summaries), + "artifacts": artifacts, + "resource_note": manifest["execution"], + "claim_boundary": ( + "Passing establishes reproducibility of the preregistered checks. " + "It is neither a proof by sampling nor a literature-priority claim." + ), + } + atomic_write_json(report_path, report) + report_md_path = output_dir / "report.md" + atomic_write_text(report_md_path, report_markdown(report)) + + run_payload.update( + { + "status": status, + "updated_at": utc_now(), + "completed_cells": len(summaries), + "report_json_sha256": sha256_file(report_path), + "report_markdown_sha256": sha256_file(report_md_path), + } + ) + atomic_write_json(run_path, run_payload) + atomic_write_json( + progress_path, + { + "schema_version": 1, + "protocol_id": protocol_id, + "updated_at": utc_now(), + "status": status, + "completed_cells": len(summaries), + "total_cells": len(cells), + "failed_cells": failed_cells, + "pending_cells": pending_cells, + }, + ) + if status == "pass": + if sample_rows != int(manifest["expected_workload"]["total_words"]): + raise RuntimeError("all cells completed but consolidated row count is wrong") + atomic_write_text( + complete_path, + canonical_json( + { + "protocol_id": protocol_id, + "report_json_sha256": sha256_file(report_path), + "report_markdown_sha256": sha256_file(report_md_path), + "completed_at": utc_now(), + } + ) + + "\n", + ) + return report + + +def parse_args(argv: Sequence[str] | None = None) -> argparse.Namespace: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--manifest", + type=Path, + default=SOLUTION_DIR / "issue121_full_run.json", + ) + parser.add_argument( + "--output", + type=Path, + default=SOLUTION_DIR / "issue121_full_run", + ) + parser.add_argument( + "--cell-id", + dest="cell_ids", + action="append", + default=None, + metavar="CELL_ID", + help="run only this cell if pending; repeat to select multiple pilot cells", + ) + parser.add_argument( + "--max-new-cells", + type=int, + default=None, + help="run at most this many not-yet-completed cells, for resumable pilots", + ) + parser.add_argument("--list-cells", action="store_true") + parser.add_argument("--validate-only", action="store_true") + return parser.parse_args(argv) + + +def main(argv: Sequence[str] | None = None) -> int: + args = parse_args(argv) + manifest = load_manifest(args.manifest) + if args.list_cells: + for cell in build_cells(manifest): + print(cell.cell_id) + return 0 + if args.validate_only: + print(canonical_json(manifest["expected_workload"])) + return 0 + report = run_verification( + args.manifest, + args.output, + max_new_cells=args.max_new_cells, + cell_ids=args.cell_ids, + ) + print( + canonical_json( + { + "status": report["status"], + "completed_cells": report["completed_cells"], + "total_cells": report["total_cells"], + "report": str(args.output / "report.json"), + } + ) + ) + return 1 if report["status"] == "fail" else 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md b/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md index 8fa2da9de..01174c48f 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md @@ -18,7 +18,13 @@ For epsilon>0 and kappa>0 define S = diag(1,1,-1), B = S A S, and let C(epsilon,kappa) be the union of the two S3 conjugacy orbits of A -and B. Throughout the open triangle +and B. Throughout (R), the three diagonal entries of A (and of B) are pairwise +distinct. Any permutation stabilizing either matrix must therefore be the identity. +If the two orbits intersected, equality of their ordered diagonal entries would +again force the conjugating permutation to be the identity, but A!=B. Thus the +two orbits are disjoint and C(epsilon,kappa) contains exactly twelve matrices. + +Throughout the open triangle epsilon>0, kappa>0, 40 epsilon + 59 kappa < 2, (R) @@ -32,6 +38,9 @@ the following statements hold. det(I+T)>0 on the isolated three-mode space. Embedded local words obey det(I+T)>=0. 2. C has no common H>0 satisfying X^T H+H X<=0 for every X in C. + Consequently no fixed complex similarity carries C into an ordinary + nondegenerate Hermitian contraction cone, expansion cone, or split equality + class in the same one-particle dimension. 3. C real-linearly spans all of M_3(R). 4. The number-conserving Nambu lifts of C cannot satisfy Eqs. (2)-(3) of Wei, Phys. Rev. B 110, 075146 (2024), after any one fixed complex @@ -140,6 +149,45 @@ H exists. At epsilon=1/100 and kappa=1/1000 the two bounds are r <= -1541/24791, r >= 1541/42609. +### Fixed-similarity consequence + +The preceding result also excludes every ordinary nondegenerate Hermitian +contraction metric after an arbitrary fixed complex similarity. Suppose, to the +contrary, that one fixed L in GL_3(C) and one fixed nonsingular Hermitian eta obey + + Y_X^dagger eta+eta Y_X<=0, Y_X=L X L^(-1), + +for all X in C. Pull the metric back as + + G=L^dagger eta L. + +Then G is nonsingular Hermitian and + + X^dagger G+G X<=0. + +Fix any X in C, which is Hurwitz by Section 2, and put + + Q=-(X^dagger G+G X)>=0. + +The Lyapunov integral gives + + G=integral_0^infinity exp(X^dagger t) Q exp(X t) dt>=0. + +Since G is nonsingular, G>0. Because X is real, H=Re G is a real symmetric +positive-definite matrix and taking real parts gives + + X^T H+H X<=0 + +for every X in C, contradicting the result above. An expansion inequality is +reduced to the contraction case by replacing eta with -eta. The equality case is +included as well. Hence the obstruction covers arbitrary fixed real or complex +similarities to ordinary nondegenerate Hermitian contraction or expansion +semigroups, including split-metric equality classes. + +This consequence is same-dimensional and metric-based. It does not exclude a +general invariant-cone realization, a dilation by ancillary modes, or a different +Gaussian support. + ## 4. Exact full-span certificate Let @@ -330,14 +378,37 @@ quadratic form is K_X=B_CAR D_X, not D_X itself, and (1/4) zeta^T K_X zeta = c^dagger X c - (1/2) tr X. +Consequently the physical Gaussian differs from the corresponding spin lift only +by the strictly positive scalar exp[tau tr(X)/2]. This scalar cannot affect a sign +and will be suppressed in the fixed-support comparison below. + Let W be the one fixed complex CAR basis transformation in a hypothetical Wei -representation. Pull its reality operation and Hermitian contraction form back by -W to the original Nambu coordinates. The first Wei condition then defines an -antilinear CAR isometry +representation, and let J1,J2 be one fixed pair common to every X. Choose the +convention that W maps the original Nambu bilinear form to the canonical +Majorana coordinate space: + + W^T W=B_CAR, + A_X=W D_X W^(-1). + +The CAR identity for D_X then gives A_X^T=-A_X. Pull the two Wei structures back +to the original Nambu coordinates by defining + + U=W^(-1) J1 conjugate(W), + eta=W^dagger (i J2) W. + +Wei's first condition is equivalently + + A_X J1=J1 conjugate(A_X). + +With the convention above this becomes + + D_X U=U conjugate(D_X). + +Thus the pulled reality operation is the antilinear CAR isometry Theta_1=U K, Theta_1^2=+I or -I, -that commutes with every D_X. This reality equality is real-linear in X. Since +commuting with every D_X. This reality equality is real-linear in X. Since span_R F=M_n(R), it extends from X in F to D_Y for every Y in M_n(R), in particular to Y=I. @@ -358,13 +429,16 @@ D_X makes Theta_1=K. Full span has removed any hidden Kramers partner. ### 5.3 The contraction structure forces a common H>0 -In a canonical Majorana frame let eta_0=iJ2. After pulling both Hermitian forms -back by the same CAR transformation, define +For the surviving symmetric J1 case, let eta_0=iJ2 and recall that + + eta=W^dagger eta_0 W. + +Define the other pulled Hermitian form by - G = U^T B_CAR, - eta = pulled-back eta_0. + G=U^T B_CAR=W^dagger J1 W. -Equivalently G is the congruence transform of J1. Anticommutation of J1 and J2 +The second equality uses W^T W=B_CAR and J1^T=J1. Thus G and eta are the +congruence transforms of J1 and eta_0 by the same W. Anticommutation of J1 and J2 gives the coordinate-independent identity eta G^(-1) eta = -G. (C) @@ -402,8 +476,11 @@ therefore lies outside both fixed-metric sufficient classes of Wei 2024, includi the complex-orthogonal Majorana extension stated after Eq. (3). This statement concerns the supplied Gaussian vertex support and its natural -principal logarithms. It does not prove that the resulting Hamiltonian has no -different Hubbard-Stratonovich, fermion-bag, or other positive decomposition. +principal logarithms, using one common fixed pair and one common fixed complex +CAR basis in the same Nambu dimension. It does not exclude ancillary-mode +dilations, a general invariant-cone similarity, or a different Gaussian support. +Nor does it prove that the resulting Hamiltonian has no different +Hubbard-Stratonovich, fermion-bag, or other positive decomposition. ### 5.4 Small-time robustness against alternate logarithms @@ -414,8 +491,9 @@ such that, for every 00 such that, for every X in C(epsilon,kappa) and @@ -593,14 +671,28 @@ where p_t=(2+t)[(1-t)(d-c)-b(1+t)-delta_1-delta_2-delta_3 t] > 0, q_t=(2-t)[(1-t)(c+d)+b(1+t)+delta_1+delta_2-delta_3 t] > 0. +The displayed signs are consequences of G_t>0, not additional assumptions. +Indeed, positivity of all seven parameters and t in (0,1) give + + d(1-t)>delta_3 t, + +and + + p_t/(2+t) + =G_t+(1-t)[d(1-t)-delta_3 t]>0, + q_t/(2-t) + =(1-t)d-delta_3 t+(1-t)c+b(1+t)+delta_1+delta_2>0. + They require r<0 and r>0. Multiplying by q_t and p_t and adding gives the exact Farkas contradiction (p_t+q_t) G_t <= 0. -For fixed rational t these are rational linear inequalities. G_t>0 is a nonempty -open convex cone; removing overall scale leaves six essential continuous parameters. -At the original point and t=3/4, +For fixed rational t these are rational linear inequalities. Within the +seven-parameter structured family, G_t>0 is a nonempty open convex cone; removing +overall scale leaves six essential continuous parameters. Here and below, "open" +means relative to this structured design space, not to the ambient space of +arbitrary twelve-tuples in M_3(R). At the original point and t=3/4, G_t=1679/16000, p_t=10109/16000, @@ -617,8 +709,75 @@ For X=A or B define exp[tau c^dagger (P_sigma X P_sigma^T) c]. Within each particle-number sector the exterior-power representation of S3 is real -and multiplicity-free. Group averaging makes M_X Hermitian. Generically it is not a -Gaussian operator: the average contains genuine many-body interactions. +and multiplicity-free. Group averaging therefore makes M_X Hermitian. + +We now give exact local certificates for interaction and failure of Gaussian +closure. Let alpha_X(tau) and beta_X(tau) be the scalar eigenvalues of the +one-particle twirl on the trivial and standard irreducible sectors. Then + + alpha_X(tau)=(1/3) e^T exp(tau X) e, + beta_X(tau)=(1/2)[tr exp(tau X)-alpha_X(tau)]. + +Under the three-dimensional Hodge identification, + + wedge^2 exp(tau X)=exp[tau tr(X)] exp(-tau X^T). + +The sign irrep in the two-particle sector corresponds to the uniform Hodge vector, +so its twirl eigenvalue is + + d_(2,X)(tau) + =exp[tau tr(X)] (1/3) e^T exp(-tau X) e. + +Put + + a_X=(1/3)e^T X e, b_X=(1/3)e^T X^2 e, + t_X=tr(X), s_X=tr(X^2). + +Taylor expansion gives + + beta_X(tau) + =1+(t_X-a_X)tau/2+(s_X-b_X)tau^2/4+O(tau^3), + d_(2,X)(tau) + =1+(t_X-a_X)tau + +(t_X^2/2-t_X a_X+b_X/2)tau^2+O(tau^3). + +The two required certificates are different. A permutation-invariant operator that +is a constant plus a number-conserving one-body operator has vacuum eigenvalue one, +one-particle standard eigenvalue beta_X, and two-particle sign eigenvalue +2 beta_X-1. Hence + + d_(2,X)-(2 beta_X-1) + =[(t_X^2-s_X)/2-t_X a_X+b_X]tau^2+O(tau^3) (I_X) + +is an interaction certificate. + +Likewise M_X(tau) is analytic and equals I at tau=0. If it were Gaussian at +arbitrarily small positive values of tau, its principal operator logarithm at those +values would be quadratic. Since M_X commutes with particle number, that logarithm +would be number-conserving, and exterior-power multiplicativity would require +d_(2,X)=beta_X^2. Thus + + d_(2,X)-beta_X^2 + =[(t_X^2-s_X)/2-t_X a_X+b_X + -(t_X-a_X)^2/4]tau^2+O(tau^3) (G_X) + +is a non-Gaussian certificate. + +At epsilon=1/100 and kappa=1/1000, direct substitution into these exact formulas +produces + + I_A(tau)=(15062013/3000000)tau^2+O(tau^3), + G_A(tau)=(363599/360000)tau^2+O(tau^3), + +and + + I_B(tau)=(3056033/3000000)tau^2+O(tau^3), + G_B(tau)=(797/120000)tau^2+O(tau^3). + +All four leading coefficients are nonzero. Analyticity therefore makes both twirls +interacting and non-Gaussian for all sufficiently small positive tau. The +coefficients depend continuously on the matrix parameters, so the conclusion +persists on an open neighborhood of the rational point. For positive g_A,g_B, sums of local copies on overlapping triangular clusters, @@ -634,10 +793,7 @@ twirl is Hermitian. The Fock trace for every sequence is This is an engineered interacting Hamiltonian with an exact sign-free series expansion, not a standard auxiliary-field DQMC decomposition of a two-body Hubbard -Hamiltonian. No sampler, estimator, or scaling benchmark is claimed. - -At the rational point, exact small-tau invariants for both twirls are nonzero, so -both are interacting and non-Gaussian on an open neighborhood. Determinant +Hamiltonian. No sampler, estimator, or scaling benchmark is claimed. Determinant positivity holds at arbitrary word depth, not merely over a sampled range. ## 8. Novelty boundary and publication position @@ -646,7 +802,8 @@ Established ingredients include logarithmic norms, common polyhedral Lyapunov functions, contraction semigroups, and group twirling. The theorem candidate is the combination of: -- an explicit nonzero-volume QMC vertex family certified by a common polyhedral norm; +- an explicit seven-parameter QMC vertex family occupying an open region relative + to its structured design cone and certified by a common polyhedral norm; - exact failure of all common ellipsoidal metrics; - a full-span odd-dimensional obstruction separating the same support from Wei 2024 even under fixed complex CAR basis changes; diff --git a/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md b/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md index c2cbcf29c..b32948266 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md @@ -5,6 +5,27 @@ Date: 2026-07-29 Status: targeted primary-source search, not a proof of priority. No claim below is based merely on the absence of a search hit. +The search was refreshed on 2026-07-29 against the arXiv/APS primary records, +the Semantic Scholar citation graph of arXiv:1712.09412, the issue #121 comment +thread, and every open challenge PR in the upstream repository. Query families +combined the physics vocabulary + +```text +fermion determinant / determinant QMC / sign-problem-free / auxiliary field +``` + +with the matrix vocabulary + +```text +common norm / logarithmic norm / matrix measure / polyhedral Lyapunov / +Banach contraction / H-matrix / Metzler / cone / compound matrix +``` + +and separately searched citations of the 2015 split-orthogonal, 2016 Majorana, +2020 intrinsic-sign, 2024 semigroup, and 2025 time-reversal-positivity papers. +This protocol can falsify a priority claim by finding prior art; it cannot prove +priority by failing to find it. + ## 1. Search outcome The targeted search found no QMC paper that directly uses either @@ -32,6 +53,12 @@ These are negative targeted-search results, not exhaustive historical proofs. `main_theorem.md` separates the supplied support from these sufficient classes, not from every possible positive decomposition. + Wei's 2025 follow-up, *Time-reversal positivity*, arXiv:2510.06226, + develops a cone-theoretic positivity tool for the time-reversal-symmetric + non-Hermitian Hubbard setting. It is prior art for the time-reversal cone + language, but it retains a fixed antiunitary structure and does not supply the + real common-Banach-norm determinant criterion used here. + 2. L. Wang et al., Split orthogonal group: a guiding principle for sign-problem-free fermionic simulations, Phys. Rev. Lett. 115, 250601 (2015): https://arxiv.org/abs/1506.05349 @@ -63,6 +90,27 @@ Items 2-4 are the principal group, reflection-positivity, and MTR baselines. does not use the signed A/B polyhedral family or the Perron-plus-compound orientation criterion. +7. O. Golan, A. Smith, and Z. Ringel, Intrinsic sign problem in fermionic and + bosonic chiral topological matter, Phys. Rev. Research 2, 043032 (2020): + https://arxiv.org/abs/2005.05566 + + Appendix F is an important scope check on local and homogeneous known DQMC + design principles. The present support-level separation is not an intrinsic + sign-problem theorem for a phase and must not be advertised as one. + +8. C. Wu and S.-C. Zhang, Phys. Rev. B 71, 155115 (2005), together with the + finite-density designer models of Berg, Metlitski, and Sachdev, Science 338, + 1606 (2012), and Schattner et al., Phys. Rev. X 6, 031028 (2016), are controls + against an incorrect finite-density novelty claim. Their nonnegative weights + follow from determinant squaring or a fixed Kramers/conjugate pairing. Adding + a duplicated flavor to the present real support would therefore be useful as a + control but not a new mechanism. + +The upstream issue thread also points to Appendix A of Phys. Rev. X 9, 021022 +(2019), where a pseudo-unitary SU(n,n) condition makes the determinant real. +That observation is included here as prior art even though reality alone is weaker +than the nonnegativity theorem sought in issue #121. + ## 3. Closest control and matrix sources 1. F. Blanchini, Nonquadratic Lyapunov functions for robust control, Automatica 31, @@ -106,9 +154,16 @@ second-compound bound for fermion determinant positivity. For the polyhedral family: > We give an explicit open sign-free generator-support family certified by a -> non-Hilbert common norm and prove that, at generator level and for sufficiently -> small discrete time steps, it is not embeddable in Wei's fixed-metric complex-CAR -> semigroups. +> non-Hilbert common norm. Within one fixed, same-dimensional one-particle/CAR +> representation, we prove that it cannot be mapped by a fixed complex similarity +> into an ordinary Hermitian contraction or expansion cone, a split equality +> class, or Wei's fixed complex-CAR semigroups; the discrete-support statement +> persists for sufficiently small time steps. + +The elementary common-norm determinant lemma and polyhedral Lyapunov theory are +not new mathematics. The candidate contribution is their explicit use as a QMC +guiding principle, the open family separating it from the cited fixed-metric +classes, and the interacting realization using exactly the certified vertices. For the finite-density direction: diff --git a/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md b/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md index 25a4c6683..5a16d2b17 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md @@ -1,17 +1,286 @@ -# Physical classification and no-go results for the S3 twirl +# Interacting lattice CT Gaussian-vertex realization of the S3 twirl Date: 2026-07-29 -Status: analytic companion note. No new numerical computation is used. +Status: analytic theorem and implementation specification. No new numerical +computation is used. The construction below is a complete, finite-temperature, +interacting lattice realization of the determinant-positive support in issue #121. +Finite-density ground-state physics is not a requirement of that issue and is not +claimed here. -## Why the complete S3 twirl is Hermitian +## 1. Reviewable lattice theorem + +Fix parameters + + ε>0, κ>0, 40ε+59κ<2, s>0, + +and define + + A = [ -1-ε-κ 1 -ε ] + [ 0 -1-κ 1 ] + [ 2 0 -2-κ], + + S=diag(1,1,-1), B=SAS. + +Here s is the fixed strength of a Gaussian vertex. It is not an imaginary-time +coordinate. Let Λ be any finite lattice with one spinless fermion mode per site, +and let D be any collection of ordered triples Δ=(r₁,r₂,r₃) of distinct sites. +The triples may overlap. Write E_Δ:R³→R^|Λ| for the coordinate embedding and P_σ +for the 3-by-3 permutation matrix of σ∈S3. For X∈{A,B}, define + + Y_(Δ,X,σ)=E_Δ P_σ X P_σ^T E_Δ^T, + + U_(Δ,X,σ)=exp(sY_(Δ,X,σ)) + =I+E_Δ[exp(sP_σXP_σ^T)-I₃]E_Δ^T, + + V_(Δ,X,σ)=exp[s sum_(p,q∈Δ) c_p^dagger + (P_σXP_σ^T)_(pq)c_q] + =Γ(U_(Δ,X,σ)). + +The resolved V vertices need not be Hermitian. Their complete local twirls are + + M_(Δ,X)=(1/6) sum_(σ∈S3) V_(Δ,X,σ). + +For arbitrary couplings g_(Δ,X)≥0, set + + G₀=sum_(Δ,X) g_(Δ,X), + + H_bar=sum_(Δ,X) g_(Δ,X)[I-M_(Δ,X)]. (1) + +Equivalently H_bar=G₀I+H with H=−sum gM. Then: + +1. H_bar is a finite-range, Hermitian, number-conserving interacting Hamiltonian. +2. Its grand-canonical partition function at μ=0 has an exact continuous-time + Gaussian-vertex expansion with nonnegative scalar activities. +3. Every resolved configuration has a nonnegative determinant weight, for every + β≥0, every finite lattice, every overlap pattern, and every expansion order. +4. The construction uses one spinless flavor. No identical-flavor square, + Kramers partner, or conjugate determinant is introduced. + +If D is the set of elementary triangles of a triangular lattice, the local terms +overlap and their quadratic and correlated-hopping pieces move particles through +the connected lattice. Thus this is not a collection of decoupled cells. Its +zero-temperature filling limitation is stated exactly in Section 10. + +### Proof of locality, Hermiticity, and interaction + +Every V_(Δ,X,σ) acts only on the three modes in Δ, so (1) is local. Section 5 +proves that the complete six-term twirl M_(Δ,X) is Hermitian. Every vertex commutes +with the total number N, so H_bar conserves N. + +The normal-ordered identity + + Γ(U)=:exp[c^dagger(U-I)c]: + +shows explicitly that a three-mode Gaussian vertex contains terms through sixth +order in fermion operators. After twirling, Section 6 gives the complete local +operator basis. In particular, the coefficient of n₁n₂n₃ in M_X is exactly + + W_(M_X)=−det[I₃-exp(sX)]. + +Since ||exp(sX)||_infinity≤exp(−κs)<1, this determinant is positive. Therefore +the coefficient of n₁n₂n₃ in −gM_X is strictly positive for every g>0. The +Hamiltonian is genuinely interacting, not merely a quadratic Hamiltonian written +in unusual notation. At generic couplings it also contains ordinary hopping, +density interactions, and correlated pair hopping. A special positive mixture can +cancel one quartic coefficient, but cannot cancel the three-body repulsion; see +Sections 7-8. + +### Proof of the configuration-wise determinant sign + +For every X in either S3 orbit of A or B, + + μ_infinity(X) + =max_i [X_ii+sum_(j≠i)|X_ij|] + =−κ. + +Signed permutations are isometries of the infinity norm. Hence the local block of +each resolved vertex satisfies + + ||exp(sP_σXP_σ^T)||_infinity≤q, q=exp(−κs)<1. + +The embedded U has spectator identity blocks, so + + ||U_(Δ,X,σ)||_infinity≤1. + +For any ordered resolved word + + T_C=U_(Δ_m,X_m,σ_m) ... U_(Δ_1,X_1,σ_1), (2) + +submultiplicativity gives ||T_C||_infinity≤1. Every real eigenvalue λ of the real +matrix T_C therefore obeys −1≤λ≤1, while nonreal eigenvalues occur in conjugate +pairs. Consequently + + det(I+T_C) + =product_(λ real)(1+λ) + product_(Im λ>0)|1+λ|² + ≥0. (3) + +On an isolated three-mode cluster the bound is strict and (3) is positive. On an +embedded lattice a zero is allowed because untouched spectator directions make +the global norm non-strict. Nonnegativity is the sign-free condition required by +issue #121. + +## 2. Exact continuous-time expansion and activities + +Let a resolved label be + + a=(Δ,X,σ), λ_a=g_(Δ,X)/6, B_a=U_(Δ,X,σ). + +The nonnegative number λ_a is the activity of that resolved vertex. Expanding the +interaction exponential for (1), and using the ordered simplex +00, proves that every integrand in +(4) is nonnegative. This is an exact continuous-time Gaussian-vertex QMC +representation of a non-Gaussian interacting Hamiltonian. It is not the standard +auxiliary-field DQMC decomposition of a quartic Hubbard interaction. + +## 3. Directly implementable sampler + +A minimal Metropolis sampler stores an ordered list + + C=[(t₁,a₁),...,(t_m,a_m)] + +and its determinant D(C)=det[I+T_C]. Choose any normalized proposal distribution +q_prop(a)>0 on resolved labels and nonzero probabilities p_ins,p_del. One sweep can +be written as follows. + +```text +C ← empty list; D ← 2^|Λ| +repeat: + choose INSERT or DELETE with probabilities p_ins and p_del + + if INSERT: + draw a from q_prop(a), draw t uniformly in [0,β) + C_new ← C with (t,a) inserted in time order + D_new ← stable_det(I + ordered_product(C_new)) + R ← [β λ_a/(m+1)] [p_del/(p_ins q_prop(a))] [D_new/D] + accept C_new with probability min(1,R) + + if DELETE and m>0: + choose one of the m vertices uniformly; call its label a + C_new ← C with that vertex removed + D_new ← stable_det(I + ordered_product(C_new)) + R ← [m/(β λ_a)] [p_ins q_prop(a)/p_del] [D_new/D] + accept C_new with probability min(1,R) + + after equilibration, measure Gaussian estimators at a chosen cyclic cut +``` + +The insertion and deletion ratios are exact detailed-balance ratios for the +ordered-simplex measure in (4). Insert/delete moves alone connect all finite words; +time shifts and label swaps may be added to improve mixing. A determinant that is +negative beyond floating-point tolerance is an implementation failure, not a sign +to be sampled with reweighting. + +At a cyclic cut with product T, define + + C_ij=[T(I+T)^(-1)]_ij=_C. + +Configuration-wise Wick contractions then give all equal-time number-conserving +observables. The conditional matrix C need not itself look like a physical density +matrix because an individual resolved word is not Hermitian; only the weighted +average is a physical expectation value. + +Let n=|Λ|, k=3, and m be the current expansion order. A transparent dense +implementation exploits B_a-I having rank at most k. Rebuilding one word costs +O(mkn²), and a stabilized determinant costs O(n³), with O(n²+m) storage. Thus a +fully naive sweep of O(m) proposals costs O(m²kn²+mn³). Given cached left/right +products and a stabilized inverse, the matrix-determinant lemma reduces the +algebraic ratio itself to O(kn²+k³). Maintaining those caches after accepted +arbitrary-time insertions and performing periodic QR or SVD stabilization adds an +implementation-dependent polynomial overhead; no fast-update benchmark is claimed +here. The relevant expansion scale is βG₀, although the interacting determinant +changes the actual mean order. Absence of a sign problem does not by itself +guarantee fast Markov-chain mixing. + +For an insertion between T_C=LR, write B_a=I+E D_a E^T with E=E_Δ. The fast ratio +is the k-by-k determinant + + D(C_new)/D(C) + =det_k[I_k+D_a E^T R(I+LR)^(-1)L E]. + +This identity supplies a direct unit test for an optimized implementation against +the full n-by-n determinant. + +### Preregistered no-run smoke benchmark + +The first implementation benchmark is fixed to the previously approved convention: + +- four-site open chain with one spinless orbital per site; +- overlapping ordered triples Δ₁=(1,2,3) and Δ₂=(2,3,4), with no wraparound triple; +- ε=0.01, κ=0.001, and fixed vertex amplitude s=0.1 (called τ=0.1 in + the run configuration); +- g_(Δ,A)=g_(Δ,B)=0.25 for both triples; +- μ=0 and β∈{0.25,0.5,1,2}. + +This paragraph records inputs only. No chain was sampled and no benchmark number is +claimed in this analytic note. Before a future run, the random seed, warmup, +measurement count, stabilization interval, and error analysis must also be frozen. +For this 16-dimensional Fock space, a future implementation can compare Z, energy, +density, and selected correlators against exact diagonalization while also checking +that every accepted determinant sign is nonnegative. + +## 4. Finite-temperature physical meaning and scope + +The model (1) is a short-range spinless-fermion lattice Hamiltonian. On overlapping +triangles it has mobile excitations and genuine interactions. Equation (4) can be +used to measure its free energy, energy, density, compressibility, and equal- or +imaginary-time correlation functions at any finite β. At μ=0, thermally excited +particle sectors contribute even though the exact zero-temperature ground state is +the vacuum. + +Adding −μN multiplies the one-body word by + + z=exp(βμ), + +so the configuration determinant becomes det(I+zT_C). For μ≤0, z≤1 and the common +nonexpansion proof still gives nonnegative weights. For fixed μ>0 at arbitrarily +large β, the present z=1 theorem is insufficient; the exact obstruction is stated +in Section 10. Therefore this document does not claim a finite-density ground state +or a generic positive-μ algorithm. + +The deliverable in issue #121 is a matrix/Lie-semigroup condition ensuring +determinant nonnegativity. It does not impose finite density as an acceptance +condition. The lattice theorem above supplies a concrete interacting physical +realization of that mathematical result; finite density is a separate extension, +not a criterion that should be retroactively used to reject the issue solution. + +No doubled flavor is needed here. Conversely, doubling the model would trivially +replace every weight by a determinant square, but that is the established +Kramers/identical-flavor mechanism and carries no novelty for issue #121. + +## 5. Why the complete S3 twirl is Hermitian Let rho_N be the S3 action in the N-particle sector. Restricting the Fock twirl to that sector gives M_X^(N) =(1/6) sum_(sigma in S3) - rho_N(sigma) (wedge^N exp(tau X)) rho_N(sigma)^(-1). + rho_N(sigma) (wedge^N exp(sX)) rho_N(sigma)^(-1). Therefore M_X^(N) commutes with rho_N(S3). For N=0,1,2,3 the representations are, respectively, @@ -27,7 +296,7 @@ Hermitian in the standard Fock inner product. A single sampled Gaussian orbit vertex need not be Hermitian; Hermiticity appears only after the complete six-term twirl. -## 1. Complete local operator basis +## 6. Complete local operator basis For three spinless modes, the S3 representations in fixed number sectors are @@ -65,7 +334,7 @@ Thus the generic twirl is not an independent ring-exchange model. Its nonstandar quartic structure is the correlated-hopping projector P_s^dagger P_s, together with a possible three-body density term. -## 2. A tunable familiar slice +## 7. A tunable familiar slice Write the twirl eigenvalues as @@ -76,39 +345,39 @@ hopping coefficient is exactly J_M=(alpha-beta)+(d_2-gamma). -For the rational A and B=SAS family at small tau, +For the rational A and B=SAS family at small s, - J_A = (approximately 5.001995) tau^2 + O(tau^3), - J_B = -(approximately 1.000995) tau^2 + O(tau^3). + J_A = (approximately 5.001995) s^2 + O(s^3), + J_B = -(approximately 1.000995) s^2 + O(s^3). A positive mixture can therefore tune J of the Hamiltonian h=-g_A M_A-g_B M_B to zero near g_B/g_A=5. This gives a familiar hopping-density plus three-body slice. -The exact finite-tau ratio can be obtained by continuity once a time step is fixed. +The exact finite-s ratio can be obtained by continuity once a vertex amplitude is fixed. -## 3. Exact three-body no-go +## 8. Exact three-body no-go For every twirled vertex, - W_M = -det(I-exp(tau X)). + W_M = -det(I-exp(sX)). -If exp(tau X) is a strict real contraction, det(I-exp(tau X))>0. Similarity of A +If exp(sX) is a strict real contraction, det(I-exp(sX))>0. Similarity of A and B implies that their determinants are identical. Hence every positive mixture has - W_h=(g_A+g_B) det(I-exp(tau A)) > 0. + W_h=(g_A+g_B) det(I-exp(sA)) > 0. The three-body repulsion cannot be cancelled with positive safe coefficients. It can vanish only on a boundary with an eigenvalue one, or by introducing negative coefficients that invalidate the original positive-vertex expansion. -## 4. Reduction and stoquastic checks +## 9. Reduction and stoquastic checks For one triangle, a diagonal Fock-sign gauge can make h=-M stoquastic in the N=1 sector only when alpha-beta>=0, and in N=2 only when d_2-gamma>0. The A and B -orbits violate opposite conditions at small tau. Their positive mixture has only a +orbits violate opposite conditions at small s. Their positive mixture has only a narrow possible gauge-compatible window, different from the ratio that removes J. Overlapping triangles introduce further global consistency conditions. @@ -121,11 +390,11 @@ use bipartite, half-filled, or particle-hole structures and do not directly cove this nonbipartite triangular support. This is not a proof that no alternative bag or non-diagonal stoquastic representation exists. -## 5. Finite-density no-go inside the contraction route +## 10. Finite-density no-go inside the contraction route For an isolated triangle, every one-particle orbit factor U_sigma obeys - ||U_sigma||_infinity<=q=exp(-kappa tau)<1. + ||U_sigma||_infinity≤q=exp(−κs)<1. The induced exterior norm therefore gives @@ -139,12 +408,31 @@ Hermitian, this proves I-M_X>=0 as an operator on Fock space. For positive couplings, - H_0-E_vac = sum_Delta,X g_X [I-M_(X,Delta)] >= 0. + H_bar=sum_(Delta,X) g_(Delta,X)[I-M_(Delta,X)]≥0, + H_bar|vac>=0. + +If every orbital belongs to at least one active triple, the common zero eigenspace +is only the global vacuum. A Hermitian one-body background dGamma(K) that remains +safe under the same contraction certificate has K≥0 and only reinforces the +vacuum. A positive chemical potential −μN instead contributes z=exp(βμ)>1 to the +word and leaves this proof. + +For a fixed real word T, the exact all-fugacity criterion is + + det(I+zT)≥0 for every z>0 + +if and only if every distinct negative real eigenvalue of T has even algebraic +multiplicity. Complex-conjugate pairs contribute |1+zλ|², positive real +eigenvalues never vanish for z>0, and a negative eigenvalue gives the positive +root z=−1/λ; the polynomial changes sign there exactly when that root has odd +multiplicity. Strict positivity for all z>0 requires no negative real eigenvalue. -Any deterministic one-body background dGamma(K) that remains safe under the same -contraction certificate has K>=0 and only reinforces the vacuum. A positive physical -chemical potential -mu N has one-particle propagation exp(+Delta tau mu), leaves the -contraction semigroup, and destroys this proof. +For a real 3-by-3 word with detT>0, two distinct negative eigenvalues therefore +produce a negative interval between their two positive roots. They are harmless for +all z only if they are exactly degenerate, in which case the weight can vanish. The +current contraction theorem proves positivity at z=1 (and 0≤z≤1), but proves +neither negative-spectrum avoidance nor this degeneracy for every word. Positive-μ +sign freedom is consequently an open extension, not a result of the present model. Grand-canonical positivity also does not imply positivity at fixed filling because @@ -153,9 +441,10 @@ Grand-canonical positivity also does not imply positivity at fixed filling becau may be positive at z=1 while individual coefficients are negative. For example, X=[[-1,-1],[1,-1]] at t=pi gives T=-exp(-pi)I: det(I+T)>0 but tr T<0. -Therefore the S3 contraction family defines an engineered Hermitian interacting model -with an exact sign-free grand-canonical determinant-valued series expansion and a -rigorous vacuum ground state. It is not a standard auxiliary-field DQMC formulation -or a solved finite-density algorithm. Canonical finite density requires a new -exterior-power cone or another pairing mechanism. This no-go motivates the separate -Perron-compound construction. +Therefore the S3 contraction family defines an engineered Hermitian interacting +model with an exact, implementable, sign-free CT Gaussian-vertex sampler and a +rigorous vacuum ground state. It is not a standard Hubbard-Stratonovich DQMC +formulation and does not solve finite-density ground-state sampling. Canonical +finite density requires a separate coefficient-wise compound-trace certificate; +positive grand-canonical μ requires the all-fugacity criterion above. These are +extensions beyond the acceptance condition of issue #121. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/reduction_checklist.md b/tracks/qmc/solutions/Genshin_Impact-121/reduction_checklist.md index 89a96fbbb..f2b1c1e1f 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/reduction_checklist.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/reduction_checklist.md @@ -96,9 +96,9 @@ i(J_2 V - conjugate(V) J_2) <= 0. The equality case is a known symmetry class; symmetric `J_1` contains Majorana reflection positivity; skew `J_1` contains the Kramers contraction class. Passing only the canonical choice is insufficient: alternative common `J_1,J_2` choices -must be excluded before claiming novelty. A proof restricted to real orthogonal -Majorana frames must also say explicitly that genuinely complex orthogonal canonical -similarities remain unchecked. +and one fixed complex canonical frame must be considered before claiming novelty. +The current A/B proof treats one common frame in the same CAR dimension; it does +not treat stabilization by ancillary modes or a different Gaussian support. ## 5a. Non-Euclidean norm-contraction reduction (current internal candidate) @@ -117,6 +117,27 @@ established QMC literature class. It contains the substochastic Markov wedge bu also genuinely signed matrices. Future candidates contained in it are not independent discoveries. +## 5b. Fixed definite metric and positive-cone reductions + +For a Hurwitz support, also search after arbitrary fixed complex similarities for +an ordinary positive-definite Hermitian contraction or expansion metric. Pulling +such a metric back and using the continuous Lyapunov integral produces a common +real positive-definite quadratic metric. Therefore the exact no-common-H +certificate in main_theorem.md excludes this whole fixed-similarity route, not +only the Euclidean basis. + +Separately test whether one fixed similarity makes all generators Metzler or makes +their exponentials preserve a common simplicial or nonsimplicial proper cone. The +signed opposite edge in A/B excludes only diagonal sign gauges to Metzler form; +the present proof does not exclude every general positive-cone similarity. Cone +preservation by itself is not a known determinant-positivity proof, so a hit here +would require an additional reduction before it counts as prior sign-free work. + +Always record the representation scope. The current certificate is for one fixed +same-dimensional support. Ancilla stabilization, generator-dependent gauges, +different Hubbard-Stratonovich or fermion-bag supports, and Hamiltonian-level +stoquastic changes of basis remain separate questions. + ## 6. One-dimensional and trivial-sector reductions Check whether a fermionic ordering or Jordan-Wigner transformation removes the sign, diff --git a/tracks/qmc/solutions/Genshin_Impact-121/requirements.txt b/tracks/qmc/solutions/Genshin_Impact-121/requirements.txt index 77909df50..905fd5db6 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/requirements.txt +++ b/tracks/qmc/solutions/Genshin_Impact-121/requirements.txt @@ -1,3 +1,4 @@ numpy scipy +mpmath pytest diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_issue121_verification.py b/tracks/qmc/solutions/Genshin_Impact-121/test_issue121_verification.py new file mode 100644 index 000000000..3582693ee --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_issue121_verification.py @@ -0,0 +1,494 @@ +from __future__ import annotations + +from collections import Counter +from copy import deepcopy +import math +from pathlib import Path + +import numpy as np +import pytest +from scipy.linalg import expm + +import issue121_verification as verify + + +MANIFEST_PATH = Path(__file__).with_name("issue121_full_run.json") + + +@pytest.fixture +def manifest() -> dict: + return verify.load_manifest(MANIFEST_PATH) + + +def test_manifest_and_exact_workload(manifest: dict) -> None: + assert manifest["schema_version"] == 1 + assert manifest["seed"] == 1212026 + candidate = manifest["candidate"] + assert candidate["dimensions"] == [3, 4, 6, 8, 12] + assert candidate["depths"] == [1, 2, 4, 8, 16, 32, 64] + assert candidate["samples_per_cell"] == 256 + assert candidate["time_distribution"] == { + "kind": "log_uniform", "minimum": "1e-3", "maximum": "5" + } + regimes = {item["id"]: item for item in candidate["regimes"]} + assert list(regimes) == [ + "center", "near_boundary", "kappa_to_zero", "dirichlet_open_triangle" + ] + assert (regimes["center"]["epsilon"], regimes["center"]["kappa"]) == ( + "1/100", "1/1000" + ) + boundary = regimes["near_boundary"] + assert ( + 40 * verify.parse_fraction(boundary["epsilon"]) + + 59 * verify.parse_fraction(boundary["kappa"]) + ) == verify.parse_fraction("1999/1000") + assert regimes["kappa_to_zero"]["kappa"] == "1/1000000" + assert regimes["dirichlet_open_triangle"]["kind"] == "dirichlet_open_triangle" + assert regimes["dirichlet_open_triangle"]["alpha"] == [1.0, 1.0, 1.0] + + split = manifest["positive_anchors"]["split_orthogonal"] + semigroup = manifest["positive_anchors"]["semigroup_cone"] + controls = manifest["component_controls"] + assert split["n_values"] == semigroup["n_values"] == [1, 2, 3, 4] + assert set(controls["components"]) == {"++", "--", "-+", "+-"} + assert controls["n_values"] == [1] + + candidate_cells = len(candidate["dimensions"]) * len(candidate["depths"]) * 4 + split_cells = len(split["n_values"]) * len(split["depths"]) + semigroup_cells = len(semigroup["n_values"]) * len(semigroup["depths"]) + component_cells = 4 * len(controls["n_values"]) * len(controls["depths"]) + expected = manifest["expected_workload"] + assert (candidate_cells, split_cells, semigroup_cells, component_cells) == ( + expected["candidate_cells"], expected["split_cells"], + expected["semigroup_cells"], expected["component_cells"] + ) == (140, 28, 28, 28) + assert expected["candidate_words"] == candidate_cells * 256 == 35840 + assert expected["split_words"] == split_cells * 64 == 1792 + assert expected["semigroup_words"] == semigroup_cells * 64 == 1792 + assert expected["component_words"] == component_cells * 32 == 896 + assert expected["total_words"] == 40320 + assert expected["physical_poisson_words"] == 4 * 4096 == 16384 + assert expected["total_random_words_including_physical"] == 56704 + + cells = verify.build_cells(manifest) + assert len(cells) == expected["total_cells"] == 224 + assert Counter(cell.kind for cell in cells) == { + "candidate": 140, "split_orthogonal": 28, + "semigroup_cone": 28, "component_control": 28, + } + assert manifest["fock_oracle"]["maximum_dimension"] == 8 + assert manifest["fock_oracle"]["sample_indices"] == [0, 127, 255] + assert expected["fock_oracle_checks"] == 4 * 7 * 4 * 3 == 336 + assert manifest["determinant_precision"]["mpmath_dps"] == 100 + assert manifest["determinant_precision"]["high_precision_zero_tolerance"] == "1e-60" + execution = manifest["execution"] + assert execution["cpus_per_task"] == 1 + assert execution["memory_mb"] <= 2048 + assert execution["time_limit_minutes"] <= 20 + assert execution["gpus"] == 0 + + +@pytest.mark.parametrize( + "workload_key", + [ + "candidate_cells", + "split_cells", + "semigroup_cells", + "component_cells", + "total_cells", + "fock_oracle_checks", + ], +) +def test_validate_manifest_rejects_incorrect_structural_workload( + manifest: dict, workload_key: str +) -> None: + broken = deepcopy(manifest) + broken["expected_workload"][workload_key] += 1 + with pytest.raises(ValueError, match=rf"expected_workload\.{workload_key}="): + verify.validate_manifest(broken) + + +def test_exact_fraction_certificates_and_components(manifest: dict) -> None: + result = verify.exact_certificates(manifest) + assert result["status"] == "pass" + assert all(result["checks"].values()) + cert = result["certificates"] + assert cert["mu_infinity"] == "-1/1000" + assert cert["opposite_edge_product_A13_A31"] == "-1/50" + assert cert["support_span_rank"] == 9 + assert verify.parse_fraction(cert["no_common_H_upper_bound"]) < 0 + assert verify.parse_fraction(cert["no_common_H_lower_bound"]) > 0 + assert cert["standard_polynomial_minimum"] == "37/27" + assert cert["o11_component_det_I_plus"] == { + "++": "16/3", "--": "-4/3", "-+": "0", "+-": "0" + } + assert verify.exact_component_weights() == cert["o11_component_det_I_plus"] + + +def test_ab_orbit_infinity_norm_certificate(manifest: dict) -> None: + fixed = [r for r in manifest["candidate"]["regimes"] if r["kind"] == "fixed"] + for regime in fixed: + epsilon = float(verify.parse_fraction(regime["epsilon"])) + kappa = float(verify.parse_fraction(regime["kappa"])) + for _, _, generator in verify.ab_orbit(epsilon, kappa): + assert verify.mu_infinity(generator) == pytest.approx(-kappa, abs=2e-15) + for propagation_time in (1e-3, 0.1, 5.0): + norm = np.linalg.norm(expm(propagation_time * generator), ord=np.inf) + assert norm <= math.exp(-kappa * propagation_time) + 5e-12 + + +def test_candidate_factor_order_equals_fock_trace(manifest: dict) -> None: + cell = verify.Cell( + "candidate__center__d04__m004", "candidate", + {"regime": "center", "dimension": 4, "depth": 4}, + ) + rng = np.random.default_rng(verify.derive_seed(manifest["seed"], cell.cell_id)) + product, factor_specs, descriptor, total_kappa_time = verify.sample_candidate_word( + manifest, cell, rng + ) + rebuilt = np.eye(4) + for factor in factor_specs: + rebuilt = expm(factor["matrix"]) @ rebuilt + assert len(factor_specs) == len(descriptor) == 4 + assert total_kappa_time > 0 + np.testing.assert_allclose(product, rebuilt, rtol=2e-13, atol=2e-13) + + determinant = float(np.linalg.det(np.eye(4) + product)) + fock_trace = verify.direct_fock_trace(factor_specs) + tolerance = ( + float(manifest["fock_oracle"]["absolute_tolerance"]) + + float(manifest["fock_oracle"]["relative_tolerance"]) * abs(determinant) + ) + assert determinant > 0 + assert abs(fock_trace.imag) <= tolerance + assert abs(fock_trace.real - determinant) <= tolerance + + +def test_semigroup_sampler_records_actual_q_ranks(manifest: dict) -> None: + config = deepcopy(manifest["positive_anchors"]["semigroup_cone"]) + config["time_distribution"] = { + "kind": "log_uniform", "minimum": "0.1", "maximum": "0.1" + } + product, factor_specs, descriptor, generator_minimum, full, deficient, rank_failures = ( + verify.sample_semigroup_word( + 2, 2, 0, np.random.default_rng(1212026), config + ) + ) + assert [item["q_kind"] for item in descriptor] == ["full", "rank_deficient"] + assert [item["q_rank"] for item in descriptor] == [4, 2] + assert (full, deficient) == (1, 1) + assert rank_failures == 0 + assert generator_minimum >= -5e-12 + eta = verify.sph.split_metric(2) + product_lmi = product.T @ eta @ product - eta + product_lmi = 0.5 * (product_lmi + product_lmi.T) + assert np.linalg.eigvalsh(product_lmi)[0] >= -5e-10 + determinant = verify.stable_determinant_i_plus( + product, factor_specs, manifest["determinant_precision"] + ) + assert determinant["classification"] == "positive" + + +def test_shifted_hbar_exact_deterministic_and_poisson_conventions(manifest: dict) -> None: + config = manifest["physical_benchmark"] + assert config["sites"] == 4 and config["boundary"] == "open" + assert config["triangles"] == [[0, 1, 2], [1, 2, 3]] + assert config["couplings"] == {"A": "1/4", "B": "1/4"} + assert config["chemical_potential"] == "0" + assert config["betas"] == ["1/4", "1/2", "1", "2"] + + catalog, interaction, _ = verify.physical_vertex_catalog(config) + assert len(catalog) == 24 + total_activity = sum(float(vertex["weight"]) for vertex in catalog) + assert total_activity == pytest.approx(1.0, abs=1e-15) + hbar = total_activity * np.eye(interaction.shape[0]) - interaction + assert hbar.shape == (16, 16) + assert np.linalg.norm(hbar - hbar.T.conj(), ord="fro") <= 1e-10 + assert abs(hbar[0, 0]) <= 1e-12 + + beta = 0.25 + exact_shifted = float(np.trace(expm(-beta * hbar)).real) + exact_unshifted = float(np.trace(expm(beta * interaction)).real) + assert exact_shifted == pytest.approx( + math.exp(-beta * total_activity) * exact_unshifted, + rel=2e-13, abs=2e-13, + ) + deterministic = verify.deterministic_partition_expansion( + interaction, beta, config["deterministic_truncation_order"], total_activity + ) + shifted_series = deterministic["z_bar_estimate_real"] + shifted_bound = ( + deterministic["remainder_bound"] + float(config["deterministic_roundoff_allowance"]) + ) + assert abs(shifted_series - exact_shifted) <= shifted_bound + + poisson = verify.poisson_partition_estimate( + catalog, beta, 1024, + np.random.default_rng(verify.derive_seed(config["seed"], "pytest_hbar")), + manifest["determinant_precision"], + ) + assert poisson["negative_or_unresolved_configurations"] == 0 + assert poisson["minimum_fock_configuration_weight"] >= -1e-10 + assert poisson["maximum_fock_determinant_abs_error"] <= 1e-7 + shifted_estimate = poisson["z_bar_estimate"] + shifted_se = poisson["standard_error"] + assert abs(shifted_estimate - exact_shifted) <= max( + 12.0 * shifted_se, 0.03 * exact_shifted + ) + + +def _fixture_row(cell: verify.Cell, sample: int) -> dict[str, object]: + row = {field: "" for field in verify.CSV_FIELDS} + row.update({ + "cell_id": cell.cell_id, + "kind": cell.kind, + "sample": sample, + "dimension": cell.parameters.get("dimension", ""), + "n": cell.parameters.get("n", ""), + "depth": cell.parameters.get("depth", ""), + "regime": cell.parameters.get("regime", ""), + "component": cell.parameters.get("component", ""), + "det_class": "positive", + "det_method": "fixture", + "det_sign": 1, + "log_abs_det": "0", + "determinant_decimal": "1", + "sigma_min_i_plus_t": "1", + "structural_diagnostic": "0", + "fock_checked": 0, + "word_sha256": f"fixture-{sample}", + }) + return row + + +def test_resume_binds_protocol_and_rows_hash(tmp_path: Path) -> None: + cell = verify.Cell( + "candidate__center__d03__m001", "candidate", + {"regime": "center", "dimension": 3, "depth": 1}, + ) + rows_path = tmp_path / "rows.csv" + summary_path = tmp_path / "summary.json" + rows = [_fixture_row(cell, sample) for sample in range(3)] + verify.atomic_write_csv(rows_path, rows) + summary = { + "cell_id": cell.cell_id, + "protocol_id": "protocol-a", + "sample_count": 3, + "row_count": 3, + "rows_sha256": verify.sha256_file(rows_path), + } + verify.atomic_write_json(summary_path, summary) + assert verify.load_reusable_cell( + summary_path, rows_path, cell=cell, expected_samples=3, + protocol_id="protocol-a", + ) == summary + assert verify.load_reusable_cell( + summary_path, rows_path, cell=cell, expected_samples=3, + protocol_id="protocol-b", + ) is None + rows[0]["word_sha256"] = "tampered" + verify.atomic_write_csv(rows_path, rows) + assert verify.load_reusable_cell( + summary_path, rows_path, cell=cell, expected_samples=3, + protocol_id="protocol-a", + ) is None + + +def test_protocol_id_depends_on_all_code_and_manifest_hashes(manifest: dict) -> None: + manifest_hash = verify.sha256_bytes(verify.canonical_json(manifest).encode("utf-8")) + verifier_hash = verify.sha256_file(Path(verify.__file__)) + support_hash = verify.sha256_file(Path(verify.sph.__file__).resolve()) + environment_signature = { + "python_major": int(verify.sys.version_info.major), + "python_full": verify.sys.version, + "numpy": verify.np.__version__, + "scipy": verify.scipy.__version__, + "mpmath": verify.mp.__version__, + } + + def protocol_id( + manifest_digest: str, verifier_digest: str, + support_digest: str, environment: dict, + ) -> str: + return verify.sha256_bytes(verify.canonical_json({ + "manifest_sha256": manifest_digest, + "verifier_sha256": verifier_digest, + "sign_problem_hunter_sha256": support_digest, + "environment_signature": environment, + }).encode("utf-8")) + + protocol = protocol_id( + manifest_hash, verifier_hash, support_hash, environment_signature + ) + changed = deepcopy(manifest) + changed["seed"] += 1 + changed_hash = verify.sha256_bytes(verify.canonical_json(changed).encode("utf-8")) + changed_environment = dict(environment_signature) + changed_environment["numpy"] = "changed" + assert len(protocol) == 64 + assert protocol != protocol_id(changed_hash, verifier_hash, support_hash, environment_signature) + assert protocol != protocol_id(manifest_hash, "0" * 64, support_hash, environment_signature) + assert protocol != protocol_id(manifest_hash, verifier_hash, "0" * 64, environment_signature) + assert protocol != protocol_id(manifest_hash, verifier_hash, support_hash, changed_environment) + + +def test_cli_cell_ids_are_stable_and_selectable( + manifest: dict, capsys: pytest.CaptureFixture[str] +) -> None: + assert verify.main(["--manifest", str(MANIFEST_PATH), "--list-cells"]) == 0 + listed = capsys.readouterr().out.splitlines() + expected = [cell.cell_id for cell in verify.build_cells(manifest)] + assert listed == expected + assert len(listed) == len(set(listed)) == 224 + assert listed[0] == "candidate__center__d03__m001" + assert "semigroup_cone__n04__m064" in listed + assert listed[-1] == "component__pm__n01__m064" + + chosen = [ + "candidate__center__d03__m001", + "semigroup_cone__n02__m004", + ] + args = verify.parse_args([ + "--manifest", str(MANIFEST_PATH), + "--cell-id", chosen[0], + "--cell-id", chosen[1], + ]) + assert args.cell_ids == chosen + + + +@pytest.mark.parametrize( + ("component", "expected_class"), + [("++", "positive"), ("--", "negative"), ("-+", "inconclusive"), ("+-", "inconclusive")], +) +def test_o11_numeric_component_controls_and_exact_zero( + manifest: dict, component: str, expected_class: str +) -> None: + local_manifest = deepcopy(manifest) + local_manifest["component_controls"]["samples_per_cell"] = 1 + label = component.replace("+", "p").replace("-", "m") + cell = verify.Cell( + f"component__{label}__n01__m001", + "component_control", + {"component": component, "n": 1, "dimension": 2, "depth": 1}, + ) + summary, rows = verify.run_component_cell( + local_manifest, + cell, + np.random.default_rng(verify.derive_seed(manifest["seed"], cell.cell_id)), + ) + assert summary["status"] == "pass" + assert summary["sample_count"] == 1 + assert summary["determinant_class_counts"] == {expected_class: 1} + expected_zero_count = int(component in {"-+", "+-"}) + raw_inconclusive_count = int(expected_class == "inconclusive") + assert summary["inconclusive_determinants"] == raw_inconclusive_count + assert summary["raw_inconclusive_determinants"] == raw_inconclusive_count + assert summary["expected_exact_zero_controls"] == expected_zero_count + assert summary["unexpected_inconclusive_determinants"] == 0 + + assert len(rows) == 1 + assert rows[0]["det_class"] == expected_class + if expected_class != "positive": + assert rows[0]["det_method"] == "mpmath_100dps" + if component in {"-+", "+-"}: + assert rows[0]["det_method"] == "mpmath_100dps" + assert float(rows[0]["sigma_min_i_plus_t"]) <= float( + manifest["thresholds"]["component_zero_sigma"] + ) + + +def test_expected_exact_zero_aggregate_and_markdown_are_distinct( + manifest: dict, +) -> None: + mixed_cells = [ + cell + for cell in verify.build_cells(manifest) + if cell.kind == "component_control" + and cell.parameters["component"] in {"-+", "+-"} + ] + assert len(mixed_cells) == 14 + summaries = { + cell.cell_id: { + "status": "pass", + "high_precision_escalations": 32, + "inconclusive_determinants": 32, + "raw_inconclusive_determinants": 32, + "expected_exact_zero_controls": 32, + "unexpected_inconclusive_determinants": 0, + } + for cell in mixed_cells + } + aggregates = verify.aggregate_cell_results(mixed_cells, summaries) + assert aggregates["inconclusive_determinants"] == 448 + assert aggregates["raw_inconclusive_determinants"] == 448 + assert aggregates["expected_exact_zero_controls"] == 448 + assert aggregates["unexpected_inconclusive_determinants"] == 0 + + markdown = verify.report_markdown( + { + "status": "pass", + "protocol_id": "fixture", + "completed_cells": len(mixed_cells), + "total_cells": len(mixed_cells), + "sample_rows": 448, + "stage_status": { + "exact_certificates": "pass", + "twirl_checks": "pass", + "physical_benchmark": "pass", + }, + "aggregates": aggregates, + "failed_cells": [], + "pending_cells": [], + } + ) + assert "Raw numeric inconclusive classifications: 448" in markdown + assert "Expected exact-zero mixed O(1,1) controls: 448" in markdown + assert "Unexpected inconclusive determinants: 0" in markdown + + +def test_twirl_stage_parses_fraction_tau_and_passes(manifest: dict) -> None: + result = verify.run_twirl_checks(manifest) + assert result["status"] == "pass" + assert result["parameters"]["tau"] == pytest.approx(0.1) + for family in ("A", "B"): + assert result["checks"][family] == {"hermitian": True, "non_gaussian": True} + + +def test_complete_fast_path_verifies_report_hashes( + manifest: dict, tmp_path: Path +) -> None: + manifest_hash = verify.sha256_bytes(verify.canonical_json(manifest).encode("utf-8")) + verifier_hash = verify.sha256_file(Path(verify.__file__)) + support_hash = verify.sha256_file(Path(verify.sph.__file__).resolve()) + environment_signature = { + "python_major": int(verify.sys.version_info.major), + "python_full": verify.sys.version, + "numpy": verify.np.__version__, + "scipy": verify.scipy.__version__, + "mpmath": verify.mp.__version__, + } + protocol_id = verify.sha256_bytes(verify.canonical_json({ + "manifest_sha256": manifest_hash, + "verifier_sha256": verifier_hash, + "sign_problem_hunter_sha256": support_hash, + "environment_signature": environment_signature, + }).encode("utf-8")) + + report_path = tmp_path / "report.json" + markdown_path = tmp_path / "report.md" + complete_path = tmp_path / "COMPLETE" + report = {"schema_version": 1, "status": "pass", "protocol_id": protocol_id} + verify.atomic_write_json(report_path, report) + verify.atomic_write_text(markdown_path, "# completed fixture\n") + verify.atomic_write_json(complete_path, { + "protocol_id": protocol_id, + "report_json_sha256": verify.sha256_file(report_path), + "report_markdown_sha256": verify.sha256_file(markdown_path), + "completed_at": "fixture", + }) + assert verify.run_verification(MANIFEST_PATH, tmp_path) == report + + verify.atomic_write_text(markdown_path, "# tampered fixture\n") + with pytest.raises(RuntimeError, match="COMPLETE"): + verify.run_verification(MANIFEST_PATH, tmp_path) From 1a11367ecbf0b4d2b847a06444b992b4242f4c24 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 03:17:02 +0800 Subject: [PATCH 05/13] qmc: complete issue 121 verification report --- .../solutions/Genshin_Impact-121/README.md | 191 +++-- .../external_review_draft.md | 58 +- .../formal_run_snapshot/COMPLETE | 1 + .../formal_run_snapshot/challenge_report.html | 84 ++ .../formal_run_snapshot/challenge_report.json | 238 ++++++ .../exact_certificates.json | 55 ++ .../formal_run_snapshot/manifest.json | 240 ++++++ .../physical_benchmark.json | 748 ++++++++++++++++++ .../formal_run_snapshot/report.json | 92 +++ .../formal_run_snapshot/report.md | 16 + .../formal_run_snapshot/run.json | 30 + .../formal_run_snapshot/slurm_jobs.json | 77 ++ .../formal_run_snapshot/twirl_checks.json | 48 ++ .../Genshin_Impact-121/main_theorem.md | 23 +- .../Genshin_Impact-121/novelty_audit.md | 12 +- .../physical_realization.md | 44 +- .../Genshin_Impact-121/verification_record.md | 91 +++ 17 files changed, 1906 insertions(+), 142 deletions(-) create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/COMPLETE create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.html create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/exact_certificates.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/manifest.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/physical_benchmark.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/run.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/slurm_jobs.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/twirl_checks.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/verification_record.md diff --git a/tracks/qmc/solutions/Genshin_Impact-121/README.md b/tracks/qmc/solutions/Genshin_Impact-121/README.md index aa5d4852d..121e02f57 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/README.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/README.md @@ -1,4 +1,4 @@ -# Polyhedral and Perron-compound sign-free generator supports +# Polyhedral sign-free generator supports beyond fixed metrics ## Team @@ -11,21 +11,22 @@ | Row | | |---|---| -| **Challenge** | Find structured fermionic Gaussian-vertex sets with det(I + product exp(A_i)) >= 0 beyond the known split-orthogonal and fixed-metric semigroup principles, and map any survivor to an interacting QMC weight. | -| **Catalog issue** | Addresses #121 - Sign-problem free hunter, released by Lei Wang, Institute of Physics, Chinese Academy of Sciences. | -| **Track** | `tracks/qmc/` — from the issue's `Method: Quantum Monte Carlo` field. | +| **Challenge** | Find structured Gaussian-vertex sets with det(I+T)>=0 for arbitrary words beyond split-orthogonal and fixed-metric sufficient principles, then realize one as an interacting QMC weight. | +| **Catalog issue** | [QuantumBFS/quantum.harness issue #121](https://github.com/QuantumBFS/quantum.harness/issues/121) | +| **Pull request** | [PR #261](https://github.com/QuantumBFS/quantum.harness/pull/261) | +| **Track** | `tracks/qmc/` | ## Bottom line -This submission reports **substantial progress toward #121, not a claimed closure of the whole research challenge**. +This submission supplies all six explicit deliverables of issue #121: independent determinant/Fock oracles and signed controls; a reduction and literature checklist; a new arbitrary-depth structured family with proof and preregistered stress tests; an interacting physical determinant weight; complete reporting; and a public expert-review draft. -The main analytic candidate is an open, two-orbit family of real 3 x 3 generators whose arbitrary positive-time words have positive determinant weights. The supplied support has an exact obstruction to every common quadratic contraction metric and a proof under internal review of nonembedding in one fixed complex-CAR Wei structure. An S3 Fock-space twirl maps the same twelve vertices to an engineered Hermitian interacting Hamiltonian with an exact determinant-valued continuous-time Gaussian-vertex series expansion; this is not a standard auxiliary-field DQMC formulation. +The result is an open two-orbit family of real 3 x 3 generators. A common polyhedral norm proves positivity at every depth. Exact certificates exclude every common quadratic contraction metric and the stated fixed, same-dimensional complex-CAR Wei classes. An S3 Fock-space twirl maps the same twelve vertices to a local Hermitian interacting Hamiltonian with an exact positive continuous-time Gaussian-vertex expansion. -Two major gaps remain. First, the final A/B family does not yet ship with its own randomized cross-dimension harness, so the survival claim currently rests on the analytic common-norm proof and internal proof audit. Second, the contraction Hamiltonian has a frustration-free vacuum ground state at chemical potential zero, while the finite-occupancy extension factorizes into number-conserving cells with no itinerant intercell hopping. We do not claim a scalable finite-density phase, a production sampler, publication priority, or Hamiltonian-level exclusion of every alternative Hubbard-Stratonovich, fermion-bag, Majorana, Jordan-Wigner, or stoquastic representation. +The formal run at executable commit [`9fe85a6`](https://github.com/QuantumBFS/quantum.harness/commit/9fe85a6317132983b48c12cbe3628b2da2945a19) passed 224/224 preregistered cells and every exact, twirl, and physical stage. This meets the literal issue submission standard. It does not imply maintainer acceptance, publication priority, exclusion of every alternative representation, a finite-density breakthrough, or publication readiness. -## 1. Main theorem candidate +## 1. Main theorem -For epsilon > 0 and kappa > 0, define +For epsilon>0 and kappa>0, define ```text A(epsilon,kappa) = @@ -33,119 +34,147 @@ A(epsilon,kappa) = [ 0 -1-kappa 1 ] [ 2 0 -2-kappa ] -S = diag(1,1,-1), B = S A S, -C = S3 orbit of A union S3 orbit of B. +S=diag(1,1,-1), B=SAS, +C=S3 orbit of A union S3 orbit of B. ``` -On the open parameter region +On the open region ```text -epsilon > 0, kappa > 0, 40 epsilon + 59 kappa < 2, +epsilon>0, kappa>0, 40 epsilon+59 kappa<2, ``` -the accompanying proof draft establishes: +[`main_theorem.md`](main_theorem.md) proves: -1. Every X in C has logarithmic infinity norm mu_infinity(X) = -kappa. Thus every positive-time word T obeys ||T||_infinity < 1 on the isolated three-mode space and det(I+T) > 0. Embedded local words obey det(I+T) >= 0. -2. No common H > 0 can satisfy X^T H + H X <= 0 for all X in C. At epsilon=1/100 and kappa=1/1000, permutation averaging reduces H to I+r ee^T, while A requires r <= -1541/24791 and B requires r >= 1541/42609. -3. The twelve generators span all of M_3(R); the standard-isotypic minor is 162(2 epsilon^3 + epsilon^2 - 4 epsilon + 3), which is positive in the stated region. -4. For odd one-particle dimension and full span, the number-conserving Nambu support cannot be put into Wei's fixed complex-CAR semigroups without inducing the forbidden common H. A compactness argument also excludes alternate logarithms of this same discrete support for sufficiently small time step. -5. The result is not tied to one decimal matrix. `main_theorem.md` gives a seven-parameter signed directed-triangle design cone with a nonempty open feasible region. +1. Every X in C has logarithmic infinity norm mu_infinity(X)=-kappa. Every positive-time word is a strict contraction on the isolated three-mode space, so det(I+T)>0; locally embedded words obey det(I+T)>=0 at arbitrary depth. +2. No common H>0 satisfies X^T H+HX<=0 for all X in C. At epsilon=1/100 and kappa=1/1000, A requires r<=-1541/24791 and B requires r>=1541/42609 after permutation averaging. +3. The twelve generators span M_3(R). +4. The number-conserving Nambu support cannot enter the compared fixed, same-dimensional complex-CAR Wei semigroups under one fixed allowed basis change. The statement includes sufficiently small alternate logarithms of the same discrete support. +5. Section 6 gives a seven-parameter signed directed-triangle design cone, so the displayed rational matrix is not an isolated fitted point. -The determinant proof itself is short: a common induced norm puts every eigenvalue of the real product T in the closed unit disk. Real eigenvalues contribute nonnegative factors 1+lambda, and nonreal conjugate pairs contribute |1+lambda|^2. +The determinant step is short: eigenvalues of a real contraction lie in the closed unit disk; real eigenvalues contribute 1+lambda>=0 and nonreal conjugate pairs contribute |1+lambda|^2. ## 2. Interacting physical realization -For X=A or B, define the three-site Fock-space twirl +For X=A or B, define ```text -M_X(tau) = (1/6) sum over sigma in S3 of - exp[tau c^dagger (P_sigma X P_sigma^T) c]. +M_X(s)=(1/6) sum_(sigma in S3) + exp[s c^dagger(P_sigma X P_sigma^T)c]. ``` -The exterior-power representations of the natural S3 representation are real and multiplicity-free in every three-mode number sector, so M_X is Hermitian. At the rational interior point and sufficiently small positive tau, both twirls are non-Gaussian and interacting. Their exact local operator content is +The complete twirl is Hermitian although a resolved Gaussian vertex need not be. At the rational interior point and sufficiently small s>0, both twirls are interacting and non-Gaussian. Positive couplings on overlapping triples define ```text -constant + chemical potential + uniform hopping + density interaction -+ correlated hopping + three-body density. +H_bar=sum_(Delta,X) g_(Delta,X)[I-M_(Delta,X)]. ``` -For positive couplings, overlapping triangular clusters give +Resolving the continuous-time expansion of exp(-beta H_bar) gives nonnegative scalar activities and configuration weight det(I+U_m...U_1)>=0 at every order. The formal four-site benchmark used overlapping triples (1,2,3) and (2,3,4), s=1/10, g_A=g_B=1/4, mu=0, and beta=1/4,1/2,1,2. -```text -H = - sum over triangles Delta of [g_A M_A,Delta + g_B M_B,Delta]. -``` - -Expanding exp(-beta H) and resolving every twirl insertion into one of the twelve Gaussian orbit vertices gives nonnegative scalar activities and fermion factor det(I + product exp(τ X_j)) >= 0 at arbitrary depth. A sampled orbit vertex need not be Hermitian or a positive operator; Hermiticity belongs to the complete twirl. +All 16,384 sampled physical configurations were nonnegative. Exact diagonalization and the positive Poisson estimator agreed within every preregistered allowance; the minimum sampled determinant was 4.330910819303328. See [`physical_realization.md`](physical_realization.md) and [`verification_record.md`](verification_record.md). -This meets the issue's minimum “route to a physical determinant weight” requirement in the broad sense of an exact grand-canonical Gaussian-vertex series. It is not a standard auxiliary-field DQMC decomposition of a two-body model. At chemical potential zero the vacuum minimizes every positive-coupling contraction term; positive chemical potential leaves the certified cone, and canonical weights are not automatically positive. - -`finite_density_extension.md` develops a Perron-plus-second-compound criterion that permits one expanding positive mode. Its decoupled D4 cell Hamiltonian has a unique one-particle local ground state at mu=0, and the full cell-factorized fermionic expansion has positive grand-canonical determinant weights. The conserved one-particle-per-cell sector carries qutrit compass terms, but projected qutrit weights, an active low-energy qutrit manifold, and itinerant intercell fermion exchange are not proved sign-free. +This is a local, spinless, number-conserving, genuinely interacting model and an implementable continuous-time expansion. It is not a standard two-body Hubbard auxiliary-field decomposition. Its mu=0 ground state is the vacuum; positive chemical potential and canonical finite-density positivity remain open. ## 3. Novelty boundary -Established ingredients include logarithmic norms, common polyhedral Lyapunov functions, cone-preserving matrices, compound matrices, and group twirling. The candidate contribution is their QMC combination: +Established ingredients include logarithmic norms, polyhedral Lyapunov functions, contraction semigroups, compound matrices, cone preservation, and group twirling. The candidate contribution is their QMC combination: -- an explicit nonzero-volume arbitrary-depth determinant-positive vertex family; +- an explicit nonzero-volume arbitrary-depth determinant-positive family; - exact separation from every common ellipsoidal contraction certificate; -- a full-span odd-dimensional obstruction for the same support against Wei's fixed complex-CAR classes; -- an interacting Hermitian realization using the original safe vertices; -- a separate Perron-compound route and an exact map of its finite-density limitations. - -A targeted primary-source audit found no direct QMC use of this common-polyhedral construction or the Perron-plus-compound combination. That search is not proof of priority. The real-determinant pseudo-unitary observation in Appendix A of Phys. Rev. X 9, 021022 (2019), the total-positivity route independently submitted in PR #259, and all standard split-orthogonal/Kramers/Majorana/Wei reductions are treated as prior or competing work rather than claimed here. +- a full-span odd-dimensional obstruction for the same support against the stated fixed complex-CAR classes; +- an interacting Hermitian realization using only certified vertices. -The one-dimensional total-nonnegative/Jordan-Wigner route was deliberately excluded from this submission because PR #259 already contains it. See `novelty_audit.md` and `reduction_checklist.md` for the detailed filter. +A targeted primary-source audit found no direct QMC use of this common-polyhedral construction. Absence of a search hit is not proof of priority. PR #259's total-nonnegative/Jordan-Wigner route and split-orthogonal, Kramers, Majorana, pseudo-unitary, and Wei results are treated as prior or competing mechanisms. See [`novelty_audit.md`](novelty_audit.md) and [`reduction_checklist.md`](reduction_checklist.md). -## 4. Reproducibility and evidence +## 4. Formal verification result -The committed baseline oracle independently constructs the Fock-space lift of c_i^dagger c_j and checks +The compact immutable record is [`verification_record.md`](verification_record.md). Full row-level artifacts remain on `t02-server` at ```text -Tr_Fock product exp(c^dagger A_i c) = det(I + product exp(A_i)). +tracks/qmc/results/Genshin_Impact-121/20260730-021845-9fe85a6/ ``` -It includes analytic O(1,1), randomized O(n,n) identity-component positive controls, all four O(1,1) components, the exact rational negative certificate det(I+T)=-4/3 in O^{--}, and the four-site Wang et al. 2015 Hubbard/spin-flip construction. +That directory also contains the standalone challenge report at +`challenge-report/report.html` and scheduler provenance at `slurm_jobs.json`. +A compact public copy of the formal evidence, excluding the 9.6 MB row-level +sample table and per-cell files, is tracked in +[`formal_run_snapshot/`](formal_run_snapshot/). + +| Check | Result | +|---|---| +| Protocol | `ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20` | +| Cells / core random words | 224/224 pass; 40,320 | +| Candidate A/B words | 35,840/35,840 positive | +| Direct Fock checks | 336; maximum absolute error 5.400124791776761e-13 | +| High-precision rebuilds | 672 | +| Exact-zero controls | 448 expected; 0 unexpected inconclusive | +| Physical Poisson words | 16,384/16,384 nonnegative | +| Total randomized words | 56,704 | +| Exact certificates / twirl / physical benchmark | pass | +| Regression suite | 39 tests pass | -The code was developed with Python 3.13.9. From the repository root, install the minimal dependencies and run the regression tests with +Sampling audits implementation and boundary behavior; it is not the proof. The exact common-norm theorem proves arbitrary-depth positivity, and exact rational certificates audit the separation claims. -```bash -python -m pip install -r tracks/qmc/solutions/Genshin_Impact-121/requirements.txt -python -m pytest -q tracks/qmc/solutions/Genshin_Impact-121/test_sign_problem_hunter.py -``` +## 5. Reproduce -These team-local tests are not discovered by the repository's default `make test` target. To reproduce the complete preregistered Wang-2015 baseline of 256 configurations at orders 0 through 8, including three independent 256-dimensional Fock checks, use the committed manifest: +From the repository root: ```bash -run_dir="$(mktemp -d)" -cp tracks/qmc/solutions/Genshin_Impact-121/wang2015_run_template.json "$run_dir/run.json" -python tracks/qmc/solutions/Genshin_Impact-121/sign_problem_hunter.py --run-dir "$run_dir" +python -m pip install -r tracks/qmc/solutions/Genshin_Impact-121/requirements.txt +python -m pytest -q \ + tracks/qmc/solutions/Genshin_Impact-121/test_sign_problem_hunter.py \ + tracks/qmc/solutions/Genshin_Impact-121/test_issue121_verification.py + +python tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py \ + --manifest tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json \ + --validate-only + +output=tracks/qmc/results/Genshin_Impact-121/REPRODUCE-$(date -u +%Y%m%d-%H%M%S) +python tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py \ + --manifest tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json \ + --output "$output" +sha256sum "$output"/{manifest.json,report.json,report.md,samples.csv,COMPLETE} ``` -Final A/B-specific randomized validation is not yet included; the earlier A/D/F development harness was excluded as superseded. The arbitrary-word A/B statement currently rests on the analytic common-norm proof and the internal proof audit. No new scientific calculation was run merely to prepare this PR. +The runner writes cells atomically, binds resume state to the protocol and environment, and emits COMPLETE only after every stage passes. On `t02-server`, submit the full command as a 1-CPU, 2-GB, no-GPU Slurm job. -## 5. File map +## 6. File map | File | Role | |---|---| -| [`main_theorem.md`](main_theorem.md) | Open A/B family, exact no-ellipsoid and full-span certificates, fixed-CAR Wei obstruction, and seven-parameter cone. | -| [`physical_realization.md`](physical_realization.md) | Exact S3-twirl operator classification, correlated-hopping tuning, and three-body/vacuum no-go results. | -| [`finite_density_extension.md`](finite_density_extension.md) | Perron-compound theorem, D4 finite-occupancy construction, and explicit non-itinerant limitation. | -| [`novelty_audit.md`](novelty_audit.md) | Closest primary literature and cautious priority language. | -| [`reduction_checklist.md`](reduction_checklist.md) | Split-orthogonal, Kramers, Majorana, Wei, stoquastic, and physical-realizability novelty filter. | -| [`sign_problem_hunter.py`](sign_problem_hunter.py) | Reproducible split-orthogonal/Wang-2015 determinant and independent Fock oracle. | -| [`test_sign_problem_hunter.py`](test_sign_problem_hunter.py) | Exact and numerical baseline regression tests. | -| [`wang2015_run_template.json`](wang2015_run_template.json) | Path-free manifest for the full 256-configuration baseline. | - -## 6. Honest completion audit against issue #121 - -| Issue requirement | Status | -|---|---| -| Rebuild determinant/Fock oracle with positive and exact negative controls | Substantially complete. | -| Validate the known fixed-metric semigroup cone independently | Incomplete in the committed baseline. | -| Map known literature and run a novelty filter | Substantial targeted internal audit; historical priority remains unproved. | -| New structured support with arbitrary-depth proof | Analytic theorem candidate after internal audit; dedicated A/B randomized harness still missing. | -| Interacting physical determinant weight | Exact for an engineered grand-canonical Gaussian-vertex series; not a standard auxiliary-field DQMC formulation and vacuum-limited. | -| Nontrivial scalable finite-density itinerant model and benchmark | Incomplete. | -| Exclude every alternative positive decomposition of the same Hamiltonian | Incomplete and not claimed. | -| Public MathOverflow/arXiv endgame and external review | Not yet done. | - -For these reasons this is a non-closing PR that addresses #121. The core matrix question has a serious candidate answer; the strongest physical interpretation of the challenge has not yet been solved. +| [`main_theorem.md`](main_theorem.md) | Open A/B theorem, exact separation, fixed-CAR boundary, and seven-parameter cone. | +| [`physical_realization.md`](physical_realization.md) | S3-twirl Hamiltonian, positive CT expansion, sampler, and benchmark. | +| [`verification_record.md`](verification_record.md) | Formal-run hashes, counts, environment, results, and claim boundary. | +| [`formal_run_snapshot/`](formal_run_snapshot/) | Tracked compact copy of the materialized manifest, formal reports, exact/twirl/physical evidence, Slurm metadata, COMPLETE, and challenge report; the source manifest remains `issue121_full_run.json` and row-level samples remain remote by hash. | +| [`issue121_full_run.json`](issue121_full_run.json) | Preregistered manifest. | +| [`issue121_verification.py`](issue121_verification.py) | Protocol-bound exact, randomized, Fock, twirl, and physical verifier. | +| [`test_issue121_verification.py`](test_issue121_verification.py) | Formal verifier tests. | +| [`sign_problem_hunter.py`](sign_problem_hunter.py) | Independent split-orthogonal/Wang-2015 determinant and Fock oracle. | +| [`test_sign_problem_hunter.py`](test_sign_problem_hunter.py) | Baseline oracle tests. | +| [`novelty_audit.md`](novelty_audit.md) | Primary-source novelty audit and priority boundary. | +| [`reduction_checklist.md`](reduction_checklist.md) | Known-mechanism and physical-realizability filter. | +| [`external_review_draft.md`](external_review_draft.md) | Expert-review draft with permanent source links. | +| [`finite_density_extension.md`](finite_density_extension.md) | Optional Perron-compound extension and non-itinerant limitation. | +| [`wang2015_run_template.json`](wang2015_run_template.json) | Earlier Wang-2015 baseline manifest. | + +## 7. Issue #121 completion audit + +| Explicit issue gate | Status | Evidence | +|---|---|---| +| 1. Oracle plus known positive/negative anchors | Completed | Independent determinant/Fock identity; O(n,n), four O(1,1) components, exact -4/3 negative anchor, and 336 Fock checks. | +| 2. State-of-art and reduction checklist | Completed | Targeted primary-source audit and split-orthogonal, Kramers, Majorana, Wei, one-dimensional, stoquastic, and physical filters. | +| 3. New arbitrary-depth structure, tests, and proof | Completed | Open A/B theorem; exact proof; 35,840 candidate words over d=3,4,6,8,12 and depths 1-64; exact separation certificates. | +| 4. Interacting physical determinant weight | Completed | Local overlapping-triple H_bar, positive CT expansion, ED/Poisson benchmark, and 16,384 nonnegative physical configurations. | +| 5. Full reporting and reproducibility | Completed | Protocol-bound manifest, hashes, atomic resume, COMPLETE, tracked verification record, and 39 tests. | +| 6. Public endgame draft | Completed as a draft | [`external_review_draft.md`](external_review_draft.md) is ready for expert circulation; it has not been posted to MathOverflow or arXiv. | + +These rows mean PR #261 supplies every artifact explicitly requested by issue #121. They do not prejudge maintainer review. Finite-density physics is special credit rather than a hard gate and remains open; priority and independent specialist proof review also remain open. + +## 8. Suggested reading order + +1. [`main_theorem.md`](main_theorem.md), Sections 1-3: common polyhedral positivity and the no-ellipsoid certificate. +2. `main_theorem.md`, Section 5: the precise fixed-CAR Wei separation and its limits. +3. [`physical_realization.md`](physical_realization.md), Sections 1-4: Fock twirl, CT expansion, sampler, and benchmark. +4. [`verification_record.md`](verification_record.md), then [`issue121_full_run.json`](issue121_full_run.json): registered checks, counts, and hashes. +5. [`novelty_audit.md`](novelty_audit.md) and [`reduction_checklist.md`](reduction_checklist.md): prior art and defensible novelty. +6. [`finite_density_extension.md`](finite_density_extension.md): optional next research direction, not part of the solved hard gate. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md b/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md index 4c51d8eac..765f217ca 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/external_review_draft.md @@ -1,6 +1,6 @@ # External expert review draft: a contractive matrix family for issue #121 -Status: draft for public technical review. +Status: expert-review draft backed by the completed formal verifier. It has not been posted to MathOverflow or arXiv. This text evaluates the mathematical and physical claims on their present scope. It is not an endorsement of novelty or a substitute for independent reproduction. @@ -22,8 +22,8 @@ The proposed many-body realization uses overlapping S3-twirled Gaussian vertices It is interacting and non-Gaussian at the operator level for sufficiently small positive tau. Its continuous-time operator-string expansion nevertheless has nonnegative configuration weights. -In my view, the package is promising enough for specialist review after full reproducibility artifacts are posted. -The current appropriate recommendation is "major technical verification," not unconditional acceptance. +The full preregistered verifier and compact hash record are now posted in PR #261. +The current appropriate recommendation is independent specialist review, not unconditional acceptance. ## Background and relation to issue #121 @@ -140,9 +140,9 @@ At the stated point and t=3/4, the draft records p_t=10109/16000, q_t=15375/16000. -These values should be regenerated by exact rational arithmetic in the public verifier. +The formal verifier regenerated and verified all three values using exact Fraction arithmetic. -The orbit also reportedly has exact rational span rank nine in M_3(R). +The formal verifier confirmed exact Fraction span rank nine in M_3(R). That full-span result rules out an explanation confined to a proper linear subspace of 3x3 matrices. Together, full span and no common H strengthen the claim that the ell_infinity mechanism is structurally distinct. @@ -175,7 +175,7 @@ Here V is the positive linear combination of all resolved Gaussian vertices. The identity shift is physically and statistically important. Each twirl acts as one on the Fock vacuum, so H_bar annihilates the vacuum. -For the finite four-site benchmark, the verifier should check H_bar>=0 within tolerance. +For the finite four-site benchmark, the verifier checked H_bar>=0 within tolerance: the minimum eigenvalue was 4.440892098500626e-16 and the Frobenius hermiticity residual was 1.7216638914240724e-17. The operator is not merely a quadratic free-fermion Hamiltonian. At epsilon=1/100 and kappa=1/1000, exact Taylor coefficients give interaction certificates @@ -211,27 +211,30 @@ No extra factor exp(+beta G_0) belongs in the shifted estimator. The one-particle determinant should also be compared with an independent direct Fock-space trace. Time ordering should be identical in those two calculations. -## Reproducibility package expected for review +## Reproducibility package available for review - Issue discussion: [quantum.harness issue #121](https://github.com/QuantumBFS/quantum.harness/issues/121) -- Verifier source: [permanent source link to be inserted](VERIFIER_PERMALINK_TBD) -- Preregistered manifest: [manifest permalink to be inserted](MANIFEST_PERMALINK_TBD) -- Exact certificate output: [artifact link to be inserted](EXACT_CERTIFICATE_ARTIFACT_TBD) -- Full sampled report and hashes: [artifact link to be inserted](FULL_REPORT_ARTIFACT_TBD) -- Independent archival snapshot: [DOI or immutable archive to be inserted](ARCHIVE_DOI_TBD) - -The verifier should preregister dimensions, word depths, parameter regimes, and sample counts. -It should include center, near-boundary, weak-damping, and random interior points. -It should include d<=8 direct Fock checks and exact Fraction certificates. - -Known O(n,n) and Wei-semigroup controls should appear as positive and negative controls. -All four O(n,n) connected components should be sampled, including negative and exact-zero branches. -Near-singular determinants should trigger reproducible high-precision rebuilding rather than clipping. - -Every cell should be atomically written with a deterministic seed and content hash. -A COMPLETE sentinel should be created only after all preregistered checks pass. -Until those immutable artifacts exist, numerical statements should be labeled planned or provisional. - +- Pull request: [PR #261](https://github.com/QuantumBFS/quantum.harness/pull/261) +- Executable commit: [9fe85a6317132983b48c12cbe3628b2da2945a19](https://github.com/QuantumBFS/quantum.harness/commit/9fe85a6317132983b48c12cbe3628b2da2945a19) +- [Verifier source at the executable commit](https://github.com/QuantumBFS/quantum.harness/blob/9fe85a6317132983b48c12cbe3628b2da2945a19/tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py) +- [Preregistered manifest at the executable commit](https://github.com/QuantumBFS/quantum.harness/blob/9fe85a6317132983b48c12cbe3628b2da2945a19/tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json) +- [Compact tracked verification record](verification_record.md) +- Remote row-level artifacts: `tracks/qmc/results/Genshin_Impact-121/20260730-021845-9fe85a6/` + +Protocol `ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20` +passed 224/224 cells: 35,840 candidate words, 4,480 control words, 336 direct +Fock checks, exact Fraction and twirl certificates, and 16,384 physical Poisson +strings. All candidate and physical weights were nonnegative. The 448 inconclusive +numeric classifications were exactly the preregistered mixed-component O(1,1) +zero controls; the unexpected count was zero. Near-singular cases triggered 672 +100-digit rebuilds. The four-site ED/Poisson benchmark passed at all four beta +values, and the test suite passed 39 tests. + +The compact record contains SHA256 values for the manifest, verifier, independent +support oracle, reports, exact and physical artifacts, samples table, and COMPLETE +sentinel. The 9.6 MB `samples.csv` remains in the durable remote result directory +rather than being copied into the PR. No DOI or independent archival snapshot is +claimed. ## Scope and limitations This work does not by itself prove literature priority. @@ -274,7 +277,8 @@ The interacting twirl supplies a concrete route from matrix algebra to a many-bo Publication value will depend on three remaining standards. First, the theorem and representation-class boundaries must survive specialist scrutiny. -Second, the complete preregistered verifier must be independently reproducible. +Second, the completed preregistered verifier should be independently reproduced. Third, the literature audit must justify a carefully worded novelty claim. -Subject to those conditions, I would encourage a full technical submission rather than dismiss the construction as a numerical curiosity. +Subject to independent review, I would encourage a full technical submission rather +than dismiss the construction as a numerical curiosity. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/COMPLETE b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/COMPLETE new file mode 100644 index 000000000..e2c8a37fe --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/COMPLETE @@ -0,0 +1 @@ +{"completed_at":"2026-07-29T18:25:23.975391+00:00","protocol_id":"ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20","report_json_sha256":"52c8fb5419d2fdf463b4a56643f63de216aa45ac73b9fe46d149da9eb27390be","report_markdown_sha256":"727f5f0c54cc4b277a19503f5c2f865249c09f317c5251dc8c2b8f579c4fb8a9"} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.html b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.html new file mode 100644 index 000000000..0c0514d9a --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.html @@ -0,0 +1,84 @@ + +Issue #121: polyhedral sign-free generator supports
Genshin_Impact formal verification

Issue #121: polyhedral sign-free generator supports

https://github.com/QuantumBFS/quantum.harness/pull/261

An open real generator family has an arbitrary-depth determinant-positivity proof, exact separation certificates, and a completed interacting four-site verification.

1. Mathematical result

The theorem is analytic; sampling is an implementation audit.

Formal protocol passed224/224 cells and every exact, twirl, Fock, and physical stage passed.

For epsilon>0, kappa>0, and 40 epsilon+59 kappa<2, the two S3 orbits of A and B=SAS share a strict infinity-norm contraction rate -kappa. Therefore every finite positive-time word has det(I+T)>=0, including locally embedded arbitrary-depth words.

Executable commit
9fe85a6317132983b48c12cbe3628b2da2945a19
Protocol
ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20
Structural certificates
no common H>0; span M_3(R); fixed same-dimensional CAR/Wei obstruction
Design scope
open two-orbit family and wider seven-parameter cone
Proof boundary The fixed-CAR result does not exclude ancillas, configuration-dependent bases, or a different many-body decomposition.

2. Preregistered evidence

Seed 1212026; Python 3.13.9, NumPy 2.5.1, SciPy 1.18.0, mpmath 1.4.1.

StageCellsWords / checksOutcome
A/B candidates14035,840all positive
Split O(n,n) controls281,792pass
Wei semigroup controls281,792pass
Four O(1,1) components28896pass; 448 expected zeros
Direct Fock oracle-336max abs error 5.400124791776761e-13
Physical Poisson strings-16,384all nonnegative
Core random words
40,320
Total including physical
56,704
High-precision rebuilds
672
Unexpected inconclusive cases
0
Regression tests
39 pass

The compact tracked record lists SHA256 values for the manifest, verifier, independent support oracle, exact/twirl/physical artifacts, reports, samples table, and COMPLETE sentinel. Row-level samples remain in this durable run directory.

3. Interacting physical benchmark

Four open sites, overlapping triples (1,2,3) and (2,3,4), s=1/10, g_A=g_B=1/4, mu=0.

The complete S3 twirl is Hermitian and non-Gaussian, while every resolved continuous-time configuration has a nonnegative determinant activity. Exact 16-dimensional diagonalization was compared with the normalized positive Poisson estimator.

betaExact ED Z_barPoisson abs errorAllowance
1/415.3163534083896490.028088692310300090.1727116598757571
1/214.6691030803747730.035129552196263350.2233055507021328
113.4753922713054020.024535683666746520.2857508015621753
211.4393313885352330.04612091005488850.33059523654337436
Minimum sampled determinant
4.330910819303328
Minimum H_bar eigenvalue
4.440892098500626e-16
Hermiticity residual
1.7216638914240724e-17
Physical boundary This is an engineered local interacting CT Gaussian-vertex model, not a standard Hubbard AFQMC decomposition. Its mu=0 ground state is the vacuum; finite-density positivity remains open.

4. Reproduction and claim boundary

Slurm jobs 42169, 42171, and 42173 completed the pilot, full run, and afterok audit.

Reproduce from the repository root
output=tracks/qmc/results/Genshin_Impact-121/REPRODUCE-$(date -u +%Y%m%d-%H%M%S)
+python tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py \
+  --manifest tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json \
+  --output "$output"
What this result does not establish
  • It does not prove literature priority or maintainer acceptance.
  • It does not exclude every ancilla, Hubbard-Stratonovich, fermion-bag, Jordan-Wigner, or stoquastic reformulation.
  • It does not establish a finite-density sign-free phase or efficient autocorrelation time.
  • It is ready for independent expert review, but is not yet publication-ready.
Issue standard versus scientific acceptanceThe six explicit issue #121 submission gates are supplied; external proof review and priority assessment remain open.
diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.json new file mode 100644 index 000000000..3169d0365 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/challenge_report.json @@ -0,0 +1,238 @@ +{ + "title": "Issue #121: polyhedral sign-free generator supports", + "eyebrow": "Genshin_Impact formal verification", + "url": "https://github.com/QuantumBFS/quantum.harness/pull/261", + "lede": "An open real generator family has an arbitrary-depth determinant-positivity proof, exact separation certificates, and a completed interacting four-site verification.", + "sections": [ + { + "title": "1. Mathematical result", + "note": "The theorem is analytic; sampling is an implementation audit.", + "blocks": [ + { + "kind": "verdict", + "status": "good", + "label": "Formal protocol passed", + "why": "224/224 cells and every exact, twirl, Fock, and physical stage passed." + }, + { + "kind": "text", + "text": "For epsilon>0, kappa>0, and 40 epsilon+59 kappa<2, the two S3 orbits of A and B=SAS share a strict infinity-norm contraction rate -kappa. Therefore every finite positive-time word has det(I+T)>=0, including locally embedded arbitrary-depth words." + }, + { + "kind": "kv", + "pairs": [ + [ + "Executable commit", + "9fe85a6317132983b48c12cbe3628b2da2945a19" + ], + [ + "Protocol", + "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20" + ], + [ + "Structural certificates", + "no common H>0; span M_3(R); fixed same-dimensional CAR/Wei obstruction" + ], + [ + "Design scope", + "open two-orbit family and wider seven-parameter cone" + ] + ] + }, + { + "kind": "note", + "label": "Proof boundary", + "text": "The fixed-CAR result does not exclude ancillas, configuration-dependent bases, or a different many-body decomposition." + } + ] + }, + { + "title": "2. Preregistered evidence", + "note": "Seed 1212026; Python 3.13.9, NumPy 2.5.1, SciPy 1.18.0, mpmath 1.4.1.", + "blocks": [ + { + "kind": "table", + "columns": [ + "Stage", + "Cells", + "Words / checks", + "Outcome" + ], + "numeric": [ + false, + true, + true, + false + ], + "rows": [ + [ + "A/B candidates", + "140", + "35,840", + "all positive" + ], + [ + "Split O(n,n) controls", + "28", + "1,792", + "pass" + ], + [ + "Wei semigroup controls", + "28", + "1,792", + "pass" + ], + [ + "Four O(1,1) components", + "28", + "896", + "pass; 448 expected zeros" + ], + [ + "Direct Fock oracle", + "-", + "336", + "max abs error 5.400124791776761e-13" + ], + [ + "Physical Poisson strings", + "-", + "16,384", + "all nonnegative" + ] + ] + }, + { + "kind": "kv", + "pairs": [ + [ + "Core random words", + "40,320" + ], + [ + "Total including physical", + "56,704" + ], + [ + "High-precision rebuilds", + "672" + ], + [ + "Unexpected inconclusive cases", + "0" + ], + [ + "Regression tests", + "39 pass" + ] + ] + }, + { + "kind": "text", + "text": "The compact tracked record lists SHA256 values for the manifest, verifier, independent support oracle, exact/twirl/physical artifacts, reports, samples table, and COMPLETE sentinel. Row-level samples remain in this durable run directory." + } + ] + }, + { + "title": "3. Interacting physical benchmark", + "note": "Four open sites, overlapping triples (1,2,3) and (2,3,4), s=1/10, g_A=g_B=1/4, mu=0.", + "blocks": [ + { + "kind": "text", + "text": "The complete S3 twirl is Hermitian and non-Gaussian, while every resolved continuous-time configuration has a nonnegative determinant activity. Exact 16-dimensional diagonalization was compared with the normalized positive Poisson estimator." + }, + { + "kind": "table", + "columns": [ + "beta", + "Exact ED Z_bar", + "Poisson abs error", + "Allowance" + ], + "numeric": [ + true, + true, + true, + true + ], + "rows": [ + [ + "1/4", + "15.316353408389649", + "0.02808869231030009", + "0.1727116598757571" + ], + [ + "1/2", + "14.669103080374773", + "0.03512955219626335", + "0.2233055507021328" + ], + [ + "1", + "13.475392271305402", + "0.02453568366674652", + "0.2857508015621753" + ], + [ + "2", + "11.439331388535233", + "0.0461209100548885", + "0.33059523654337436" + ] + ] + }, + { + "kind": "kv", + "pairs": [ + [ + "Minimum sampled determinant", + "4.330910819303328" + ], + [ + "Minimum H_bar eigenvalue", + "4.440892098500626e-16" + ], + [ + "Hermiticity residual", + "1.7216638914240724e-17" + ] + ] + }, + { + "kind": "note", + "label": "Physical boundary", + "text": "This is an engineered local interacting CT Gaussian-vertex model, not a standard Hubbard AFQMC decomposition. Its mu=0 ground state is the vacuum; finite-density positivity remains open." + } + ] + }, + { + "title": "4. Reproduction and claim boundary", + "note": "Slurm jobs 42169, 42171, and 42173 completed the pilot, full run, and afterok audit.", + "blocks": [ + { + "kind": "code", + "title": "Reproduce from the repository root", + "text": "output=tracks/qmc/results/Genshin_Impact-121/REPRODUCE-$(date -u +%Y%m%d-%H%M%S)\npython tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py \\\n --manifest tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json \\\n --output \"$output\"" + }, + { + "kind": "list", + "title": "What this result does not establish", + "items": [ + "It does not prove literature priority or maintainer acceptance.", + "It does not exclude every ancilla, Hubbard-Stratonovich, fermion-bag, Jordan-Wigner, or stoquastic reformulation.", + "It does not establish a finite-density sign-free phase or efficient autocorrelation time.", + "It is ready for independent expert review, but is not yet publication-ready." + ] + }, + { + "kind": "verdict", + "status": "warn", + "label": "Issue standard versus scientific acceptance", + "why": "The six explicit issue #121 submission gates are supplied; external proof review and priority assessment remain open." + } + ] + } + ] +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/exact_certificates.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/exact_certificates.json new file mode 100644 index 000000000..c88ccc059 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/exact_certificates.json @@ -0,0 +1,55 @@ +{ + "certificates": { + "mu_infinity": "-1/1000", + "no_common_H_lower_bound": "1541/42609", + "no_common_H_upper_bound": "-1541/24791", + "o11_component_det_I_plus": { + "++": "16/3", + "+-": "0", + "-+": "0", + "--": "-4/3" + }, + "opposite_edge_product_A13_A31": "-1/50", + "seven_parameter_at_t_3_4": { + "G": "1679/16000", + "p": "10109/16000", + "q": "123/128" + }, + "standard_polynomial": "2 epsilon^3 + epsilon^2 - 4 epsilon + 3", + "standard_polynomial_minimizer_nonnegative_axis": "2/3", + "standard_polynomial_minimum": "37/27", + "support_span_rank": 9, + "twirl_tau2": { + "A": { + "interaction": "5020671/1000000", + "non_gaussian": "363599/360000" + }, + "B": { + "interaction": "3056033/3000000", + "non_gaussian": "797/120000" + } + } + }, + "checks": { + "all_exact_row_rates_minus_kappa": true, + "component_weights": true, + "full_support_fraction_rank_9": true, + "no_common_quadratic_bounds_disjoint": true, + "open_region": true, + "opposite_edge_product": true, + "seven_parameter_t_3_4": true, + "split_boost_identity": true, + "standard_polynomial_minimum_positive": true, + "twirl_tau2_coefficients": true + }, + "completed_at": "2026-07-29T18:20:29.546541+00:00", + "elapsed_seconds": 0.0044496890041045845, + "interpretation": "Exact Fraction arithmetic; these certify formulas, not literature priority.", + "parameters": { + "epsilon": "1/100", + "kappa": "1/1000" + }, + "protocol_id": "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20", + "schema_version": 1, + "status": "pass" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/manifest.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/manifest.json new file mode 100644 index 000000000..a3e0ab251 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/manifest.json @@ -0,0 +1,240 @@ +{ + "candidate": { + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "description": "Locally embedded three-mode A/B orbit words", + "dimensions": [ + 3, + 4, + 6, + 8, + 12 + ], + "regimes": [ + { + "epsilon": "1/100", + "id": "center", + "kappa": "1/1000", + "kind": "fixed" + }, + { + "epsilon": "1/100", + "id": "near_boundary", + "kappa": "1599/59000", + "kind": "fixed", + "note": "40 epsilon + 59 kappa = 1999/1000" + }, + { + "epsilon": "1/100", + "id": "kappa_to_zero", + "kappa": "1/1000000", + "kind": "fixed" + }, + { + "alpha": [ + 1.0, + 1.0, + 1.0 + ], + "id": "dirichlet_open_triangle", + "kind": "dirichlet_open_triangle", + "map": "epsilon=x/20, kappa=2y/59" + } + ], + "samples_per_cell": 256, + "time_distribution": { + "kind": "log_uniform", + "maximum": "5", + "minimum": "1e-3" + } + }, + "component_controls": { + "components": [ + "++", + "--", + "-+", + "+-" + ], + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "description": "All four O(1,1) components", + "generator_scale": 0.15, + "n_values": [ + 1 + ], + "samples_per_cell": 32, + "time_distribution": { + "kind": "log_uniform", + "maximum": "0.5", + "minimum": "1e-3" + } + }, + "determinant_precision": { + "high_precision_imag_tolerance": "1e-60", + "high_precision_zero_tolerance": "1e-60", + "mpmath_dps": 100, + "sigma_min_escalation": "1e-9" + }, + "execution": { + "cpus_per_task": 1, + "durability": "atomic cells, protocol-bound resume, all-pass COMPLETE", + "gpus": 0, + "memory_mb": 2048, + "platform": "t02-server Slurm CPU job", + "time_limit_minutes": 20 + }, + "expected_workload": { + "candidate_cells": 140, + "candidate_words": 35840, + "component_cells": 28, + "component_words": 896, + "fock_oracle_checks": 336, + "physical_poisson_words": 16384, + "semigroup_cells": 28, + "semigroup_words": 1792, + "split_cells": 28, + "split_words": 1792, + "total_cells": 224, + "total_random_words_including_physical": 56704, + "total_words": 40320 + }, + "fock_oracle": { + "absolute_tolerance": "5e-8", + "maximum_dimension": 8, + "relative_tolerance": "5e-9", + "sample_indices": [ + 0, + 127, + 255 + ] + }, + "physical_benchmark": { + "betas": [ + "1/4", + "1/2", + "1", + "2" + ], + "boundary": "open", + "chemical_potential": "0", + "confidence_sigma": 8.0, + "couplings": { + "A": "1/4", + "B": "1/4" + }, + "description": "Four-site OBC shifted-Hbar convention", + "deterministic_roundoff_allowance": "1e-10", + "deterministic_truncation_order": 24, + "epsilon": "1/100", + "hermiticity_tolerance": "1e-11", + "kappa": "1/1000", + "partition_imag_tolerance": "1e-9", + "poisson_samples_per_beta": 4096, + "relative_error_floor": 0.01, + "seed": 1212026, + "sites": 4, + "tau": "1/10", + "triangles": [ + [ + 0, + 1, + 2 + ], + [ + 1, + 2, + 3 + ] + ], + "weight_tolerance": "1e-9" + }, + "positive_anchors": { + "semigroup_cone": { + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "description": "Wei semigroup A^T eta + eta A positive semidefinite", + "dissipation_strength": { + "maximum": 0.15, + "minimum": 0.01 + }, + "n_values": [ + 1, + 2, + 3, + 4 + ], + "rank_tolerance": "1e-10", + "samples_per_cell": 64, + "split_generator_scale": 0.1, + "time_distribution": { + "kind": "log_uniform", + "maximum": "0.5", + "minimum": "1e-3" + } + }, + "split_orthogonal": { + "depths": [ + 1, + 2, + 4, + 8, + 16, + 32, + 64 + ], + "description": "Identity component of O(n,n)", + "generator_scale": 0.15, + "n_values": [ + 1, + 2, + 3, + 4 + ], + "samples_per_cell": 64, + "time_distribution": { + "kind": "log_uniform", + "maximum": "0.5", + "minimum": "1e-3" + } + } + }, + "protocol_name": "Genshin_Impact issue 121 full preregistered audit", + "schema_version": 1, + "seed": 1212026, + "thresholds": { + "component_zero_sigma": "5e-9", + "contraction_abs": "5e-10", + "semigroup_generator_eigenvalue_abs": "5e-10", + "semigroup_product_eigenvalue_abs": "5e-8", + "split_group_abs": "5e-8", + "split_lie_abs": "5e-10" + }, + "twirl_checks": { + "epsilon": "1/100", + "hermiticity_tolerance": "1e-11", + "kappa": "1/1000", + "nongaussian_gap_minimum_abs": "1e-8", + "tau": "1/10" + } +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/physical_benchmark.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/physical_benchmark.json new file mode 100644 index 000000000..50ad8a1b5 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/physical_benchmark.json @@ -0,0 +1,748 @@ +{ + "beta_results": [ + { + "beta": "1/4", + "deterministic_abs_error": 0.0, + "deterministic_expansion": { + "energy_shift_G0": 1.0, + "operator_norm_argument": 0.2499999999999999, + "order": 24, + "partition_estimate_imag_abs": 0.0, + "partition_estimate_real": 15.316353408389649, + "remainder_bound": 9.161667384751697e-40, + "shift_normalization_exp_minus_beta_G0": 0.7788007830714049, + "terms": [ + { + "imag_abs": 0.0, + "order": 0, + "real": 12.460812529142478 + }, + { + "imag_abs": 0.0, + "order": 1, + "real": 2.5680247649376913 + }, + { + "imag_abs": 0.0, + "order": 2, + "real": 0.26765975134625064 + }, + { + "imag_abs": 0.0, + "order": 3, + "real": 0.018809225191832125 + }, + { + "imag_abs": 0.0, + "order": 4, + "real": 0.0010023294288424433 + }, + { + "imag_abs": 0.0, + "order": 5, + "real": 4.319072751568084e-05 + }, + { + "imag_abs": 0.0, + "order": 6, + "real": 1.5670014037181487e-06 + }, + { + "imag_abs": 0.0, + "order": 7, + "real": 4.921373511175038e-08 + }, + { + "imag_abs": 0.0, + "order": 8, + "real": 1.3651554906953055e-09 + }, + { + "imag_abs": 0.0, + "order": 9, + "real": 3.396011867747338e-11 + }, + { + "imag_abs": 0.0, + "order": 10, + "real": 7.666696994013786e-13 + }, + { + "imag_abs": 0.0, + "order": 11, + "real": 1.5857242766140896e-14 + }, + { + "imag_abs": 0.0, + "order": 12, + "real": 3.028286726490249e-16 + }, + { + "imag_abs": 0.0, + "order": 13, + "real": 5.374201014014706e-18 + }, + { + "imag_abs": 0.0, + "order": 14, + "real": 8.911185261370186e-20 + }, + { + "imag_abs": 0.0, + "order": 15, + "real": 1.386989765261581e-21 + }, + { + "imag_abs": 0.0, + "order": 16, + "real": 2.0345281620998208e-23 + }, + { + "imag_abs": 0.0, + "order": 17, + "real": 2.82241713584158e-25 + }, + { + "imag_abs": 0.0, + "order": 18, + "real": 3.714314480214766e-27 + }, + { + "imag_abs": 0.0, + "order": 19, + "real": 4.6496379052263827e-29 + }, + { + "imag_abs": 0.0, + "order": 20, + "real": 5.550095414901469e-31 + }, + { + "imag_abs": 0.0, + "order": 21, + "real": 6.331039203324404e-33 + }, + { + "imag_abs": 0.0, + "order": 22, + "real": 6.915211523126396e-35 + }, + { + "imag_abs": 0.0, + "order": 23, + "real": 7.245653909923289e-37 + }, + { + "imag_abs": 0.0, + "order": 24, + "real": 7.294752880239593e-39 + } + ], + "z_bar_estimate_imag_abs": 0.0, + "z_bar_estimate_real": 15.316353408389649 + }, + "exact_fock_partition_function": 15.316353408389649, + "exact_partition_imag_abs": 0.0, + "exact_z_bar": 15.316353408389649, + "poisson": { + "energy_shift_G0": 1.0, + "maximum_fock_determinant_abs_error": 8.881784197001252e-15, + "maximum_fock_imaginary_part": 0.0, + "maximum_sampled_order": 3, + "minimum_configuration": { + "determinant_decimal": "9.1307348234499077", + "fock_weight": 9.130734823449906, + "order": 3, + "sample": 380, + "word_sha256": "73f3b32cb541aea43ab74bfc2384e336894739ebe384d4a82c109fbd3f9aa76f" + }, + "minimum_determinant_configuration_weight": 9.130734823449908, + "minimum_fock_configuration_weight": 9.130734823449906, + "minimum_sampled_order": 0, + "negative_or_unresolved_configurations": 0, + "partition_estimate": 15.288264716079349, + "poisson_mean": 0.25, + "poisson_mean_beta_G0": 0.25, + "sample_count": 4096, + "standard_error": 0.021588957484469637, + "total_vertex_weight": 1.0, + "z_bar_estimate": 15.288264716079349 + }, + "poisson_abs_error": 0.02808869231030009, + "poisson_allowed_error": 0.1727116598757571, + "status": "pass" + }, + { + "beta": "1/2", + "deterministic_abs_error": 1.7763568394002505e-15, + "deterministic_expansion": { + "energy_shift_G0": 1.0, + "operator_norm_argument": 0.4999999999999998, + "order": 24, + "partition_estimate_imag_abs": 0.0, + "partition_estimate_real": 14.669103080374775, + "remainder_bound": 3.074145452682686e-32, + "shift_normalization_exp_minus_beta_G0": 0.6065306597126334, + "terms": [ + { + "imag_abs": 0.0, + "order": 0, + "real": 9.704490555402135 + }, + { + "imag_abs": 0.0, + "order": 1, + "real": 3.999959395760469 + }, + { + "imag_abs": 0.0, + "order": 2, + "real": 0.83381449578063 + }, + { + "imag_abs": 0.0, + "order": 3, + "real": 0.11718911446692204 + }, + { + "imag_abs": 0.0, + "order": 4, + "real": 0.012489839105248141 + }, + { + "imag_abs": 0.0, + "order": 5, + "real": 0.0010763831171403493 + }, + { + "imag_abs": 0.0, + "order": 6, + "real": 7.810444289853983e-05 + }, + { + "imag_abs": 0.0, + "order": 7, + "real": 4.905945016691185e-06 + }, + { + "imag_abs": 0.0, + "order": 8, + "real": 2.721751462829394e-07 + }, + { + "imag_abs": 0.0, + "order": 9, + "real": 1.3541461513837625e-08 + }, + { + "imag_abs": 0.0, + "order": 10, + "real": 6.114129533449341e-10 + }, + { + "imag_abs": 0.0, + "order": 11, + "real": 2.5292048555261747e-11 + }, + { + "imag_abs": 0.0, + "order": 12, + "real": 9.660137774921102e-13 + }, + { + "imag_abs": 0.0, + "order": 13, + "real": 3.428705860073711e-14 + }, + { + "imag_abs": 0.0, + "order": 14, + "real": 1.137055835692968e-15 + }, + { + "imag_abs": 0.0, + "order": 15, + "real": 3.5395623822876454e-17 + }, + { + "imag_abs": 0.0, + "order": 16, + "real": 1.0384127595801257e-18 + }, + { + "imag_abs": 0.0, + "order": 17, + "real": 2.8810945174537164e-20 + }, + { + "imag_abs": 0.0, + "order": 18, + "real": 7.583068391380662e-22 + }, + { + "imag_abs": 0.0, + "order": 19, + "real": 1.8985211089853054e-23 + }, + { + "imag_abs": 0.0, + "order": 20, + "real": 4.532384463843521e-25 + }, + { + "imag_abs": 0.0, + "order": 21, + "real": 1.0340256006442444e-26 + }, + { + "imag_abs": 0.0, + "order": 22, + "real": 2.2588726808161507e-28 + }, + { + "imag_abs": 0.0, + "order": 23, + "real": 4.733625173153012e-30 + }, + { + "imag_abs": 0.0, + "order": 24, + "real": 9.531403595896606e-32 + } + ], + "z_bar_estimate_imag_abs": 0.0, + "z_bar_estimate_real": 14.669103080374775 + }, + "exact_fock_partition_function": 14.669103080374773, + "exact_partition_imag_abs": 0.0, + "exact_z_bar": 14.669103080374773, + "poisson": { + "energy_shift_G0": 1.0, + "maximum_fock_determinant_abs_error": 8.881784197001252e-15, + "maximum_fock_imaginary_part": 0.0, + "maximum_sampled_order": 4, + "minimum_configuration": { + "determinant_decimal": "7.7498935076637974", + "fock_weight": 7.749893507663796, + "order": 4, + "sample": 3552, + "word_sha256": "e131c5716956c38a704397a5be5928d147c5b8800a05e2f4bf5411ba20cf8c6b" + }, + "minimum_determinant_configuration_weight": 7.749893507663797, + "minimum_fock_configuration_weight": 7.749893507663796, + "minimum_sampled_order": 0, + "negative_or_unresolved_configurations": 0, + "partition_estimate": 14.704232632571037, + "poisson_mean": 0.5, + "poisson_mean_beta_G0": 0.5, + "sample_count": 4096, + "standard_error": 0.0279131938377666, + "total_vertex_weight": 1.0, + "z_bar_estimate": 14.704232632571037 + }, + "poisson_abs_error": 0.03512955219626335, + "poisson_allowed_error": 0.2233055507021328, + "status": "pass" + }, + { + "beta": "1", + "deterministic_abs_error": 1.7763568394002505e-15, + "deterministic_expansion": { + "energy_shift_G0": 1.0, + "operator_norm_argument": 0.9999999999999996, + "order": 24, + "partition_estimate_imag_abs": 0.0, + "partition_estimate_real": 13.475392271305404, + "remainder_bound": 1.031512045501504e-24, + "shift_normalization_exp_minus_beta_G0": 0.36787944117144233, + "terms": [ + { + "imag_abs": 0.0, + "order": 0, + "real": 5.886071058743077 + }, + { + "imag_abs": 0.0, + "order": 1, + "real": 4.8521960222686875 + }, + { + "imag_abs": 0.0, + "order": 2, + "real": 2.0229362248151292 + }, + { + "imag_abs": 0.0, + "order": 3, + "real": 0.5686303272700923 + }, + { + "imag_abs": 0.0, + "order": 4, + "real": 0.12120752563537285 + }, + { + "imag_abs": 0.0, + "order": 5, + "real": 0.02089149958856566 + }, + { + "imag_abs": 0.0, + "order": 6, + "real": 0.003031855313775301 + }, + { + "imag_abs": 0.0, + "order": 7, + "real": 0.00038087757663841427 + }, + { + "imag_abs": 0.0, + "order": 8, + "real": 4.2261138184287676e-05 + }, + { + "imag_abs": 0.0, + "order": 9, + "real": 4.20521553175612e-06 + }, + { + "imag_abs": 0.0, + "order": 10, + "real": 3.797408787959321e-07 + }, + { + "imag_abs": 0.0, + "order": 11, + "real": 3.141714513040766e-08 + }, + { + "imag_abs": 0.0, + "order": 12, + "real": 2.399915924495494e-09 + }, + { + "imag_abs": 0.0, + "order": 13, + "real": 1.7036207941804688e-10 + }, + { + "imag_abs": 0.0, + "order": 14, + "real": 1.1299376761290025e-11 + }, + { + "imag_abs": 0.0, + "order": 15, + "real": 7.034808260437429e-13 + }, + { + "imag_abs": 0.0, + "order": 16, + "real": 4.1276484886341215e-14 + }, + { + "imag_abs": 0.0, + "order": 17, + "real": 2.29044670741303e-15 + }, + { + "imag_abs": 0.0, + "order": 18, + "real": 1.2056955385466405e-16 + }, + { + "imag_abs": 0.0, + "order": 19, + "real": 6.037235358557629e-18 + }, + { + "imag_abs": 0.0, + "order": 20, + "real": 2.882567026954785e-19 + }, + { + "imag_abs": 0.0, + "order": 21, + "real": 1.3152671072906235e-20 + }, + { + "imag_abs": 0.0, + "order": 22, + "real": 5.746513306409038e-22 + }, + { + "imag_abs": 0.0, + "order": 23, + "real": 2.4084438468881127e-23 + }, + { + "imag_abs": 0.0, + "order": 24, + "real": 9.699057066427502e-25 + } + ], + "z_bar_estimate_imag_abs": 0.0, + "z_bar_estimate_real": 13.475392271305404 + }, + "exact_fock_partition_function": 13.475392271305402, + "exact_partition_imag_abs": 0.0, + "exact_z_bar": 13.475392271305402, + "poisson": { + "energy_shift_G0": 1.0, + "maximum_fock_determinant_abs_error": 8.881784197001252e-15, + "maximum_fock_imaginary_part": 0.0, + "maximum_sampled_order": 7, + "minimum_configuration": { + "determinant_decimal": "5.0114337181972894", + "fock_weight": 5.0114337181972894, + "order": 7, + "sample": 1974, + "word_sha256": "d135c495b854bd4cf5d99fee297b62e90b731d7c82f2ffc35fa7928d8e4c0eb0" + }, + "minimum_determinant_configuration_weight": 5.0114337181972894, + "minimum_fock_configuration_weight": 5.0114337181972894, + "minimum_sampled_order": 0, + "negative_or_unresolved_configurations": 0, + "partition_estimate": 13.499927954972149, + "poisson_mean": 1.0, + "poisson_mean_beta_G0": 1.0, + "sample_count": 4096, + "standard_error": 0.03571885019527191, + "total_vertex_weight": 1.0, + "z_bar_estimate": 13.499927954972149 + }, + "poisson_abs_error": 0.02453568366674652, + "poisson_allowed_error": 0.2857508015621753, + "status": "pass" + }, + { + "beta": "2", + "deterministic_abs_error": 3.552713678800501e-15, + "deterministic_expansion": { + "energy_shift_G0": 1.0, + "operator_norm_argument": 1.9999999999999991, + "order": 24, + "partition_estimate_imag_abs": 0.0, + "partition_estimate_real": 11.43933138853523, + "remainder_bound": 3.46118007879611e-17, + "shift_normalization_exp_minus_beta_G0": 0.1353352832366127, + "terms": [ + { + "imag_abs": 0.0, + "order": 0, + "real": 2.1653645317858032 + }, + { + "imag_abs": 0.0, + "order": 1, + "real": 3.5700463222530003 + }, + { + "imag_abs": 0.0, + "order": 2, + "real": 2.976786591641828 + }, + { + "imag_abs": 0.0, + "order": 3, + "real": 1.6734992562340474 + }, + { + "imag_abs": 0.0, + "order": 4, + "real": 0.7134361087442277 + }, + { + "imag_abs": 0.0, + "order": 5, + "real": 0.24593770220399844 + }, + { + "imag_abs": 0.0, + "order": 6, + "real": 0.07138286326683684 + }, + { + "imag_abs": 0.0, + "order": 7, + "real": 0.017934979846204548 + }, + { + "imag_abs": 0.0, + "order": 8, + "real": 0.003980032998017242 + }, + { + "imag_abs": 0.0, + "order": 9, + "real": 0.0007920703179918904 + }, + { + "imag_abs": 0.0, + "order": 10, + "real": 0.00014305163497615352 + }, + { + "imag_abs": 0.0, + "order": 11, + "real": 2.3670214233654212e-05 + }, + { + "imag_abs": 0.0, + "order": 12, + "real": 3.6162753706469284e-06 + }, + { + "imag_abs": 0.0, + "order": 13, + "real": 5.13414812246966e-07 + }, + { + "imag_abs": 0.0, + "order": 14, + "real": 6.810514896533842e-08 + }, + { + "imag_abs": 0.0, + "order": 15, + "real": 8.480231691380222e-09 + }, + { + "imag_abs": 0.0, + "order": 16, + "real": 9.951490994017856e-10 + }, + { + "imag_abs": 0.0, + "order": 17, + "real": 1.1044234916738833e-10 + }, + { + "imag_abs": 0.0, + "order": 18, + "real": 1.1627412873371696e-11 + }, + { + "imag_abs": 0.0, + "order": 19, + "real": 1.164430420175305e-12 + }, + { + "imag_abs": 0.0, + "order": 20, + "real": 1.11194894186877e-13 + }, + { + "imag_abs": 0.0, + "order": 21, + "real": 1.0147273971780899e-14 + }, + { + "imag_abs": 0.0, + "order": 22, + "real": 8.866859754857753e-16 + }, + { + "imag_abs": 0.0, + "order": 23, + "real": 7.432449097086253e-17 + }, + { + "imag_abs": 0.0, + "order": 24, + "real": 5.986251083171387e-18 + } + ], + "z_bar_estimate_imag_abs": 0.0, + "z_bar_estimate_real": 11.43933138853523 + }, + "exact_fock_partition_function": 11.439331388535233, + "exact_partition_imag_abs": 0.0, + "exact_z_bar": 11.439331388535233, + "poisson": { + "energy_shift_G0": 1.0, + "maximum_fock_determinant_abs_error": 8.881784197001252e-15, + "maximum_fock_imaginary_part": 0.0, + "maximum_sampled_order": 8, + "minimum_configuration": { + "determinant_decimal": "4.3309108193033277", + "fock_weight": 4.3309108193033286, + "order": 8, + "sample": 1039, + "word_sha256": "b83fdaed2549d5e83b8bd7eac99f4f70ce963156858a62c34e6c59b83c80e2f6" + }, + "minimum_determinant_configuration_weight": 4.330910819303328, + "minimum_fock_configuration_weight": 4.3309108193033286, + "minimum_sampled_order": 0, + "negative_or_unresolved_configurations": 0, + "partition_estimate": 11.485452298590122, + "poisson_mean": 2.0, + "poisson_mean_beta_G0": 2.0, + "sample_count": 4096, + "standard_error": 0.041324404567921795, + "total_vertex_weight": 1.0, + "z_bar_estimate": 11.485452298590122 + }, + "poisson_abs_error": 0.0461209100548885, + "poisson_allowed_error": 0.33059523654337436, + "status": "pass" + } + ], + "catalog_size": 24, + "completed_at": "2026-07-29T18:20:31.145319+00:00", + "elapsed_seconds": 1.5336786480038427, + "energy_shift_G0": 1.0, + "h_bar_psd_tolerance": 1e-09, + "h_bar_sha256": "0053f84c4405349852f8cfcb746600c9105c0f8ffdacfdc86df8cc9628583756", + "hamiltonian_dimension": 16, + "hamiltonian_hermiticity_residual_fro": 1.7216638914240724e-17, + "hamiltonian_sha256": "0053f84c4405349852f8cfcb746600c9105c0f8ffdacfdc86df8cc9628583756", + "interaction_V_sha256": "74be7cd8e3a6d612a99020fe89c002da90ea26d978b08494d0db22df285b98c2", + "interpretation": "For H_bar=G0 I-V, the exact 16-dimensional Z_bar is compared with the normalized positive Poisson operator-string estimator and a controlled shifted deterministic expansion.", + "minimum_h_bar_eigenvalue": 4.440892098500626e-16, + "one_particle_twirl_sha256": "f6533f2cf007cfcb94ece2e74d717798e8bba5489f74d4df521e06126ab1cc33", + "parameters": { + "betas": [ + "1/4", + "1/2", + "1", + "2" + ], + "boundary": "open", + "chemical_potential": "0", + "confidence_sigma": 8.0, + "couplings": { + "A": "1/4", + "B": "1/4" + }, + "description": "Four-site OBC shifted-Hbar convention", + "deterministic_roundoff_allowance": "1e-10", + "deterministic_truncation_order": 24, + "epsilon": "1/100", + "hermiticity_tolerance": "1e-11", + "kappa": "1/1000", + "partition_imag_tolerance": "1e-9", + "poisson_samples_per_beta": 4096, + "relative_error_floor": 0.01, + "seed": 1212026, + "sites": 4, + "tau": "1/10", + "triangles": [ + [ + 0, + 1, + 2 + ], + [ + 1, + 2, + 3 + ] + ], + "weight_tolerance": "1e-9" + }, + "protocol_id": "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20", + "schema_version": 1, + "status": "pass" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.json new file mode 100644 index 000000000..e01d483e8 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.json @@ -0,0 +1,92 @@ +{ + "aggregates": { + "cell_status_by_kind": { + "candidate": { + "fail": 0, + "pass": 140 + }, + "component_control": { + "fail": 0, + "pass": 28 + }, + "semigroup_cone": { + "fail": 0, + "pass": 28 + }, + "split_orthogonal": { + "fail": 0, + "pass": 28 + } + }, + "expected_exact_zero_controls": 448, + "fock_checks": 336, + "high_precision_escalations": 672, + "inconclusive_determinants": 448, + "maximum_abs_fock_error": 5.400124791776761e-13, + "raw_inconclusive_determinants": 448, + "unexpected_inconclusive_determinants": 0 + }, + "artifacts": { + "exact_certificates": { + "bytes": 1650, + "path": "exact_certificates.json", + "sha256": "4276fd469722894796cd4152c2f11f8cb3b977ee8dcc867062a48c57dec79034" + }, + "manifest": { + "bytes": 4923, + "path": "manifest.json", + "sha256": "d2fb2be0d2cb179ecf77036683c1c3d50283a28bcfa0b458859d910751f2016e" + }, + "physical_benchmark": { + "bytes": 21165, + "path": "physical_benchmark.json", + "sha256": "5b9029d962c6db0b3768a93d5e9512bcd607883c9cf052d8dbd7c2ecdea6c75a" + }, + "samples": { + "bytes": 9641890, + "path": "samples.csv", + "rows": 40320, + "sha256": "27a81a5400780b1851f031a725926cf964da7b0b97e27a4b5acde7fd599711a7" + }, + "twirl_checks": { + "bytes": 1413, + "path": "twirl_checks.json", + "sha256": "1234ee7b8e419b404c0cd667ea1cce7d26a12d72bff4a4a4676ef33a0da2b56a" + } + }, + "claim_boundary": "Passing establishes reproducibility of the preregistered checks. It is neither a proof by sampling nor a literature-priority claim.", + "completed_cells": 224, + "environment_signature": { + "mpmath": "1.4.1", + "numpy": "2.5.1", + "python_full": "3.13.9 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 19:16:10) [GCC 11.2.0]", + "python_major": 3, + "scipy": "1.18.0" + }, + "expected_full_sample_rows": 40320, + "failed_cells": [], + "generated_at": "2026-07-29T18:25:23.969324+00:00", + "manifest_sha256": "7a04a1e9a4293e85f47ddf4901ae8b20e7b034d7ee50b9d3e8317f805b2f4b12", + "pending_cells": [], + "protocol_id": "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20", + "requested_cell_ids": null, + "resource_note": { + "cpus_per_task": 1, + "durability": "atomic cells, protocol-bound resume, all-pass COMPLETE", + "gpus": 0, + "memory_mb": 2048, + "platform": "t02-server Slurm CPU job", + "time_limit_minutes": 20 + }, + "sample_rows": 40320, + "schema_version": 1, + "sign_problem_hunter_sha256": "fea156818fafdfc9635fb9e7c797470aa34758d82a24e69b6dd3b62d2e04f780", + "stage_status": { + "exact_certificates": "pass", + "physical_benchmark": "pass", + "twirl_checks": "pass" + }, + "status": "pass", + "total_cells": 224, + "verifier_sha256": "e566f1a0f300d5201a354cfcd3c45b022631ac3175d98af3fa3b898c954993c4" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.md b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.md new file mode 100644 index 000000000..4f8ebc0ba --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/report.md @@ -0,0 +1,16 @@ +# Issue 121 preregistered verification report + +- Status: pass +- Protocol: `ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20` +- Completed cells: 224 / 224 +- Consolidated random-word rows: 40320 +- Exact certificates: pass +- Twirl checks: pass +- Four-site physical benchmark: pass +- Raw numeric inconclusive classifications: 448 +- Expected exact-zero mixed O(1,1) controls: 448 +- Unexpected inconclusive determinants: 0 + +Random-word checks are implementation audits, not proofs. The exact +Fraction certificates and theorem documents carry the algebraic claims. +A COMPLETE sentinel is emitted only for an all-pass full protocol. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/run.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/run.json new file mode 100644 index 000000000..83a59b431 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/run.json @@ -0,0 +1,30 @@ +{ + "base_seed": 1212026, + "completed_cells": 224, + "environment": { + "mpmath": "1.4.1", + "numpy": "2.5.1", + "python_full": "3.13.9 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 19:16:10) [GCC 11.2.0]", + "python_major": 3, + "scipy": "1.18.0" + }, + "environment_signature": { + "mpmath": "1.4.1", + "numpy": "2.5.1", + "python_full": "3.13.9 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 19:16:10) [GCC 11.2.0]", + "python_major": 3, + "scipy": "1.18.0" + }, + "git_revision": "9fe85a6317132983b48c12cbe3628b2da2945a19", + "manifest_sha256": "7a04a1e9a4293e85f47ddf4901ae8b20e7b034d7ee50b9d3e8317f805b2f4b12", + "protocol_id": "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20", + "report_json_sha256": "52c8fb5419d2fdf463b4a56643f63de216aa45ac73b9fe46d149da9eb27390be", + "report_markdown_sha256": "727f5f0c54cc4b277a19503f5c2f865249c09f317c5251dc8c2b8f579c4fb8a9", + "schema_version": 1, + "sign_problem_hunter_sha256": "fea156818fafdfc9635fb9e7c797470aa34758d82a24e69b6dd3b62d2e04f780", + "started_at": "2026-07-29T18:20:29.516488+00:00", + "status": "pass", + "total_cells": 224, + "updated_at": "2026-07-29T18:25:23.972206+00:00", + "verifier_sha256": "e566f1a0f300d5201a354cfcd3c45b022631ac3175d98af3fa3b898c954993c4" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/slurm_jobs.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/slurm_jobs.json new file mode 100644 index 000000000..fb54c78a9 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/slurm_jobs.json @@ -0,0 +1,77 @@ +{ + "accounting": { + "alternative_terminal_evidence": [ + "pilot-42169.out and pilot-42169.err", + "full-42171.out and full-42171.err", + "audit-42173.out and audit-42173.err", + "report.json status=pass", + "COMPLETE protocol/report hashes" + ], + "enabled": false, + "evidence": "Slurm accounting is disabled on this cluster. Terminal completion evidence therefore uses durable stdout/stderr logs, disappearance from squeue, the all-pass verifier artifacts, and the protocol-bound COMPLETE sentinel." + }, + "cluster": "t02-server", + "executable_commit": "9fe85a6317132983b48c12cbe3628b2da2945a19", + "jobs": [ + { + "dependency": null, + "evidence": "Pilot log completed without stderr and left protocol-bound resumable cell artifacts.", + "job_id": 42169, + "resources": { + "cpus_per_task": 1, + "gpus": 0, + "memory_mb": 2048, + "time_limit_minutes": 20 + }, + "stage": "representative resumable pilot", + "status": "COMPLETED", + "stderr": "pilot-42169.err", + "stdout": "pilot-42169.out" + }, + { + "dependency": { + "job_id": 42169, + "type": "submitted_after_successful_pilot" + }, + "evidence": "Full log completed without stderr; report.json records pass, 224/224 cells, and 40320 rows.", + "job_id": 42171, + "resources": { + "cpus_per_task": 1, + "gpus": 0, + "memory_mb": 2048, + "time_limit_minutes": 20 + }, + "stage": "full preregistered verification", + "status": "COMPLETED", + "stderr": "full-42171.err", + "stdout": "full-42171.out" + }, + { + "dependency": { + "job_id": 42171, + "type": "afterok" + }, + "evidence": "Audit log completed without stderr and verified COMPLETE plus artifact/test invariants.", + "job_id": 42173, + "resources": { + "cpus_per_task": 1, + "gpus": 0, + "memory_mb": 1024, + "time_limit_minutes": 10 + }, + "stage": "independent artifact audit", + "status": "COMPLETED", + "stderr": "audit-42173.err", + "stdout": "audit-42173.out" + } + ], + "protocol_id": "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20", + "schema_version": 1, + "terminal_result": { + "complete_sentinel": "COMPLETE", + "completed_cells": 224, + "status": "pass", + "total_cells": 224 + }, + "workflow": "pilot -> full -> afterok audit" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/twirl_checks.json b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/twirl_checks.json new file mode 100644 index 000000000..a2ae5acdd --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/formal_run_snapshot/twirl_checks.json @@ -0,0 +1,48 @@ +{ + "checks": { + "A": { + "hermitian": true, + "non_gaussian": true + }, + "B": { + "hermitian": true, + "non_gaussian": true + } + }, + "completed_at": "2026-07-29T18:20:29.610230+00:00", + "elapsed_seconds": 0.06245212099747732, + "families": { + "A": { + "alpha": 0.9992035741695577, + "beta": 0.8143689104604577, + "d2": 0.6699380114719741, + "gamma": 0.8137447675069036, + "gaussian_gap_d2_minus_beta2": 0.0067412891474211145, + "gaussian_gap_gamma_minus_alpha_beta": 2.4441482245785018e-05, + "gaussian_gap_zeta_minus_alpha_beta2": 0.006780660826633866, + "hermiticity_residual_fro": 1.3877787807814457e-17, + "vacuum": 1.0, + "zeta": 0.6694491961508628 + }, + "B": { + "alpha": 0.8188802914908884, + "beta": 0.9045305517997924, + "d2": 0.8174358310497376, + "gamma": 0.7399958577180219, + "gaussian_gap_d2_minus_beta2": -0.000739688089499202, + "gaussian_gap_gamma_minus_alpha_beta": -0.0007063842022061451, + "gaussian_gap_zeta_minus_alpha_beta2": -0.00053861145258427, + "hermiticity_residual_fro": 3.024593730708204e-17, + "vacuum": 1.0, + "zeta": 0.6694491961508628 + } + }, + "parameters": { + "epsilon": "1/100", + "kappa": "1/1000", + "tau": 0.1 + }, + "protocol_id": "ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20", + "schema_version": 1, + "status": "pass" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md b/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md index 01174c48f..e15cf7e04 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/main_theorem.md @@ -2,10 +2,10 @@ Date: 2026-07-29 -Status: analytic theorem draft under internal referee audit. The algebraic separation -from Wei 2024 is a vertex-support statement. Literature priority and exclusion of -alternative positive decompositions of the same many-body Hamiltonian are not -claimed. +Status: theorem package with exact certificates and a completed preregistered +implementation audit. The algebraic separation from Wei 2024 is a vertex-support +statement. Literature priority, independent specialist acceptance, and exclusion +of alternative positive decompositions of the same Hamiltonian are not claimed. ## 1. Executive theorem @@ -793,8 +793,10 @@ twirl is Hermitian. The Fock trace for every sequence is This is an engineered interacting Hamiltonian with an exact sign-free series expansion, not a standard auxiliary-field DQMC decomposition of a two-body Hubbard -Hamiltonian. No sampler, estimator, or scaling benchmark is claimed. Determinant -positivity holds at arbitrary word depth, not merely over a sampled range. +Hamiltonian. A direct continuous-time sampler specification and a four-site +ED/Poisson benchmark are documented in `physical_realization.md`; the formal run +passed all registered tolerances. Determinant positivity holds at arbitrary word +depth by proof, not merely over the sampled range. ## 8. Novelty boundary and publication position @@ -816,11 +818,12 @@ Current limitations are equally important: - Hamiltonian-level inequivalence to every alternative positive decomposition is not proved; - absence in a literature search cannot establish priority; -- a dedicated final-family harness and external proof review are still missing. +- the fixed-CAR separation still needs independent specialist proof review. -After those checks, the result may support a short mathematical-physics note or a -rigorous progress report on challenge issue 121. The current package is not yet a -publication-ready condensed-matter result. +The dedicated formal harness passed 224/224 cells, 40,320 core words, 336 direct +Fock checks, and the four-site physical benchmark; see `verification_record.md`. +The package now meets the explicit submission gates of challenge issue 121, but it +is not yet a publication-ready condensed-matter result. The separate Perron-plus-second-compound construction in `finite_density_extension.md` escapes the vacuum no-go locally, but its current diff --git a/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md b/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md index b32948266..c0c972c2d 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/novelty_audit.md @@ -187,8 +187,10 @@ would combine: - an engineered interacting Hermitian two-twirl realization; - a distinct Perron-compound theorem and exact no-go statements mapping its limits. -Before an external preprint claim, the package still needs a dedicated A/B harness, -independent expert checking of the fixed-CAR proof, a more systematic priority -audit, and a sharper physical target. A condensed-matter venue would additionally -need a scalable intercell-hopping construction, a nontrivial phase or critical -point, and an algorithmic benchmark. +The dedicated A/B harness is now complete: its protocol-bound run passed 224/224 +cells, 35,840 candidate words, 336 direct Fock checks, and the interacting four-site +benchmark; see `verification_record.md`. Before an external preprint claim, the +package still needs independent expert checking of the fixed-CAR proof, a more +systematic priority audit, and a sharper physical target. A condensed-matter venue +would additionally need a scalable finite-density construction, a nontrivial phase +or critical point, and an algorithmic performance study. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md b/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md index 5a16d2b17..2f636580e 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md +++ b/tracks/qmc/solutions/Genshin_Impact-121/physical_realization.md @@ -2,11 +2,10 @@ Date: 2026-07-29 -Status: analytic theorem and implementation specification. No new numerical -computation is used. The construction below is a complete, finite-temperature, -interacting lattice realization of the determinant-positive support in issue #121. -Finite-density ground-state physics is not a requirement of that issue and is not -claimed here. +Status: analytic theorem, implementation specification, and completed formal +four-site verification. The construction below is a finite-temperature interacting +lattice realization of the determinant-positive support in issue #121. +Finite-density ground-state physics is not a requirement and is not claimed. ## 1. Reviewable lattice theorem @@ -226,24 +225,31 @@ is the k-by-k determinant This identity supplies a direct unit test for an optimized implementation against the full n-by-n determinant. -### Preregistered no-run smoke benchmark +### Formal four-site benchmark -The first implementation benchmark is fixed to the previously approved convention: +The preregistered fixture uses a four-site open chain with one spinless orbital per +site, overlapping triples (1,2,3) and (2,3,4), epsilon=1/100, kappa=1/1000, +s=1/10, g_(Delta,A)=g_(Delta,B)=1/4, mu=0, and beta in {1/4,1/2,1,2}. +The exact 16-dimensional shifted partition functions were respectively -- four-site open chain with one spinless orbital per site; -- overlapping ordered triples Δ₁=(1,2,3) and Δ₂=(2,3,4), with no wraparound triple; -- ε=0.01, κ=0.001, and fixed vertex amplitude s=0.1 (called τ=0.1 in - the run configuration); -- g_(Δ,A)=g_(Δ,B)=0.25 for both triples; -- μ=0 and β∈{0.25,0.5,1,2}. + 15.316353408389649, + 14.669103080374773, + 13.475392271305402, + 11.439331388535233. -This paragraph records inputs only. No chain was sampled and no benchmark number is -claimed in this analytic note. Before a future run, the random seed, warmup, -measurement count, stabilization interval, and error analysis must also be frozen. -For this 16-dimensional Fock space, a future implementation can compare Z, energy, -density, and selected correlators against exact diagonalization while also checking -that every accepted determinant sign is nonnegative. +With 4096 registered Poisson strings per beta, absolute errors were respectively + 0.02808869231030009, + 0.03512955219626335, + 0.02453568366674652, + 0.0461209100548885, + +all below their preregistered allowances. All 16,384 sampled determinants were +nonnegative; the overall minimum was 4.330910819303328. The shifted Hamiltonian +minimum eigenvalue was 4.440892098500626e-16 and its Frobenius hermiticity residual +was 1.7216638914240724e-17. Exact diagonalization, deterministic series, direct +Fock/determinant comparisons, and the normalized Poisson estimator all passed. +The immutable hashes and full artifact path are in `verification_record.md`. ## 4. Finite-temperature physical meaning and scope The model (1) is a short-range spinless-fermion lattice Hamiltonian. On overlapping diff --git a/tracks/qmc/solutions/Genshin_Impact-121/verification_record.md b/tracks/qmc/solutions/Genshin_Impact-121/verification_record.md new file mode 100644 index 000000000..bd38f701e --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/verification_record.md @@ -0,0 +1,91 @@ +# Issue #121 formal verification record + +This tracked record summarizes the all-pass formal run without committing the 9.6 MB row-level sample table. + +## Identity and provenance + +| Field | Value | +|---|---| +| Executable commit | [`9fe85a6317132983b48c12cbe3628b2da2945a19`](https://github.com/QuantumBFS/quantum.harness/commit/9fe85a6317132983b48c12cbe3628b2da2945a19) | +| Pull request | [#261](https://github.com/QuantumBFS/quantum.harness/pull/261) | +| Protocol ID | `ae54430bfb17790c197fabed523138ed6ba3a632881978b5665367e1517a2e20` | +| Remote artifact path | `tracks/qmc/results/Genshin_Impact-121/20260730-021845-9fe85a6/` | +| Challenge report | `tracks/qmc/results/Genshin_Impact-121/20260730-021845-9fe85a6/challenge-report/report.html` | +| Slurm metadata | `tracks/qmc/results/Genshin_Impact-121/20260730-021845-9fe85a6/slurm_jobs.json` | +| Tracked compact snapshot | [`formal_run_snapshot/`](formal_run_snapshot/) | +| Pilot / full / audit Slurm jobs | `42169 / 42171 / 42173` | +| Formal status | `pass`; 224/224 cells; COMPLETE present | + +The run used Python 3.13.9, NumPy 2.5.1, SciPy 1.18.0, and mpmath 1.4.1 on a `t02-server` Slurm CPU job with 1 CPU, 2048 MB, no GPU, and a 20-minute limit. Base seed: `1212026`. + +## Content hashes + +| Object | SHA256 | +|---|---| +| Source manifest `issue121_full_run.json` | `17493ccc50f7979eff41b2308f6946dc48f1830036e0447b75db8b4f0ea2bbb1` | +| Canonical manifest protocol hash | `7a04a1e9a4293e85f47ddf4901ae8b20e7b034d7ee50b9d3e8317f805b2f4b12` | +| Materialized `manifest.json` | `d2fb2be0d2cb179ecf77036683c1c3d50283a28bcfa0b458859d910751f2016e` | +| Verifier `issue121_verification.py` | `e566f1a0f300d5201a354cfcd3c45b022631ac3175d98af3fa3b898c954993c4` | +| Independent support `sign_problem_hunter.py` | `fea156818fafdfc9635fb9e7c797470aa34758d82a24e69b6dd3b62d2e04f780` | +| `run.json` | `68336dcafe9f5cf130ddb41d983c9bc83dede8dfcdb9eddeb29e3be9bf47521f` | +| `report.json` | `52c8fb5419d2fdf463b4a56643f63de216aa45ac73b9fe46d149da9eb27390be` | +| `report.md` | `727f5f0c54cc4b277a19503f5c2f865249c09f317c5251dc8c2b8f579c4fb8a9` | +| `samples.csv` (40,320 rows; not tracked) | `27a81a5400780b1851f031a725926cf964da7b0b97e27a4b5acde7fd599711a7` | +| `exact_certificates.json` | `4276fd469722894796cd4152c2f11f8cb3b977ee8dcc867062a48c57dec79034` | +| `twirl_checks.json` | `1234ee7b8e419b404c0cd667ea1cce7d26a12d72bff4a4a4676ef33a0da2b56a` | +| `physical_benchmark.json` | `5b9029d962c6db0b3768a93d5e9512bcd607883c9cf052d8dbd7c2ecdea6c75a` | +| `COMPLETE` | `7e2499c8b8a43db184444f3d64926c2663ef8d199f2b59259d9f173c31c4b200` | + +The COMPLETE payload independently records the same protocol and the report JSON/Markdown hashes. The tracked [`formal_run_snapshot/`](formal_run_snapshot/) carries the materialized manifest, compact reports, and certificates unchanged; the source manifest remains [`issue121_full_run.json`](issue121_full_run.json). The 9.6 MB `samples.csv` and per-cell artifacts remain only in the durable remote run directory; their row count and SHA256 are recorded above. + +## Preregistered workload and classifications + +| Stage | Cells | Random words | Result | +|---|---:|---:|---| +| A/B candidate: 4 parameter regimes x d=3,4,6,8,12 x depths 1,2,4,8,16,32,64 | 140 | 35,840 | 35,840 positive; 0 negative or unexpected inconclusive | +| Split-orthogonal O(n,n), n=1,...,4 | 28 | 1,792 | pass | +| Fixed-metric Wei semigroup, n=1,...,4 | 28 | 1,792 | pass | +| Four O(1,1) components | 28 | 896 | pass; 448 expected exact-zero mixed-component controls | +| Core total | 224 | 40,320 | pass | +| Four-site physical Poisson strings, 4,096 per beta | - | 16,384 | all nonnegative | +| Total randomized words including physical | - | 56,704 | pass | + +The candidate regimes were center, near the proved boundary, kappa approaching zero, and Dirichlet-random points in the open triangle. The run performed 672 high-precision rebuilds. All 448 raw inconclusive determinant classifications were preregistered exact-zero O(1,1) controls; unexpected inconclusive count was zero. + +The independent direct-Fock oracle performed 336 checks through d=8. Maximum absolute determinant/Fock error was `5.400124791776761e-13`. Exact Fraction certificates, the four twirl interaction/non-Gaussian certificates, and all known signed anchors passed. The regression suite passed 39 tests. + +## Four-site interacting benchmark + +Setup: spinless number-conserving Fock space, four open sites, overlapping triples (1,2,3) and (2,3,4), epsilon=1/100, kappa=1/1000, vertex strength s=1/10, g_A=g_B=1/4, chemical potential mu=0. + +| beta | Exact ED Z_bar | Poisson absolute error | Registered allowance | +|---:|---:|---:|---:| +| 1/4 | 15.316353408389649 | 0.02808869231030009 | 0.1727116598757571 | +| 1/2 | 14.669103080374773 | 0.03512955219626335 | 0.2233055507021328 | +| 1 | 13.475392271305402 | 0.02453568366674652 | 0.2857508015621753 | +| 2 | 11.439331388535233 | 0.0461209100548885 | 0.33059523654337436 | + +All 16,384 sampled physical configurations were nonnegative. The overall minimum sampled determinant weight was `4.330910819303328`. The shifted Hamiltonian had minimum eigenvalue `4.440892098500626e-16` and Frobenius hermiticity residual `1.7216638914240724e-17`. Exact 16-dimensional diagonalization, deterministic shifted-series reconstruction, determinant/Fock equality, and the normalized positive Poisson estimator all passed their registered tolerances. + +## Reproduce + +From the repository root: + +```bash +python -m pip install -r tracks/qmc/solutions/Genshin_Impact-121/requirements.txt +python -m pytest -q \ + tracks/qmc/solutions/Genshin_Impact-121/test_sign_problem_hunter.py \ + tracks/qmc/solutions/Genshin_Impact-121/test_issue121_verification.py + +output=tracks/qmc/results/Genshin_Impact-121/REPRODUCE-$(date -u +%Y%m%d-%H%M%S) +python tracks/qmc/solutions/Genshin_Impact-121/issue121_verification.py \ + --manifest tracks/qmc/solutions/Genshin_Impact-121/issue121_full_run.json \ + --output "$output" +sha256sum "$output"/{manifest.json,report.json,report.md,samples.csv,COMPLETE} +``` + +For the full run on `t02-server`, submit the runner as a 1-CPU, 2-GB, no-GPU Slurm job. The output is atomic and resumable, and COMPLETE is written only after all cells and auxiliary stages pass. + +## Claim boundary + +This record verifies reproducibility of the preregistered implementation checks. Random sampling is not the arbitrary-depth proof; the common-polyhedral-norm theorem supplies that proof. Passing does not prove literature priority, exclude ancillas or every alternative Hubbard-Stratonovich/fermion-bag/Jordan-Wigner/stoquastic representation, establish a finite-density sign-free phase, guarantee efficient autocorrelation, imply publication readiness, or constitute maintainer acceptance of issue #121. From 886a082963429f3f62deb9e6090352a58a05b89a Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 11:52:14 +0800 Subject: [PATCH 06/13] qmc: preregister large triangular-lattice extension --- .../solutions/Genshin_Impact-121/conftest.py | 5 + .../large_lattice_benchmark_plan.md | 82 ++ .../Genshin_Impact-121/large_lattice_ctqmc.py | 695 +++++++++++ .../Genshin_Impact-121/large_lattice_ed.py | 626 ++++++++++ .../large_lattice_extension.md | 641 ++++++++++ .../large_lattice_protocol.py | 752 ++++++++++++ .../Genshin_Impact-121/large_lattice_run.json | 248 ++++ .../test_large_lattice_ctqmc.py | 1090 +++++++++++++++++ .../test_large_lattice_protocol.py | 319 +++++ 9 files changed, 4458 insertions(+) create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/conftest.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_benchmark_plan.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_extension.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py diff --git a/tracks/qmc/solutions/Genshin_Impact-121/conftest.py b/tracks/qmc/solutions/Genshin_Impact-121/conftest.py new file mode 100644 index 000000000..5377e1d9a --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/conftest.py @@ -0,0 +1,5 @@ +def pytest_configure(config) -> None: + config.addinivalue_line( + "markers", + "slow: marks stochastic end-to-end tests excluded from the default suite", + ) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_benchmark_plan.md b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_benchmark_plan.md new file mode 100644 index 000000000..68c716cde --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_benchmark_plan.md @@ -0,0 +1,82 @@ +# Preregistered large-lattice benchmark plan + +Status: proposed. No compute is authorized until the user ratifies this setup +once. Resources and final sweep counts remain proposed/TBD based on the pilot; +no Slurm partition is assumed. + +## Fixed setup for ratification + +- Periodic L by L triangular lattice with all elementary up and down triangles. +- Spinless fermions, one orbital per site, number conserving. +- epsilon=1/100, kappa=1/50, s=1/4, g_A=g_B=1/4, and mu=0. +- L=4,6,8,12,16, hence N=16,36,64,144,256. +- beta in {1/2,1,2,4}. +- Four chains per cell: two cold at order zero and two hot at round(beta*N). +- Fixed seed = 121000000 + 10000*L + 10*beta_index + chain_id, with beta + indices 0,1,2,3 for 1/2,1,2,4. Failed chains are never reseeded. + +Ordered CT times are analytically integrated into beta^m/m!, so hot starts do +not draw explicit times. At m=round(beta*N), resolved word labels are drawn +independently from q(a)=lambda_a/G_0: uniform among all 2*N triangles, equal A/B +probability, and uniform S3 labels at the frozen equal couplings. The RNG is +NumPy PCG64DXSM; its exact package version and full state are frozen in the +snapshot. + +## Analytic numerical bound + +For fixed s>0, let U be the sites touched by a word. Taking each row at the last +local factor that touches it gives + + ||T_U||_infinity <= q = exp(-kappa*s) < 1. + +Here q=exp(-1/200), approximately 0.995012 (analytic). Thus every configuration +has strictly positive determinant weight, and + + ||(I+T_U)^(-1)||_infinity <= 1/(1-q), + cond_infinity(I+T_U) <= (1+q)/(1-q), approximately 400. + +Consequently a computed zero or negative weight is a hard numerical or +implementation failure, not an allowed exact-zero boundary case. + +## Gates + +1. G0 algebra tests: A/B and S3 embeddings, contraction and inverse bounds, + Fock trace/determinant identities, and rank-3 versus rebuild ratios. +2. G1 N<=9 ED: isolated N=3 and periodic N=4,9 fixtures at every beta; compare + energy, density, compressibility, equal-time Green function, and density + structure factor within max(5*MCSE,1e-10). +3. G2 pilot: (L,beta)=(4,1/2),(8,2),(12,4); estimate tau_int, acceptance, + update accuracy, timing, memory, sweep counts, and full-run resources. +4. G3 full: all 20 cells, four fixed chains; warmup at least + 50*max_tau_int and equal preregistered extensions for all chains. +5. G4 independent audit: recompute snapshot weights and observables, verify + chain provenance, and rebuild scaling tables from raw logs. + +Each gate requires a PASS from its predecessor. Cluster stages require durable +outputs, completion sentinels, and afterok dependencies. Inspect live sinfo, +squeue, and node allocation before submission. + +## Metrics and stop rules + +Record acceptance, expansion order, fast/rebuild error and speed, inverse +residual, sign and zero-weight counts, R-hat, ESS, tau_int, proposal/sweep time, +peak memory, energy, density, compressibility, G(r), and S_n(q). + +- Fast/rebuild error <=1e-9; inverse residual <=1e-8. +- Negative and zero weight counts must both equal zero. +- Pilot acceptance target [0.2,0.7]; full insertion/deletion hard range + [0.1,0.9]. +- R-hat <=1.01, bulk ESS >=1000, tail ESS >=400. +- Withhold scalability if rank-3 speedup is not above 2 by N=144, update time + scales worse than N^2.7, or memory worse than N^2.5 after excluding N=16. +- Do not start L>12 without a stable, faster rank-3 pilot path. + +A nonpositive weight, ED discrepancy, update mismatch, or unstable residual is a +hard stop. Hot/cold disagreement or failed R-hat/ESS at the frozen extension cap +makes a cell inconclusive. OOM, timeout, or missing durable completion evidence +is failure. Never drop/reseed a chain or retune physics after inspecting full +results. + +At mu=0 this positive-semidefinite construction has a low-temperature vacuum +ground state. This benchmark does not solve the open itinerant finite-density +problem. A pass supports only the fixed mu=0 correctness and scaling claim. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py new file mode 100644 index 000000000..4df294941 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py @@ -0,0 +1,695 @@ +#!/usr/bin/env python3 +"""Determinant-only CTQMC prototype for the triangular-lattice A/B model. + +No 2**N Fock matrix is constructed. A resolved event stores a triangle id and +one of 12 local 3x3 templates (B,B^{-1}). The chronological word +(a_1,...,a_m) means T=B_m...B_1. Endpoint insertion is T'=BT. + +With D=B-I, C=T(I+T)^{-1}=I-Q, and Q=(I+T)^{-1}, + + K=I_3+D E^T C E, + det(I+BT)/det(I+T)=det K, + Q'=Q-Q E K^{-1}D E^T C. + +K^{-1} is applied with solve, never formed. Deletion uses B^{-1}. Fixed +p_insert=p_delete leaves an attempted deletion at m=0 as a self-loop. Equal +left/right cyclic-rotation probabilities give unit acceptance. + +For a nonempty word, let U be its touched sites and q=exp(-kappa*s). Choosing +the last factor touching each row gives T=I_(U^c) direct-sum T_U with +||T_U||_inf<=q<1. Hence det(I+T)>0. With fugacity z, the same proof is strict +for z*q<1, i.e. muNone: + super().__init__(message);self.kind=kind + +@dataclass(frozen=True) +class Triangle: + triangle_id:int + sites:Tuple[int,int,int] + orientation:str + anchor:Tuple[int,int] + +@dataclass(frozen=True) +class TriangularGeometry: + Lx:int + Ly:int + coordinates:np.ndarray + triangles:Tuple[Triangle,...] + @property + def n_sites(self)->int: return self.Lx*self.Ly + @property + def n_triangles(self)->int: return len(self.triangles) + +@dataclass(frozen=True) +class LocalVertex: + vertex_id:int + family:str + permutation:Tuple[int,int,int] + block:np.ndarray + block_inv:np.ndarray + activity:float + +@dataclass(frozen=True) +class Event: + triangle_id:int + vertex_id:int + def to_json(self)->List[int]: return [self.triangle_id,self.vertex_id] + @staticmethod + def from_json(value:Sequence[int])->"Event": + if len(value)!=2: raise ManifestError("event must be [triangle_id,vertex_id]") + return Event(int(value[0]),int(value[1])) + +@dataclass +class DenseFactors: + T:np.ndarray + Q:np.ndarray + logdet:float + inverse_residual_inf:float # NaN after unchecked fast updates; rebuilt exactly + +@dataclass +class LowRankProposal: + T_new:Optional[np.ndarray] + Q_new:Optional[np.ndarray] + logdet_new:float + log_det_ratio:float + condition:float + local_solve_residual_inf:float + needs_rebuild:bool=False + zero_weight:bool=False + used_dense_fallback:bool=False + +def _real(value:Any,name:str)->float: + try: result=float(Fraction(value)) if isinstance(value,str) else float(value) + except (TypeError,ValueError,ZeroDivisionError) as exc: raise ManifestError(f"invalid {name}") from exc + if not math.isfinite(result): raise ManifestError(f"{name} must be finite") + return result + +def _integer(obj:Mapping[str,Any],key:str,lower:int)->int: + value=obj.get(key) + if isinstance(value,bool) or not isinstance(value,int) or value= {lower}") + return value + +def build_triangular_geometry(Lx:int,Ly:int)->TriangularGeometry: + """Periodic up/down elementary triangles on an Lx by Ly torus.""" + if Lx<2 or Ly<2: raise ManifestError("Lx,Ly must be >=2") + site=lambda x,y:(x%Lx)*Ly+(y%Ly) + coords=np.empty((Lx*Ly,2),dtype=float); triangles:List[Triangle]=[] + for x in range(Lx): + for y in range(Ly): + coords[site(x,y)]=(x,y) + r,ex,ey,exy=site(x,y),site(x+1,y),site(x,y+1),site(x+1,y+1) + triangles.append(Triangle(len(triangles),(r,ex,ey),"up",(x,y))) + triangles.append(Triangle(len(triangles),(exy,ex,ey),"down",(x,y))) + return TriangularGeometry(Lx,Ly,coords,tuple(triangles)) + +def build_vertex_catalog(epsilon:float,kappa:float,s:float,g_A:float,g_B:float)->List[LocalVertex]: + """Exactly 12 templates: A/B times all six S3 permutations.""" + if min(epsilon,kappa,s)<=0 or min(g_A,g_B)<0 or g_A+g_B<=0: + raise ManifestError("invalid positive model parameters") + A=np.array([[-1-epsilon-kappa,1,-epsilon],[0,-1-kappa,1],[2,0,-2-kappa]],dtype=float) + S=np.diag([1.0,1.0,-1.0]); result:List[LocalVertex]=[] + for family,generator,coupling in (("A",A,g_A),("B",S@A@S,g_B)): + for perm in itertools.permutations(range(3)): + P=np.eye(3)[list(perm)]; X=P@generator@P.T + result.append(LocalVertex(len(result),family,tuple(perm),expm(s*X),expm(-s*X),coupling/6)) + assert len(result)==12 + return result + +def _left(M:np.ndarray,sites:Sequence[int],B:np.ndarray)->np.ndarray: + out=M.copy(); idx=list(sites); out[idx,:]=B@M[idx,:]; return out +def _right(M:np.ndarray,sites:Sequence[int],B:np.ndarray)->np.ndarray: + out=M.copy(); idx=list(sites); out[:,idx]=M[:,idx]@B; return out + +def structured_product(n_sites:int,triangles:Sequence[Triangle], + catalog:Sequence[LocalVertex],word:Sequence[Event])->np.ndarray: + """O(mN) rebuild of T=B_m...B_1 by local row updates.""" + T=np.eye(n_sites) + for event in word: + tri,v=triangles[event.triangle_id],catalog[event.vertex_id] + idx=list(tri.sites) + T[idx,:]=v.block@T[idx,:] + return T + +def inverse_residual_inf(T:np.ndarray,Q:np.ndarray)->float: + I=np.eye(T.shape[0]);A=I+T + return float(np.linalg.norm(A@Q-I,np.inf)/max(1.0,np.linalg.norm(A,np.inf))) + +def factor_dense(T:np.ndarray)->DenseFactors: + I=np.eye(T.shape[0]);A=I+T;sign,logdet=np.linalg.slogdet(A) + if sign==0: + raise DeterminantFailure("zero","current det(I+T) is zero") + if sign<0: + raise DeterminantFailure("negative","current det(I+T) is negative") + Q=np.linalg.solve(A,I) + return DenseFactors(T,Q,float(logdet),inverse_residual_inf(T,Q)) + +def low_rank_left_proposal(factors:DenseFactors,sites:Sequence[int],block:np.ndarray, + condition_max:float=1e12)->LowRankProposal: + """Rank-3 proposal for T'=BT using C=I-Q and a 3x3 solve.""" + idx=list(sites); D=block-np.eye(3) + Crows=-factors.Q[idx,:].copy(); Crows[np.arange(3),idx]+=1.0 + QE=factors.Q[:,idx]; K=np.eye(3)+D@Crows[:,idx] + sign,logratio=np.linalg.slogdet(K); condition=float(np.linalg.cond(K)) + if sign<=0 or not math.isfinite(condition) or condition>condition_max: + return LowRankProposal(None,None,math.nan,math.nan,condition,math.inf,needs_rebuild=True) + rhs=D@Crows; solved=np.linalg.solve(K,rhs) + residual=float(np.linalg.norm(K@solved-rhs,np.inf)/max(1.0,np.linalg.norm(rhs,np.inf))) + return LowRankProposal(_left(factors.T,idx,block),factors.Q-QE@solved, + factors.logdet+float(logratio),float(logratio),condition,residual) + +def _dense_left_proposal(factors:DenseFactors,sites:Sequence[int],block:np.ndarray)->LowRankProposal: + T=_left(factors.T,sites,block); A=np.eye(T.shape[0])+T + sign,logdet=np.linalg.slogdet(A) + if sign==0: + raise DeterminantFailure( + "zero","computed zero candidate contradicts the strict support bound") + if sign<0: + raise DeterminantFailure("negative","dense candidate determinant is negative") + Q=np.linalg.solve(A,np.eye(T.shape[0])) + residual=inverse_residual_inf(T,Q) + return LowRankProposal(T,Q,float(logdet),float(logdet-factors.logdet), + float(np.linalg.cond(A)),residual,used_dense_fallback=True) + +def apply_low_rank_proposal(factors:DenseFactors,proposal:LowRankProposal)->DenseFactors: + if proposal.needs_rebuild or proposal.zero_weight: raise ValueError("unresolved proposal") + assert proposal.T_new is not None and proposal.Q_new is not None + residual=proposal.local_solve_residual_inf if proposal.used_dense_fallback else math.nan + return DenseFactors(proposal.T_new,proposal.Q_new,proposal.logdet_new,residual) + +def rotate_left_factor_to_right(factors:DenseFactors,event:Event, + triangles:Sequence[Triangle], + catalog:Sequence[LocalVertex])->DenseFactors: + """Move product-left B_m to right: T'=B_m^-1 T B_m.""" + tri,v=triangles[event.triangle_id],catalog[event.vertex_id] + T=_right(_left(factors.T,tri.sites,v.block_inv),tri.sites,v.block) + Q=_right(_left(factors.Q,tri.sites,v.block_inv),tri.sites,v.block) + return DenseFactors(T,Q,factors.logdet,factors.inverse_residual_inf) + +def rotate_right_factor_to_left(factors:DenseFactors,event:Event, + triangles:Sequence[Triangle], + catalog:Sequence[LocalVertex])->DenseFactors: + """Move product-right B_1 to left: T'=B_1 T B_1^-1.""" + tri,v=triangles[event.triangle_id],catalog[event.vertex_id] + T=_right(_left(factors.T,tri.sites,v.block),tri.sites,v.block_inv) + Q=_right(_left(factors.Q,tri.sites,v.block),tri.sites,v.block_inv) + return DenseFactors(T,Q,factors.logdet,factors.inverse_residual_inf) + +def log_accept_insert(beta:float,activity:float,order_before:int,log_det_ratio:float, + p_insert:float,p_delete:float,p_label:float)->float: + """min(0,log[(beta*lambda/(m+1))*r*pdel/(pins*plabel)]).""" + return min(0.0,math.log(beta)+math.log(activity)-math.log(order_before+1) + +log_det_ratio+math.log(p_delete)-math.log(p_insert)-math.log(p_label)) + +def log_accept_delete(beta:float,activity:float,order_before:int,log_det_ratio:float, + p_insert:float,p_delete:float,p_label:float)->float: + """min(0,log[(m/(beta*lambda))*r*pins*plabel/pdel]).""" + if order_before<1: raise ValueError("delete requires m>=1") + return min(0.0,math.log(order_before)-math.log(beta)-math.log(activity) + +log_det_ratio+math.log(p_insert)+math.log(p_label)-math.log(p_delete)) + +def measure_configuration(factors:DenseFactors,geometry:TriangularGeometry,beta:float, + G0:float,order:int,momenta:Sequence[Tuple[int,int]], + displacements:Sequence[Tuple[int,int]]=())->Mapping[str,Any]: + """Order, energy, N/N^2, and momentum/real-space equal-time correlators.""" + N=geometry.n_sites; R=np.eye(N)-factors.Q; green=R.T + density=np.diag(green).copy() + density_pair=np.outer(density,density)-green*green.T + np.fill_diagonal(density_pair,density) + number,number2=float(density.sum()),float(density_pair.sum()) + out:Dict[str,Any]={"order":float(order),"energy_density":float((G0-order/beta)/N), + "particle_number":number,"particle_number_squared":number2, + "particle_density":number/N,"particle_density_squared":number2/(N*N), + "momenta":{},"real_space_green":{}} + x,y=geometry.coordinates[:,0],geometry.coordinates[:,1] + for kx,ky in momenta: + phase=np.exp(2j*math.pi*(kx*x/geometry.Lx+ky*y/geometry.Ly)) + one=complex(np.vdot(phase,green@phase)/N) + den=complex(np.vdot(phase,density_pair@phase)/N) + rho=complex(np.vdot(phase,density)/math.sqrt(N)) + out["momenta"][f"{kx},{ky}"]={"one_body":[one.real,one.imag], + "density_raw":[den.real,den.imag],"density_mode":[rho.real,rho.imag]} + for dx,dy in displacements: + total=0.0 + for sx in range(geometry.Lx): + for sy in range(geometry.Ly): + i=sx*geometry.Ly+sy + j=((sx+dx)%geometry.Lx)*geometry.Ly+(sy+dy)%geometry.Ly + total+=float(green[i,j]) + out["real_space_green"][f"{dx},{dy}"]=[total/N,0.0] + return out + +class ObservableAccumulator: + KEYS=("order","energy_density","particle_number","particle_number_squared", + "particle_density","particle_density_squared") + def __init__(self)->None: + self.count=0 + self.scalar={k:{"sum":0.0,"sum_sq":0.0} for k in self.KEYS} + self.primary_traces={k:[] for k in self.KEYS} + self.momentum:Dict[str,Any]={} + self.real_space:Dict[str,Any]={} + @staticmethod + def _add_complex(target:Dict[str,Any],key:str,name:str,pair:Sequence[float])->None: + slot=target.setdefault(key,{}).setdefault( + name,{"sum_real":0.0,"sum_imag":0.0,"sum_abs_sq":0.0}) + real,imag=map(float,pair) + slot["sum_real"]+=real;slot["sum_imag"]+=imag + slot["sum_abs_sq"]+=real*real+imag*imag + def add(self,obs:Mapping[str,Any])->None: + self.count+=1 + for k in self.KEYS: + value=float(obs[k]);self.scalar[k]["sum"]+=value + self.scalar[k]["sum_sq"]+=value*value + self.primary_traces[k].append(value) + for momentum,values in obs["momenta"].items(): + for name,pair in values.items(): + self._add_complex(self.momentum,momentum,name,pair) + for displacement,pair in obs.get("real_space_green",{}).items(): + self._add_complex(self.real_space,displacement,"one_body",pair) + def state(self)->Mapping[str,Any]: + return {"count":self.count,"scalar":self.scalar, + "primary_traces":self.primary_traces, + "momentum":self.momentum,"real_space_green":self.real_space} + @classmethod + def from_state(cls,state:Mapping[str,Any])->"ObservableAccumulator": + obj=cls();obj.count=int(state.get("count",0)) + obj.scalar=state.get("scalar",obj.scalar) + obj.primary_traces=state.get("primary_traces",obj.primary_traces) + obj.momentum=state.get("momentum",{}) + obj.real_space=state.get("real_space_green",{}) + return obj + @staticmethod + def _complex_summary(values:Mapping[str,Any],count:int)->Mapping[str,Any]: + result:Dict[str,Any]={} + for key,components in values.items(): + result[key]={} + for name,raw in components.items(): + mean=[raw["sum_real"]/count,raw["sum_imag"]/count] + var=max(0.0,raw["sum_abs_sq"]/count-mean[0]**2-mean[1]**2) + result[key][name]={"mean":mean, + "naive_stderr_abs":math.sqrt(var/count)} + return result + def summary(self,beta:float,n_sites:int)->Mapping[str,Any]: + if not self.count: + return {"count":0,"compressibility":None, + "primary_traces":self.primary_traces} + scalar={} + for k,raw in self.scalar.items(): + mean=raw["sum"]/self.count + var=max(0.0,raw["sum_sq"]/self.count-mean*mean) + scalar[k]={"mean":mean,"naive_stderr":math.sqrt(var/self.count)} + momentum=self._complex_summary(self.momentum,self.count) + real_space=self._complex_summary(self.real_space,self.count) + for key in momentum: + if "density_raw" in momentum[key] and "density_mode" in momentum[key]: + raw=momentum[key]["density_raw"]["mean"] + mode=momentum[key]["density_mode"]["mean"] + momentum[key]["density_connected_from_means"]=[ + raw[0]-mode[0]**2-mode[1]**2,raw[1]] + mean_n=scalar["particle_number"]["mean"] + mean_n2=scalar["particle_number_squared"]["mean"] + compressibility=beta*(mean_n2-mean_n*mean_n)/n_sites + return {"count":self.count,"scalar":scalar, + "compressibility":compressibility, + "primary_traces":self.primary_traces, + "momentum":momentum,"real_space_green":real_space, + "error_note":"naive iid errors; use primary_traces for tau_int/ESS/R-hat"} + +def linux_max_rss_kb()->Optional[int]: + if resource is None or not sys.platform.startswith("linux"): + return None + try: + value=int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) + except (AttributeError,OSError,ValueError): + return None + return value if value>=0 else None + +def atomic_write_json(path:Path,payload:Mapping[str,Any])->None: + path.parent.mkdir(parents=True,exist_ok=True) + fd,tmp=tempfile.mkstemp(prefix="."+path.name+".",suffix=".tmp",dir=path.parent) + try: + with os.fdopen(fd,"w",encoding="utf-8") as handle: + json.dump(payload,handle,indent=2,sort_keys=True,allow_nan=False) + handle.write("\n") + handle.flush(); os.fsync(handle.fileno()) + os.replace(tmp,path) + finally: + if os.path.exists(tmp):os.unlink(tmp) + +class CTQMC: + """Cyclic-word sampler; resume rebuilds dense factors from the word.""" + def __init__(self,geometry:TriangularGeometry,catalog:Sequence[LocalVertex], + model:Mapping[str,float],mc:Mapping[str,Any], + momenta:Sequence[Tuple[int,int]], + displacements:Sequence[Tuple[int,int]],output_dir:Path, + manifest_sha256:str)->None: + self.geometry=geometry; self.catalog=list(catalog); self.model=dict(model) + self.beta=model["beta"]; self.output_dir=Path(output_dir) + self.manifest_sha256=manifest_sha256; self.steps=int(mc["steps"]) + self.warmup=int(mc["warmup"]); self.measure_every=int(mc["measure_every"]) + self.checkpoint_every=int(mc["checkpoint_every"]); self.rebuild_every=int(mc["rebuild_every"]) + self.condition_max=float(mc.get("woodbury_condition_max",1e12)) + self.moves=dict(mc["move_probabilities"]);self.momenta=tuple(momenta) + self.displacements=tuple(displacements) + self.initialization=dict(mc["initialization"]) + self.rng=np.random.Generator(np.random.PCG64DXSM(int(mc["seed"]))) + self.word:Deque[Event]=deque();self.completed_steps=0 + self.accumulator=ObservableAccumulator() + self.G0=geometry.n_triangles*(model["g_A"]+model["g_B"]) + self.active=[v.vertex_id for v in catalog if v.activity>0] + weights=np.array([catalog[i].activity for i in self.active]) + self.template_probabilities=weights/weights.sum() + self.counters={"moves":{k:{"attempted":0,"accepted":0} for k in self.moves}, + "rank3_updates_accepted":0,"low_rank_rebuild_gates":0, + "dense_candidate_fallbacks":0,"zero_weight_rejections":0,"rebuilds":0, + "determinant_failures":{"zero":0,"negative":0}} + self.rebuild_diagnostics:List[Mapping[str,Any]]=[];self.moves_since_rebuild=0 + if self.initialization["mode"]=="hot": + for _ in range(self.initialization["initial_order"]): + event,_=self._sample_event();self.word.append(event) + initial_T=structured_product(self.geometry.n_sites,self.geometry.triangles, + self.catalog,list(self.word)) + self.factors=factor_dense(initial_T) + self._record("initial-"+self.initialization["mode"], + self.factors.inverse_residual_inf) + @classmethod + def from_manifest(cls,manifest:Mapping[str,Any],output_dir:Path, + manifest_sha256:str="unbound-in-memory")->"CTQMC": + if int(manifest.get("schema_version",-1))!=SCHEMA_VERSION: + raise ManifestError("schema_version must be 1") + lat,mod,mc=manifest["lattice"],manifest["model"],manifest["monte_carlo"] + geometry=build_triangular_geometry(_integer(lat,"Lx",2),_integer(lat,"Ly",2)) + model={k:_real(mod[k],"model."+k) for k in + ("epsilon","kappa","vertex_strength","g_A","g_B","beta")} + if model["beta"]<=0:raise ManifestError("beta must be positive") + catalog=build_vertex_catalog(model["epsilon"],model["kappa"],model["vertex_strength"], + model["g_A"],model["g_B"]) + lower={"steps":1,"warmup":0,"measure_every":1,"checkpoint_every":1,"rebuild_every":1,"seed":0} + parsed={k:_integer(mc,k,v) for k,v in lower.items()} + if parsed["warmup"]>=parsed["steps"]:raise ManifestError("warmup>=steps") + parsed["woodbury_condition_max"]=_real(mc.get("woodbury_condition_max",1e12),"condition") + default={"insert":.35,"delete":.35,"rotate_left_to_right":.15,"rotate_right_to_left":.15} + supplied=mc.get("move_probabilities",default) + moves={k:_real(supplied.get(k),"move."+k) for k in default} + if min(moves.values())<=0 or abs(sum(moves.values())-1)>1e-12: + raise ManifestError("move probabilities must be positive and sum to one") + if abs(moves["insert"]-moves["delete"])>1e-15: + raise ManifestError("prototype requires fixed p_insert=p_delete") + if abs(moves["rotate_left_to_right"]-moves["rotate_right_to_left"])>1e-15: + raise ManifestError("cyclic reverse probabilities must match") + parsed["move_probabilities"]=moves + initialization=mc.get("initialization",{"mode":"cold","initial_order":0}) + if not isinstance(initialization,Mapping): + raise ManifestError("monte_carlo.initialization must be an object") + mode=initialization.get("mode","cold") + if mode not in ("cold","hot"): + raise ManifestError("initialization.mode must be cold or hot") + initial_order=_integer(initialization,"initial_order",0) + if mode=="cold" and initial_order!=0: + raise ManifestError("cold initialization requires initial_order=0") + if mode=="hot" and initial_order<1: + raise ManifestError("hot initialization requires initial_order>=1") + parsed["initialization"]={"mode":mode,"initial_order":initial_order} + measurements=manifest.get("measurements",{}) + raw=measurements.get("momenta",[[0,0]]) + momenta=[(int(k[0]),int(k[1])) for k in raw] + raw_r=measurements.get("displacements",[[0,0],[1,0],[0,1]]) + displacements=[(int(r[0]),int(r[1])) for r in raw_r] + return cls(geometry,catalog,model,parsed,momenta,displacements, + Path(output_dir),manifest_sha256) + def _record(self,reason:str,fast_residual:Optional[float]=None, + delta_logdet:Optional[float]=0.0, + relative_T:Optional[float]=0.0, + relative_Q:Optional[float]=0.0)->None: + self.counters["rebuilds"]+=1 + rebuilt_residual=self.factors.inverse_residual_inf + self.rebuild_diagnostics.append({"step":self.completed_steps,"reason":reason, + "order":len(self.word),"fast_inverse_residual_inf":fast_residual, + "rebuilt_inverse_residual_inf":rebuilt_residual, + "delta_logdet":delta_logdet, + "relative_T_drift_inf":relative_T, + "relative_Q_drift_inf":relative_Q, + "structured_row_work":3*len(self.word)*self.geometry.n_sites}) + def rebuild(self,reason:str,compare_fast:bool=True)->None: + fast=self.factors + fast_residual=inverse_residual_inf(fast.T,fast.Q) if compare_fast else None + T=structured_product(self.geometry.n_sites,self.geometry.triangles, + self.catalog,list(self.word)) + rebuilt=factor_dense(T) + if compare_fast: + delta_logdet=float(rebuilt.logdet-fast.logdet) + relative_T=float(np.linalg.norm(rebuilt.T-fast.T,np.inf)/ + max(1.0,np.linalg.norm(rebuilt.T,np.inf))) + relative_Q=float(np.linalg.norm(rebuilt.Q-fast.Q,np.inf)/ + max(1.0,np.linalg.norm(rebuilt.Q,np.inf))) + else: + delta_logdet=relative_T=relative_Q=None + self.factors=rebuilt;self.moves_since_rebuild=0 + self._record(reason,fast_residual,delta_logdet,relative_T,relative_Q) + def _event_data(self,event:Event)->Tuple[Triangle,LocalVertex,float]: + tri=self.geometry.triangles[event.triangle_id]; v=self.catalog[event.vertex_id] + return tri,v,v.activity/self.G0 + def _sample_event(self)->Tuple[Event,float]: + tri=int(self.rng.integers(self.geometry.n_triangles)) + pos=int(self.rng.choice(len(self.active),p=self.template_probabilities)) + event=Event(tri,self.active[pos]); return event,self._event_data(event)[2] + def _proposal(self,sites:Sequence[int],block:np.ndarray)->LowRankProposal: + p=low_rank_left_proposal(self.factors,sites,block,self.condition_max) + if not p.needs_rebuild:return p + self.counters["low_rank_rebuild_gates"]+=1; self.rebuild("low-rank-gate") + p=low_rank_left_proposal(self.factors,sites,block,self.condition_max) + if not p.needs_rebuild:return p + self.counters["dense_candidate_fallbacks"]+=1 + return _dense_left_proposal(self.factors,sites,block) + def _accept(self,loga:float)->bool: + return loga>=0 or math.log(max(float(self.rng.random()),np.finfo(float).tiny))bool: + raw=self.counters["moves"]["insert"]; raw["attempted"]+=1 + event,plabel=self._sample_event(); tri,v,_=self._event_data(event) + p=self._proposal(tri.sites,v.block) + if p.zero_weight:self.counters["zero_weight_rejections"]+=1;return False + loga=log_accept_insert(self.beta,v.activity,len(self.word),p.log_det_ratio, + self.moves["insert"],self.moves["delete"],plabel) + if not self._accept(loga):return False + self.factors=apply_low_rank_proposal(self.factors,p);self.word.append(event) + raw["accepted"]+=1;self.counters["rank3_updates_accepted"]+=int(not p.used_dense_fallback) + self.moves_since_rebuild+=1;return True + def _delete(self)->bool: + raw=self.counters["moves"]["delete"];raw["attempted"]+=1 + if not self.word:return False + event=self.word[-1];tri,v,plabel=self._event_data(event) + p=self._proposal(tri.sites,v.block_inv) + if p.zero_weight:self.counters["zero_weight_rejections"]+=1;return False + loga=log_accept_delete(self.beta,v.activity,len(self.word),p.log_det_ratio, + self.moves["insert"],self.moves["delete"],plabel) + if not self._accept(loga):return False + self.factors=apply_low_rank_proposal(self.factors,p);self.word.pop() + raw["accepted"]+=1;self.counters["rank3_updates_accepted"]+=int(not p.used_dense_fallback) + self.moves_since_rebuild+=1;return True + def _rotate_ltr(self)->bool: + raw=self.counters["moves"]["rotate_left_to_right"];raw["attempted"]+=1 + if len(self.word)<2:return False + event=self.word[-1];self.factors=rotate_left_factor_to_right( + self.factors,event,self.geometry.triangles,self.catalog) + self.word.rotate(1);raw["accepted"]+=1;self.moves_since_rebuild+=1;return True + def _rotate_rtl(self)->bool: + raw=self.counters["moves"]["rotate_right_to_left"];raw["attempted"]+=1 + if len(self.word)<2:return False + event=self.word[0];self.factors=rotate_right_factor_to_left( + self.factors,event,self.geometry.triangles,self.catalog) + self.word.rotate(-1);raw["accepted"]+=1;self.moves_since_rebuild+=1;return True + def step(self)->None: + u=float(self.rng.random());cumulative=0.0;move=list(self.moves)[-1] + for name,p in self.moves.items(): + cumulative+=p + if u=self.rebuild_every:self.rebuild("periodic") + def checkpoint_payload(self,status:str="running")->Mapping[str,Any]: + return {"schema_version":1,"algorithm_id":ALGORITHM_ID,"status":status, + "manifest_sha256":self.manifest_sha256,"completed_steps":self.completed_steps, + "word":[e.to_json() for e in self.word],"rng_state":self.rng.bit_generator.state, + "counters":self.counters,"accumulator":self.accumulator.state(), + "moves_since_rebuild":self.moves_since_rebuild, + "rebuild_diagnostics":self.rebuild_diagnostics, + "last_state":{"order":len(self.word),"logdet":self.factors.logdet}} + def save_checkpoint(self,status:str="running")->None: + atomic_write_json(self.output_dir/"checkpoint.json",self.checkpoint_payload(status)) + def load_checkpoint(self)->None: + data=json.loads((self.output_dir/"checkpoint.json").read_text()) + if data.get("algorithm_id")!=ALGORITHM_ID or data.get("manifest_sha256")!=self.manifest_sha256: + raise ManifestError("checkpoint protocol mismatch") + self.completed_steps=int(data["completed_steps"]) + self.word=deque(Event.from_json(e) for e in data["word"]) + self.rng.bit_generator.state=data["rng_state"];self.counters=data["counters"] + self.counters.setdefault("determinant_failures",{"zero":0,"negative":0}) + saved_moves_since_rebuild=int(data.get("moves_since_rebuild",0)) + self.accumulator=ObservableAccumulator.from_state(data["accumulator"]) + self.rebuild_diagnostics=list(data.get("rebuild_diagnostics",[])) + self.rebuild("resume",False) + self.moves_since_rebuild=saved_moves_since_rebuild + def run(self)->Mapping[str,Any]: + run_started=time.perf_counter() + self.output_dir.mkdir(parents=True,exist_ok=True) + for index in range(self.completed_steps,self.steps): + self.step();self.completed_steps=index+1 + if self.completed_steps>self.warmup and ( + self.completed_steps-self.warmup)%self.measure_every==0: + self.accumulator.add(measure_configuration( + self.factors,self.geometry,self.beta,self.G0,len(self.word), + self.momenta,self.displacements)) + if self.completed_steps%self.checkpoint_every==0: + self.save_checkpoint();atomic_write_json(self.output_dir/"progress.json",{ + "step":self.completed_steps,"order":len(self.word), + "measurements":self.accumulator.count, + "latest_rebuild":self.rebuild_diagnostics[-1]}) + print(json.dumps({"step":self.completed_steps,"order":len(self.word)}),flush=True) + self.rebuild("final") + wall_seconds=float(time.perf_counter()-run_started) + max_rss_kb=linux_max_rss_kb() + move_acceptance={} + for name,raw in self.counters["moves"].items(): + attempted=int(raw["attempted"]);accepted=int(raw["accepted"]) + move_acceptance[name]={"attempted":attempted,"accepted":accepted, + "rate":accepted/attempted if attempted else None} + result={"schema_version":1,"status":"run_complete_unvalidated", + "scope":"single_chain_execution_only","algorithm_id":ALGORITHM_ID, + "manifest_sha256":self.manifest_sha256, + "geometry":{"Lx":self.geometry.Lx,"Ly":self.geometry.Ly, + "n_sites":self.geometry.n_sites,"n_triangles":self.geometry.n_triangles}, + "model":self.model,"initialization":self.initialization, + "measurements":{"momenta":[list(k) for k in self.momenta], + "displacements":[list(r) for r in self.displacements]}, + "completed_steps":self.completed_steps, + "final_order":len(self.word),"final_logdet":self.factors.logdet, + "counters":self.counters,"move_acceptance":move_acceptance, + "rebuild_diagnostics":self.rebuild_diagnostics, + "timing":{"wall_seconds":wall_seconds}, + "resource_usage":{"max_rss_kb":max_rss_kb}, + "observables":self.accumulator.summary(self.beta,self.geometry.n_sites), + "implementation":{"fock_space_constructed":False, + "local_storage":"12 local 3x3 B/B_inv templates","state":"dense T,Q,logdet", + "stabilization":"direct O(mN) rebuild + dense O(N^3) LU", + "trace_storage":"pilot-only in-memory/checkpoint JSON; O(n_measurements)", + "not_implemented":["QR/UDT","chunked production trace storage", + "autocorrelation-aware errors"]}, + "validation_status":"single chain ran; correctness and science gates remain unvalidated", + "claim_boundary":"mu is not implemented; no finite-density ground-state or mixing claim"} + result_path=self.output_dir/"result.json" + atomic_write_json(result_path,result) + self.save_checkpoint("run_complete_unvalidated") + result_sha256=hashlib.sha256(result_path.read_bytes()).hexdigest() + atomic_write_json(self.output_dir/"CHAIN_COMPLETE",{ + "schema_version":1,"status":"run_complete_unvalidated", + "scope":"single_chain_execution_only","algorithm_id":ALGORITHM_ID, + "manifest_sha256":self.manifest_sha256, + "result_json_sha256":result_sha256, + "completed_steps":self.completed_steps}) + return result + +def load_manifest(path:Path)->Tuple[Mapping[str,Any],str]: + raw=path.read_bytes();data=json.loads(raw.decode()) + if not isinstance(data,dict):raise ManifestError("manifest root must be object") + return data,hashlib.sha256(raw).hexdigest() + +def main(argv:Optional[Sequence[str]]=None)->int: + parser=argparse.ArgumentParser(description=__doc__) + parser.add_argument("--manifest",type=Path,required=True) + parser.add_argument("--output",type=Path,required=True) + parser.add_argument("--resume",action="store_true") + parser.add_argument("--validate-only",action="store_true") + args=parser.parse_args(argv) + if args.resume and args.validate_only: + raise ManifestError("--resume and --validate-only are mutually exclusive") + manifest,digest=load_manifest(args.manifest) + if args.validate_only: + sampler=CTQMC.from_manifest(manifest,args.output,digest) + print(json.dumps({"algorithm_id":ALGORITHM_ID,"manifest_sha256":digest, + "n_sites":sampler.geometry.n_sites, + "n_triangles":sampler.geometry.n_triangles, + "local_templates":len(sampler.catalog),"status":"parsed, not run"}, + indent=2,allow_nan=False)) + return 0 + checkpoint=args.output/"checkpoint.json" + result=args.output/"result.json" + chain_complete=args.output/"CHAIN_COMPLETE" + failed=args.output/"FAILED" + if chain_complete.exists(): + raise ManifestError("CHAIN_COMPLETE exists; completed chain output is immutable") + if failed.exists(): + raise ManifestError("FAILED exists; failed chain output is immutable") + if args.resume: + if not checkpoint.is_file(): + raise ManifestError("--resume needs checkpoint") + elif checkpoint.exists() or result.exists(): + raise ManifestError("output exists; use --resume or a new directory") + sampler:Optional[CTQMC]=None + try: + sampler=CTQMC.from_manifest(manifest,args.output,digest) + if args.resume: + sampler.load_checkpoint() + final=sampler.run() + except Exception as exc: + kind=exc.kind if isinstance(exc,DeterminantFailure) else None + if sampler is not None: + counts=sampler.counters.setdefault( + "determinant_failures",{"zero":0,"negative":0}) + if kind in counts: + counts[kind]=int(counts[kind])+1 + completed_steps=sampler.completed_steps + try: + sampler.save_checkpoint("run_failed") + except Exception: + pass + failure_counts=dict(counts) + else: + failure_counts={"zero":int(kind=="zero"), + "negative":int(kind=="negative")} + completed_steps=0 + failure_payload={"schema_version":1,"status":"run_failed", + "scope":"single_chain_execution_only","algorithm_id":ALGORITHM_ID, + "manifest_sha256":digest,"completed_steps":completed_steps, + "failed_unix_time":float(time.time()), + "error_type":type(exc).__name__,"error_message":str(exc), + "determinant_failure_kind":kind, + "determinant_failures":failure_counts} + try: + atomic_write_json(failed,failure_payload) + except Exception: + pass + raise + print(json.dumps({"status":final["status"], + "wall_seconds":final["timing"]["wall_seconds"]}, + allow_nan=False),flush=True) + return 0 +if __name__=="__main__":raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py new file mode 100644 index 000000000..3ae3a39a8 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py @@ -0,0 +1,626 @@ +#!/usr/bin/env python3 +"""Exact-diagonalization oracle for the issue-121 large-lattice runner. + +This module deliberately constructs the complete 2**N Fock space and is +therefore hard-limited to N<=9. It is only a small-system ED oracle for checking +large_lattice_ctqmc.py; it is not a production lattice algorithm. + +For a one-particle matrix B and ordered occupation sets I,J, the convention is + + = det(B[I,J]). + +Thus the one-particle block of Gamma(B) is B, with the destination occupation +set selecting matrix rows and the source occupation set selecting columns. The +Hamiltonian matching the continuous-time expansion is + + H = G0 I - sum_(triangle,vertex) activity * Gamma(B_emb), + +where the catalog activity already includes the factor 1/6 from the S3 twirl. +Individual Gamma(B_emb) need not be Hermitian; the completed sum must pass an +explicit Hermiticity-residual gate before diagonalization. +""" + +from __future__ import annotations + +import argparse +import json +import math +from dataclasses import dataclass +from fractions import Fraction +from itertools import combinations +from pathlib import Path +from typing import Any, Mapping, Optional, Sequence, Tuple + +import numpy as np + +import large_lattice_ctqmc as ctqmc + + +ALGORITHM_ID = "triangular-ab-full-fock-ed-oracle-v1" +SCHEMA_VERSION = 1 +MAX_SITES = 9 +DEFAULT_HERMITIAN_TOLERANCE = 1.0e-10 +ORIENTATION_TOLERANCE = 1.0e-14 + + +class EDOracleError(RuntimeError): + """Raised when an ED-only size or numerical invariant is violated.""" + + +@dataclass(frozen=True) +class SectorLayout: + particles: int + occupations: Tuple[Tuple[int, ...], ...] + masks: Tuple[int, ...] + + +@dataclass(frozen=True) +class FockLayout: + n_sites: int + dimension: int + sectors: Tuple[SectorLayout, ...] + + +@dataclass(frozen=True) +class OracleInput: + manifest_sha256: str + geometry: ctqmc.TriangularGeometry + catalog: Tuple[ctqmc.LocalVertex, ...] + model: Mapping[str, float] + momenta: Tuple[Tuple[int, int], ...] + hermitian_tolerance: float + + +def _as_mapping(value: Any, name: str) -> Mapping[str, Any]: + if not isinstance(value, Mapping): + raise ctqmc.ManifestError(f"{name} must be an object") + return value + + +def _integer(value: Any, name: str, minimum: int) -> int: + if isinstance(value, bool) or not isinstance(value, int) or value < minimum: + raise ctqmc.ManifestError(f"{name} must be an integer >= {minimum}") + return value + + +def _signed_integer(value: Any, name: str) -> int: + if isinstance(value, bool) or not isinstance(value, int): + raise ctqmc.ManifestError(f"{name} must be an integer") + return value + + +def _real(value: Any, name: str) -> float: + try: + parsed = float(Fraction(value)) if isinstance(value, str) else float(value) + except (TypeError, ValueError, ZeroDivisionError) as exc: + raise ctqmc.ManifestError(f"invalid {name}") from exc + if not math.isfinite(parsed): + raise ctqmc.ManifestError(f"{name} must be finite") + return parsed + + +def load_runner_input(path: Path) -> OracleInput: + """Load one CTQMC runner manifest without constructing a sampler.""" + manifest, digest = ctqmc.load_manifest(path) + if int(manifest.get("schema_version", -1)) != SCHEMA_VERSION: + raise ctqmc.ManifestError("schema_version must be 1") + + lattice = _as_mapping(manifest.get("lattice"), "lattice") + lx = _integer(lattice.get("Lx"), "lattice.Lx", 2) + ly = _integer(lattice.get("Ly"), "lattice.Ly", 2) + geometry = ctqmc.build_triangular_geometry(lx, ly) + if geometry.n_sites > MAX_SITES: + raise EDOracleError( + f"ED oracle forbids N={geometry.n_sites}; maximum is {MAX_SITES}" + ) + + raw_model = _as_mapping(manifest.get("model"), "model") + model = { + name: _real(raw_model.get(name), f"model.{name}") + for name in ( + "epsilon", + "kappa", + "vertex_strength", + "g_A", + "g_B", + "beta", + ) + } + if model["beta"] <= 0.0: + raise ctqmc.ManifestError("model.beta must be positive") + catalog = tuple( + ctqmc.build_vertex_catalog( + model["epsilon"], + model["kappa"], + model["vertex_strength"], + model["g_A"], + model["g_B"], + ) + ) + + measurements = _as_mapping(manifest.get("measurements", {}), "measurements") + raw_momenta = measurements.get("momenta", [[0, 0]]) + if ( + not isinstance(raw_momenta, Sequence) + or isinstance(raw_momenta, (str, bytes)) + ): + raise ctqmc.ManifestError("measurements.momenta must be a sequence") + momenta = [] + for index, raw in enumerate(raw_momenta): + if ( + not isinstance(raw, Sequence) + or isinstance(raw, (str, bytes)) + or len(raw) != 2 + ): + raise ctqmc.ManifestError( + f"measurements.momenta[{index}] must be [kx,ky]" + ) + kx = _signed_integer(raw[0], f"measurements.momenta[{index}][0]") + ky = _signed_integer(raw[1], f"measurements.momenta[{index}][1]") + momenta.append((kx, ky)) + if len(set(momenta)) != len(momenta): + raise ctqmc.ManifestError("measurements.momenta contains duplicates") + + ed_config = _as_mapping( + manifest.get("exact_diagonalization", {}), + "exact_diagonalization", + ) + hermitian_tolerance = _real( + ed_config.get("hermitian_tolerance", DEFAULT_HERMITIAN_TOLERANCE), + "exact_diagonalization.hermitian_tolerance", + ) + if hermitian_tolerance <= 0.0: + raise ctqmc.ManifestError("hermitian_tolerance must be positive") + + return OracleInput( + digest, + geometry, + catalog, + model, + tuple(momenta), + hermitian_tolerance, + ) + + +def build_fock_layout(n_sites: int) -> FockLayout: + if n_sites < 1 or n_sites > MAX_SITES: + raise EDOracleError(f"Fock layout requires 1<=N<={MAX_SITES}") + sectors = [] + for particles in range(n_sites + 1): + occupations = tuple(combinations(range(n_sites), particles)) + masks = tuple( + sum(1 << site for site in occupation) + for occupation in occupations + ) + sectors.append(SectorLayout(particles, occupations, masks)) + return FockLayout(n_sites, 1 << n_sites, tuple(sectors)) + + +def exterior_representation( + matrix: np.ndarray, + occupations: Sequence[Tuple[int, ...]], +) -> np.ndarray: + """Return the exterior-power block with row=destination, column=source.""" + square = np.asarray(matrix) + if square.ndim != 2 or square.shape[0] != square.shape[1]: + raise ValueError("matrix must be square") + result = np.zeros( + (len(occupations), len(occupations)), + dtype=np.result_type(square.dtype, np.float64), + ) + if len(occupations) == 1 and not occupations[0]: + result[0, 0] = 1.0 + return result + for row, destination in enumerate(occupations): + for column, source in enumerate(occupations): + result[row, column] = np.linalg.det( + square[np.ix_(destination, source)] + ) + return result + + +def fock_gamma( + matrix: np.ndarray, + layout: FockLayout, +) -> Tuple[np.ndarray, float]: + """Build full Gamma(matrix) in bitmask order and check its 1-body block.""" + square = np.asarray(matrix) + if square.shape != (layout.n_sites, layout.n_sites): + raise ValueError("one-particle matrix has wrong shape") + gamma = np.zeros( + (layout.dimension, layout.dimension), + dtype=np.result_type(square.dtype, np.float64), + ) + for sector in layout.sectors: + block = exterior_representation(square, sector.occupations) + indices = list(sector.masks) + gamma[np.ix_(indices, indices)] = block + + one_particle_masks = list(layout.sectors[1].masks) + one_particle_block = gamma[ + np.ix_(one_particle_masks, one_particle_masks) + ] + orientation_residual = float( + np.linalg.norm(one_particle_block - square, ord=np.inf) + / max(1.0, float(np.linalg.norm(square, ord=np.inf))) + ) + return gamma, orientation_residual + + +def embed_block( + n_sites: int, + sites: Sequence[int], + block: np.ndarray, +) -> np.ndarray: + embedded = np.eye(n_sites) + indices = list(sites) + if len(indices) != 3 or len(set(indices)) != 3: + raise EDOracleError("each ED vertex must occupy three distinct sites") + embedded[np.ix_(indices, indices)] = np.asarray(block) + return embedded + + +def build_hamiltonian( + oracle: OracleInput, + layout: FockLayout, +) -> Tuple[np.ndarray, Mapping[str, Any]]: + """Construct H from the exact catalog used by the determinant sampler.""" + activity_sum = float(sum(vertex.activity for vertex in oracle.catalog)) + g0 = float(oracle.geometry.n_triangles * activity_sum) + hamiltonian = g0 * np.eye(layout.dimension) + max_orientation_residual = 0.0 + terms = 0 + + for triangle in oracle.geometry.triangles: + for vertex in oracle.catalog: + embedded = embed_block( + oracle.geometry.n_sites, + triangle.sites, + vertex.block, + ) + lifted, orientation_residual = fock_gamma(embedded, layout) + max_orientation_residual = max( + max_orientation_residual, + orientation_residual, + ) + hamiltonian -= float(vertex.activity) * lifted + terms += 1 + + if max_orientation_residual > ORIENTATION_TOLERANCE: + raise EDOracleError( + "Gamma(B) one-particle block has the wrong row/column orientation: " + f"residual={max_orientation_residual:.3e}" + ) + + norm_h = float(np.linalg.norm(hamiltonian, ord=np.inf)) + hermitian_residual = float( + np.linalg.norm( + hamiltonian - hamiltonian.conj().T, + ord=np.inf, + ) + / max(1.0, norm_h) + ) + if ( + not math.isfinite(hermitian_residual) + or hermitian_residual > oracle.hermitian_tolerance + ): + raise EDOracleError( + "completed S3-twirled Hamiltonian is not Hermitian: " + f"relative_inf_residual={hermitian_residual:.3e}, " + f"tolerance={oracle.hermitian_tolerance:.3e}" + ) + + diagnostics = { + "G0": g0, + "resolved_term_count": terms, + "max_gamma_one_body_orientation_residual_inf": ( + max_orientation_residual + ), + "hermitian_residual_relative_inf": hermitian_residual, + "hermitian_tolerance": oracle.hermitian_tolerance, + } + hermitian = 0.5 * (hamiltonian + hamiltonian.conj().T) + return hermitian, diagnostics + + +def thermal_density_matrix( + hamiltonian: np.ndarray, + beta: float, +) -> Tuple[np.ndarray, np.ndarray, float, Optional[float], float]: + eigenvalues, eigenvectors = np.linalg.eigh(hamiltonian) + minimum = float(eigenvalues[0]) + scaled_weights = np.exp(-beta * (eigenvalues - minimum)) + scaled_partition = float(np.sum(scaled_weights)) + probabilities = scaled_weights / scaled_partition + log_z = float(-beta * minimum + math.log(scaled_partition)) + log_float_max = math.log(np.finfo(float).max) + z_value = math.exp(log_z) if log_z < log_float_max else None + density_matrix = ( + eigenvectors * probabilities[np.newaxis, :] + ) @ eigenvectors.conj().T + energy = float(np.dot(probabilities, eigenvalues)) + return density_matrix, eigenvalues, log_z, z_value, energy + + +def _fermion_sign(mask: int, site: int) -> float: + lower = mask & ((1 << site) - 1) + return -1.0 if lower.bit_count() % 2 else 1.0 + + +def hop_action(mask: int, create_site: int, annihilate_site: int) -> Optional[Tuple[int, float]]: + """Apply c_create^dagger c_annihilate to a bitmask ket.""" + if not (mask & (1 << annihilate_site)): + return None + amplitude = _fermion_sign(mask, annihilate_site) + intermediate = mask ^ (1 << annihilate_site) + if intermediate & (1 << create_site): + return None + amplitude *= _fermion_sign(intermediate, create_site) + destination = intermediate | (1 << create_site) + return destination, amplitude + + +def one_body_green( + density_matrix: np.ndarray, + n_sites: int, +) -> np.ndarray: + """Return G[i,j]=Tr(rho c_i^dagger c_j), matching the sampler.""" + dimension = 1 << n_sites + green = np.zeros((n_sites, n_sites), dtype=complex) + for create_site in range(n_sites): + for annihilate_site in range(n_sites): + value = 0.0j + for source in range(dimension): + action = hop_action(source, create_site, annihilate_site) + if action is None: + continue + destination, amplitude = action + # Tr(rho O) uses rho[source,destination] when + # O|source> = amplitude|destination>. + value += amplitude * density_matrix[source, destination] + green[create_site, annihilate_site] = value + return green + + +def density_moments( + density_matrix: np.ndarray, + n_sites: int, +) -> Tuple[np.ndarray, np.ndarray, float, float]: + dimension = 1 << n_sites + basis_probabilities = np.real(np.diag(density_matrix)) + occupations = np.empty((dimension, n_sites), dtype=float) + for mask in range(dimension): + for site in range(n_sites): + occupations[mask, site] = float((mask >> site) & 1) + density = basis_probabilities @ occupations + density_pair = occupations.T @ ( + basis_probabilities[:, np.newaxis] * occupations + ) + particle_number = float(np.sum(density)) + particle_number_squared = float(np.sum(density_pair)) + return density, density_pair, particle_number, particle_number_squared + + +def _complex_pair(value: complex) -> Sequence[float]: + number = complex(value) + return [float(number.real), float(number.imag)] + + +def _complex_matrix(matrix: np.ndarray) -> Mapping[str, Any]: + array = np.asarray(matrix) + return { + "real": np.real(array).tolist(), + "imag": np.imag(array).tolist(), + } + + +def momentum_observables( + geometry: ctqmc.TriangularGeometry, + green: np.ndarray, + density: np.ndarray, + density_pair: np.ndarray, + momenta: Sequence[Tuple[int, int]], +) -> Mapping[str, Any]: + """Use exactly the phase and normalization convention of the sampler.""" + n_sites = geometry.n_sites + x = geometry.coordinates[:, 0] + y = geometry.coordinates[:, 1] + result = {} + for kx, ky in momenta: + phase = np.exp( + 2.0j + * math.pi + * (kx * x / geometry.Lx + ky * y / geometry.Ly) + ) + one_body = complex(np.vdot(phase, green @ phase) / n_sites) + density_raw = complex( + np.vdot(phase, density_pair @ phase) / n_sites + ) + density_mode = complex( + np.vdot(phase, density) / math.sqrt(n_sites) + ) + density_connected = ( + density_raw - density_mode.conjugate() * density_mode + ) + result[f"{kx},{ky}"] = { + "one_body": _complex_pair(one_body), + "density_raw": _complex_pair(density_raw), + "density_mode": _complex_pair(density_mode), + "density_connected_from_means": _complex_pair( + density_connected + ), + } + return result + + +def run_oracle(manifest_path: Path) -> Mapping[str, Any]: + oracle = load_runner_input(manifest_path) + layout = build_fock_layout(oracle.geometry.n_sites) + hamiltonian, hamiltonian_diagnostics = build_hamiltonian(oracle, layout) + ( + density_matrix, + eigenvalues, + log_z, + z_value, + energy, + ) = thermal_density_matrix(hamiltonian, oracle.model["beta"]) + + green = one_body_green(density_matrix, oracle.geometry.n_sites) + ( + density, + density_pair, + particle_number, + particle_number_squared, + ) = density_moments(density_matrix, oracle.geometry.n_sites) + raw_number_variance = ( + particle_number_squared - particle_number * particle_number + ) + variance_roundoff_tolerance = ( + 128.0 + * np.finfo(float).eps + * max(1.0, float(oracle.geometry.n_sites**2)) + ) + if raw_number_variance < -variance_roundoff_tolerance: + raise EDOracleError("thermal particle-number variance is negative") + number_variance = max(0.0, raw_number_variance) + compressibility = ( + oracle.model["beta"] + * number_variance + / oracle.geometry.n_sites + ) + + trace_residual = abs(complex(np.trace(density_matrix)) - 1.0) + green_hermitian_residual = float( + np.linalg.norm(green - green.conj().T, ord=np.inf) + ) + green_number_residual = abs( + float(np.real(np.trace(green))) - particle_number + ) + density_pair_diagonal_residual = float( + np.linalg.norm(np.diag(density_pair) - density, ord=np.inf) + ) + + return { + "schema_version": SCHEMA_VERSION, + "status": "complete", + "algorithm_id": ALGORITHM_ID, + "runner_manifest_sha256": oracle.manifest_sha256, + "oracle_boundary": { + "maximum_sites": MAX_SITES, + "fock_dimension": layout.dimension, + "purpose": "N<=9 exact-diagonalization cross-check only", + "production_use_forbidden": True, + "geometry_note": ( + "The imported runner geometry permits Lx,Ly>=2. The " + "preregistered periodic triangular-lattice tori with " + "Lx=Ly are L=2,N=4 and L=3,N=9." + ), + }, + "geometry": { + "Lx": oracle.geometry.Lx, + "Ly": oracle.geometry.Ly, + "n_sites": oracle.geometry.n_sites, + "n_triangles": oracle.geometry.n_triangles, + }, + "model": dict(oracle.model), + "hamiltonian": { + **hamiltonian_diagnostics, + "dimension": layout.dimension, + "minimum_eigenvalue": float(eigenvalues[0]), + "maximum_eigenvalue": float(eigenvalues[-1]), + }, + "observables": { + "Z": z_value, + "logZ": log_z, + "scalar": { + "energy": energy, + "energy_density": energy / oracle.geometry.n_sites, + "particle_number": particle_number, + "particle_number_squared": particle_number_squared, + "particle_density": ( + particle_number / oracle.geometry.n_sites + ), + "particle_density_squared": ( + particle_number_squared + / (oracle.geometry.n_sites * oracle.geometry.n_sites) + ), + "compressibility": compressibility, + }, + "one_body_green": { + "definition": "G[i,j]=Tr(rho c_i^dagger c_j)", + **_complex_matrix(green), + }, + "momentum": momentum_observables( + oracle.geometry, + green, + density, + density_pair, + oracle.momenta, + ), + "momentum_definition": { + "one_body": "phase^dagger G phase / N", + "density_raw": "phase^dagger phase / N", + "density_mode": "phase^dagger / sqrt(N)", + "density_connected_from_means": ( + "density_raw-abs(density_mode)^2" + ), + }, + }, + "diagnostics": { + "density_matrix_trace_residual": float(trace_residual), + "green_hermitian_residual_inf": green_hermitian_residual, + "green_trace_minus_particle_number_abs": ( + green_number_residual + ), + "density_pair_diagonal_residual_inf": ( + density_pair_diagonal_residual + ), + "raw_particle_number_variance": raw_number_variance, + "variance_roundoff_tolerance": variance_roundoff_tolerance, + "partition_function_note": ( + "Z is null only if exp(logZ) exceeds float range" + if z_value is None + else "Z represented as float" + ), + }, + } + + +def main(argv: Optional[Sequence[str]] = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--manifest", + type=Path, + required=True, + help="single-run large_lattice_ctqmc manifest", + ) + parser.add_argument( + "--output", + type=Path, + required=True, + help="new JSON output file", + ) + args = parser.parse_args(argv) + if args.output.exists(): + raise EDOracleError( + f"refusing to overwrite existing output: {args.output}" + ) + payload = run_oracle(args.manifest) + ctqmc.atomic_write_json(args.output, payload) + print( + json.dumps( + { + "status": payload["status"], + "algorithm_id": ALGORITHM_ID, + "output": str(args.output), + "n_sites": payload["geometry"]["n_sites"], + }, + sort_keys=True, + ), + flush=True, + ) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_extension.md b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_extension.md new file mode 100644 index 000000000..31c27e836 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_extension.md @@ -0,0 +1,641 @@ +# Large-lattice extension of the local three-mode A/B vertices + +Date: 2026-07-30 + +Status: analytic theorem extension. No new numerical calculation is used here. +The finite-size verification record remains in `verification_record.md`. The +purpose of this note is to make the arbitrary-system-size statement precise and +to separate local three-site support from total system size. + +## 1. A 3-by-3 generator is a local vertex, not a three-site universe + +The matrices A and B act on the one-particle space of one local triple. They are +not the one-particle Hamiltonian of the complete lattice. On a lattice with L +spinless-fermion modes, a resolved vertex is an L-by-L matrix equal to the +identity outside one triple, a word T is L-by-L, and the many-body Hilbert space +has dimension 2^L. + +Repeating the same local term over all translated triples gives O(L) terms in one +dimension and O(L^2) terms in two dimensions. Neighboring terms overlap and, for +the explicit equal-coupling choice below, do not commute. Products of their local +propagators can transport a fermion across the complete connected lattice. Thus +"three-mode vertex" describes locality in exactly the same sense that a two-site +bond term describes a macroscopic spin chain. + +The resulting Hamiltonian does contain a genuine three-site density interaction, +as well as hopping, density interactions, and correlated pair hopping. That is a +feature of the local operator, not a restriction to three particles or three +lattice sites. + +## 2. Local alphabet and embeddings + +For epsilon>0 and kappa>0 define + + A = [ -1-epsilon-kappa 1 -epsilon ] + [ 0 -1-kappa 1 ] + [ 2 0 -2-kappa ], + + S=diag(1,1,-1), B=SAS. + +The determinant-positive lattice construction below needs only epsilon>0 and +kappa>0. To retain the exact separation from every common quadratic metric and +from the fixed same-dimensional complex-CAR Wei classes proved in +`main_theorem.md`, restrict further to + + 40 epsilon + 59 kappa < 2. (R) + +Let Lambda be a finite set of sites and let D be a collection of three-element +subsets Delta of Lambda. An ordering of Delta defines the coordinate isometry + + E_Delta : R^3 -> R^|Lambda|. + +The complete S3 average below makes the final local operator independent of this +temporary ordering. For X in {A,B}, sigma in S3, and a fixed vertex strength s>0, +define + + Y_(Delta,X,sigma) + =E_Delta P_sigma X P_sigma^T E_Delta^T, + + U_(Delta,X,sigma) + =exp[s Y_(Delta,X,sigma)] + =I+E_Delta[exp(s P_sigma X P_sigma^T)-I_3]E_Delta^T. (1) + +The Fock-space lift is + + V_(Delta,X,sigma)=Gamma(U_(Delta,X,sigma)) + =exp[s sum_(i,j in Delta) + c_i^dagger(P_sigma X P_sigma^T)_(ij)c_j]. (2) + +A single V vertex need not be Hermitian. Hermiticity belongs to the complete +six-element twirl + + M_(Delta,X)=(1/6) sum_(sigma in S3)V_(Delta,X,sigma). (3) + +No assumption that different triples are disjoint is made. + +## 3. Arbitrary bounded-degree three-uniform hypergraph theorem + +### Theorem 1: arbitrary-size and arbitrary-depth determinant positivity + +Let (Lambda,D) be any finite three-uniform hypergraph. Allow every factor in a +word to choose an arbitrary triple, A or B, a permutation, and a nonnegative +strength s_j. Then every finite word + + T=U_(Delta_m,X_m,sigma_m)(s_m) ... + U_(Delta_1,X_1,sigma_1)(s_1) (4) + +is real and obeys + + ||T||_infinity <= 1, + det(I+T) >= 0. (5) + +This holds for every |Lambda|, every overlap pattern, every ordering, and every +word depth m. Bounded hypergraph degree is not needed for the finite-volume sign +statement; it is needed only for a uniform thermodynamic limit. + +#### Proof + +Every matrix in either S3 orbit has logarithmic infinity norm + + mu_infinity(P_sigma X P_sigma^T)=-kappa. + +After embedding, rows outside Delta have logarithmic rate zero, so + + mu_infinity(Y_(Delta,X,sigma))=0, + ||exp(sY_(Delta,X,sigma))||_infinity<=1. (6) + +Submultiplicativity gives (5) for an arbitrary product, even when consecutive +factors overlap and fail to commute. + +Every eigenvalue lambda of the real matrix T lies in the closed unit disk. Real +eigenvalues contribute 1+lambda>=0. Nonreal eigenvalues occur in conjugate pairs +and contribute + + (1+lambda)(1+lambda_bar)=|1+lambda|^2>=0. + +Multiplying all contributions proves det(I+T)>=0. A zero is allowed in this +variable-strength theorem when T has an eigenvalue -1. No large-depth +extrapolation or finite-size assumption enters the proof. + +### Corollary 1: strict fixed-strength support bound + +For the fixed alphabet (1), put q=exp(-kappa s)<1. Given a nonempty word, let U +be the union of its touched sites. For each i in U, choose the last +(leftmost-applied) factor that contains i. Immediately after that factor acts, +the absolute row sum of row i is at most q, because its three local rows have +infinity norm at most q and the preceding partial product has infinity norm at +most one. Later factors do not touch i, so that row is unchanged. Sites outside +U remain exact identity rows and columns. Consequently + + T=I_(Lambda\U) direct-sum T_U, + ||T_U||_infinity<=q<1, (6a) + +and therefore + + det(I+T)=2^(|Lambda|-|U|) det(I_U+T_U)>0, + ||(I_U+T_U)^(-1)||_infinity<=1/(1-q). (6b) + +Thus the fixed-s CT alphabet used below has no exact zero-weight configuration. +A computed zero is a numerical-stability or implementation failure, not a +separate component of the sampling support. + +## 4. Hermitian, positive-semidefinite interacting Hamiltonian + +For nonnegative couplings g_(Delta,X), define + + H_Lambda + =sum_(Delta in D) sum_(X=A,B) + g_(Delta,X)[I-M_(Delta,X)]. (7) + +### Theorem 2: operator properties + +The Hamiltonian (7) is finite-range on every bounded-diameter hypergraph, +Hermitian, number conserving, and positive semidefinite. + +#### Hermiticity + +On the local three-mode Fock space, the S3 representations in particle-number +sectors N_Delta=0,1,2,3 are + + trivial, + trivial direct-sum standard, + sign direct-sum standard, + sign. + +All irreducible summands are real and occur with multiplicity one. Equation (3) +commutes with S3, so Schur's lemma makes it a real scalar on every irreducible +block. Therefore M_(Delta,X) is Hermitian in the standard Fock inner product. + +#### Positivity and a local particle penalty + +Put + + q=exp(-kappa s)<1. + +On the local N_Delta=n>=1 sector, a projective exterior norm gives + + ||wedge^n exp(sP_sigma X P_sigma^T)|| <= q^n. + +Permutation matrices are isometries for the same norm. Their average therefore +has spectral radius at most q^n. Since M_(Delta,X) is Hermitian, all its +N_Delta=n eigenvalues are real and have absolute value at most q^n. The vacuum +eigenvalue is exactly one. Hence + + I-M_(Delta,X) + >=(1-q) Pi_(N_Delta>=1), (8) + +where Pi_(N_Delta>=1) projects onto states with at least one fermion on Delta. +This proves both positive semidefiniteness and a strict local particle penalty. + +### Genuine interaction + +Every Hermitian number-conserving S3 scalar on three spinless modes has the unique +form + + h_Delta + =C + e N_Delta + t K_Delta + V Q_(2,Delta) + +J P_(s,Delta)^dagger P_(s,Delta) + +W product_(i in Delta)n_i, (9) + +where + + N_Delta=sum_(i in Delta)n_i, + K_Delta=sum_(i!=j in Delta)c_i^dagger c_j, + Q_(2,Delta)=sum_(i0, (11) + +because A and B are similar and exp(sA) is a strict real contraction. Adding the +identity shift in (7) changes only C and does not change W. + +## 5. Exact continuous-time determinant expansion + +Introduce a resolved label + + a=(Delta,X,sigma), + lambda_a=g_(Delta,X)/6, + +and write + + G_0=sum_(Delta,X)g_(Delta,X), + V=sum_a lambda_a V_a, + H_Lambda=G_0 I-V. (12) + +The grand-canonical partition function at chemical potential zero is + + Z_Lambda(beta)=Tr exp(-beta H_Lambda) + + =exp(-beta G_0) + sum_(m=0)^infinity + integral_(0=4 and periodic boundary conditions. Take every +consecutive triple + + Delta_x={x,x+1,x+2}, x in Z/LZ, + +with site-independent couplings g_A,g_B>=0. Then + + H_L^(1D)=sum_(x=0)^(L-1) + sum_(X=A,B)g_X[I-M_(Delta_x,X)] (15) + +is translation invariant, range two, and sign free at arbitrary L and CT order. + +### Explicit noncommutativity of overlaps + +Define the one-particle first-order twirls + + X_bar=(1/6)sum_(sigma in S3)P_sigma X P_sigma^T. + +Every off-diagonal entry of X_bar is the average of the six off-diagonal entries +of X. Thus + + b_A=(4-epsilon)/6, + b_B=(epsilon-2)/6, + +and the combined off-diagonal coefficient is + + b_eff=[g_A(4-epsilon)+g_B(epsilon-2)]/6. (16) + +The translated local term has the analytic expansion + + h_x(s) + =sum_X g_X[I-M_(Delta_x,X)] + =-s dGamma(g_A A_bar+g_B B_bar)_(Delta_x)+O(s^2). + +For neighboring triples, the one-particle commutator has the private-endpoint +matrix element + + [Z_x,Z_(x+1)]_(x,x+3)=2 b_eff^2, (17) + +because there are two length-two paths through the shared sites x+1 and x+2 in +one order and no path in the reverse order. Therefore + + [h_x(s),h_(x+1)(s)] != 0 + +for all sufficiently small positive s whenever b_eff!=0. The symmetric choice + + g_A=g_B=g>0 + +is especially clean: b_eff=g/3 exactly. It uses all twelve resolved orbit +vertices with positive activities, is translation invariant, interacting by +(10)-(11), and is explicitly not a sum of commuting or decoupled cells. + +## 7. Explicit periodic triangular-lattice construction + +Let + + Lambda_L={n_1 e_1+n_2 e_2 : n_1,n_2 in Z/LZ} + +be a periodic triangular lattice with L>=3. For every r include the two elementary +triangles + + Delta_r^+={r,r+e_1,r+e_2}, + + Delta_r^-={r+e_1+e_2,r+e_1,r+e_2}. (18) + +Use the same positive g_A,g_B and the same s on every triangle and orientation: + + H_L^(tri) + =sum_(r in Lambda_L) sum_(eta=+,-) sum_(X=A,B) + g_X[I-M_(Delta_r^eta,X)]. (19) + +Equation (19) has 2L^2 local triples and + + G_0=2L^2(g_A+g_B). + +It is translation invariant. Because the complete local twirl is insensitive to +the ordering of a triangle, equal couplings on the two orientations also restore +the triangular-lattice point-group action. + +Every site belongs to six elementary triangles. Adjacent up and down triangles +share an edge but have distinct third vertices. Replacing x and x+3 in (17) by +those two private vertices gives the same leading commutator matrix element + + 2 b_eff^2. + +Consequently the equal-coupling model is a connected, noncommuting, +translation-invariant two-dimensional interacting system. The determinant proof +continues to use only the common coordinate infinity norm and is unchanged by +the number or pattern of overlapping triangles. + +## 8. A square-lattice three-cluster construction + +For completeness, let Lambda_L be a periodic square lattice and let + + Q_r={r,r+e_x,r+e_y,r+e_x+e_y} + +be a plaquette. Include all four triples Q_r minus {v}, one for every v in Q_r, +with equal couplings. The resulting Hamiltonian + + H_L^(sq) + =sum_r sum_(v in Q_r) sum_(X=A,B) + g_X[I-M_(Q_r minus {v},X)] (20) + +is translation invariant, C4v invariant, and supported within one plaquette. +Neighboring L-shaped triples overlap and are noncommuting for b_eff!=0 by the +same shared-path argument. This is a square-lattice realization; it does not +require calling an L-shaped cluster an elementary triangle. + +## 9. Thermodynamic limit + +Consider Z^d with a finite list of three-site shapes and all their translates. +Assume the number of active triples containing any site is bounded uniformly by +d_D. Let + + g_max=max_(Delta) sum_X g_(Delta,X). + +From Hermiticity and the spectral bound above, + + ||I-M_(Delta,X)||<=2, + ||h_Delta||<=2 sum_X g_(Delta,X). (21) + +Thus the interaction is uniformly bounded and finite range. Moreover + + 0<=H_Lambda<=C|Lambda|, + 1<=Z_Lambda(beta)<=2^|Lambda|. (22) + +For van Hove boxes Lambda, define + + p_Lambda(beta)=|Lambda|^(-1) log Z_Lambda(beta), + f_Lambda(beta)=-p_Lambda(beta)/beta. + +If two boxes are separated by cutting the interactions that cross their common +boundary, the removed operator B has + + ||B||<=C_boundary |partial Lambda|. + +For self-adjoint H and B, the Gibbs variational principle gives + + |log Tr exp[-beta(H+B)]-log Tr exp(-beta H)| + <=beta ||B||. (23) + +Tiling a large box by fixed smaller boxes and applying (23) makes the pressure +nearly additive, with an error proportional to boundary area. Taking first the +large-box limit and then the tile-size limit proves + + p(beta)=lim_(Lambda approaches Z^d)p_Lambda(beta) (24) + +for every finite beta, and hence the free-energy density f(beta) exists. The same +proof covers the periodic one-dimensional, triangular, and square constructions. + +Finite-volume Gibbs states have subsequential infinite-volume limits for local +observables. At a point where p is differentiable with respect to a coupling, +the corresponding local energy-density expectation is fixed by that derivative. +In two dimensions, phase coexistence may make an individual local-observable +limit boundary-condition dependent; existence of pressure must not be +misreported as uniqueness of every Gibbs state. + +## 10. Estimators on the positive measure + +For a nonzero-weight configuration C, put + + T_C=U_(a_m)...U_(a_1), + R_C=T_C(I+T_C)^(-1). (25) + +The standard Gaussian trace identities give + + _C=(R_C)_(j,i), + + _C=[(I+T_C)^(-1)]_(i,j), + + _C=tr R_C. (26) + +For i!=j, equal-time density correlations follow from Wick's theorem: + + _C + =(R_C)_(i,i)(R_C)_(j,j) + -(R_C)_(i,j)(R_C)_(j,i). (27) + +Time-displaced Green functions are obtained by splitting the ordered word at the +insertion time and propagating (25) with the left and right segments. Higher +number-conserving observables use the corresponding Wick minors. The estimator +need not be positive configuration by configuration; the absence of the sign +problem is the positivity of (14). + +Differentiating (13) with respect to beta gives the particularly simple energy +estimator + + =G_0-/beta. (28) + +Derivatives with respect to g_X give the expectation of +sum_Delta[I-M_(Delta,X)]. Number fluctuations give compressibility whenever a +sign-free chemical-potential deformation is available. + +Corollary 1 excludes det(I+T_C)=0 for the fixed-s measure (14). A computed zero +must therefore stop the run as a numerical-stability or implementation failure. +For the more general variable-strength boundary covered only by Theorem 1, +zero-weight words can occur; unnormalized one- and two-body numerators can then +be defined with adjugates or minors rather than division by a singular matrix. + +At fixed beta, G_0 is proportional to volume for all translation-invariant +examples. Hence the natural CT expansion scale is extensive, O(beta|Lambda|). +The determinant is |Lambda|-dimensional. Local determinant-ratio and Green-matrix +updates can make insertions polynomial in |Lambda|, but positivity alone does not +prove rapid Markov-chain mixing or a favorable autocorrelation time. The direct +pilot prototype keeps primary scalar traces in memory and checkpoint JSON so +tau_int, ESS, and R-hat can be reconstructed; this costs O(number of +measurements) memory. A production run must replace it with durable chunked trace +storage without changing the estimator definitions. + +## 11. Exact vacuum gap and the finite-density boundary + +The large-lattice extension strengthens, rather than removes, the vacuum +limitation. Suppose every site belongs to at least r_min active triples and use +uniform g_A,g_B. Summing (8) gives + + H_Lambda + >=(g_A+g_B)(1-q) + sum_(Delta in D)Pi_(N_Delta>=1). (29) + +On every local occupation basis state, + + N_Delta<=3 Pi_(N_Delta>=1). + +Also + + sum_Delta N_Delta + =sum_i r_i n_i + >=r_min N. + +Therefore the operator inequality + + H_Lambda>=Delta_vac N, + + Delta_vac + =(g_A+g_B)(1-exp(-kappa s)) r_min/3 (30) + +holds. The covered periodic lattice has a unique vacuum ground state and a strict +particle-number gap. For the constructions above, + + one-dimensional consecutive triples: r_min=3, + triangular elementary triangles: r_min=6, + square plaquette triples: r_min=12. + +These are rigorous lower bounds, not measured excitation gaps. + +### Chemical potential + +Because H_Lambda conserves N, + + Z(beta,mu) + =Tr exp[-beta(H_Lambda-mu N)] + +has the same CT expansion with + + det(I+zT_C), z=exp(beta mu). (31) + +For the fixed-strength alphabet, Corollary 1 gives + + det(I+zT_C) + =(1+z)^(|Lambda|-|U|) det(I_U+zT_U)>0 + +whenever zq<1. Since q=exp(-kappa s) and z=exp(beta mu), this is the finite- +temperature sign-free window + + mu0 outside (31a), the thermodynamic pressure still exists because the +on-site Hilbert space is finite and -mu N is a bounded local term, but +configuration-wise positivity no longer follows from the support bound. For a +fixed real word T, positivity for every z>0 requires every distinct negative real +eigenvalue of T to have even algebraic multiplicity. The present theorem does not +enforce that condition. + +Equation (30) separately implies that the vacuum remains the ground state for +0 None: + if not ok: + raise ProtocolError(message) + +def _bad_constant(value: str) -> None: + raise ProtocolError(f"non-finite JSON token forbidden: {value}") + +def load_json(path: Path) -> Mapping[str,Any]: + try: + value=json.loads(Path(path).read_text(encoding="utf-8"), + parse_constant=_bad_constant) + except (OSError,ValueError,TypeError) as exc: + raise ProtocolError(f"cannot load strict JSON: {path}") from exc + _need(isinstance(value,dict),f"JSON root must be object: {path}") + return value + +def canonical_bytes(value: Any) -> bytes: + try: + text=json.dumps(value,sort_keys=True,separators=(",",":"), + ensure_ascii=False,allow_nan=False) + except (TypeError,ValueError) as exc: + raise ProtocolError("payload is not finite canonical JSON") from exc + return (text+"\n").encode("utf-8") + +def sha_bytes(raw: bytes) -> str: + return hashlib.sha256(raw).hexdigest() + +def sha_file(path: Path) -> str: + return sha_bytes(Path(path).read_bytes()) + +def write_bytes(path: Path, raw: bytes, exclusive: bool=False) -> None: + path=Path(path); path.parent.mkdir(parents=True,exist_ok=True) + if exclusive and path.exists(): + raise ProtocolError(f"refuse overwrite: {path}") + fd,tmp=tempfile.mkstemp(prefix="."+path.name+".",suffix=".tmp",dir=path.parent) + try: + with os.fdopen(fd,"wb") as handle: + handle.write(raw); handle.flush(); os.fsync(handle.fileno()) + if exclusive and path.exists(): + raise ProtocolError(f"concurrent immutable artifact: {path}") + os.replace(tmp,path) + finally: + if os.path.exists(tmp): + os.unlink(tmp) + +def write_json(path: Path, value: Mapping[str,Any], exclusive: bool=False) -> None: + write_bytes(path,canonical_bytes(value),exclusive) + +def _float_eq(actual: Any, expected: float, name: str) -> None: + _need(not isinstance(actual,bool),f"{name} must be numeric") + try: + value=float(actual) + except (TypeError,ValueError) as exc: + raise ProtocolError(f"{name} must be numeric") from exc + _need(math.isfinite(value) and value==expected,f"{name} drift") + +def validate_meta(meta: Mapping[str,Any]) -> None: + _need(meta.get("schema_version")==1,"meta schema") + _need(meta.get("document_type")=="preregistered_large_lattice_run", + "document_type drift") + _need(meta.get("issue")==121 and meta.get("team")=="Genshin_Impact", + "issue/team drift") + rat=meta.get("ratification") + _need(isinstance(rat,Mapping) and rat.get("required_before_any_compute") is True, + "ratification guard absent") + _need(rat.get("status")=="confirmed","ratification.status must be confirmed") + _need(meta.get("status") in {"confirmed","ratified","confirmed_for_execution","ratified_setup_frozen_pending_gates"}, + "top status must record confirmation") + model=meta.get("model") + _need(isinstance(model,Mapping),"model missing") + _need(model.get("fermions")=="spinless, one orbital per site","fermion drift") + _need(model.get("particle_number_conserving") is True,"number drift") + _float_eq(model.get("chemical_potential_mu"),0.0,"mu") + lattice=model.get("lattice") + _need(isinstance(lattice,Mapping),"lattice missing") + _need(lattice.get("type")=="periodic triangular L by L","lattice drift") + _need(lattice.get("boundary_conditions")=="periodic in both primitive directions", + "boundary drift") + _need(lattice.get("vertices")=="all elementary up and down triangles", + "triangle drift") + local=model.get("local_parameters") + _need(isinstance(local,Mapping),"local parameters missing") + for key,expected in LOCAL.items(): + if isinstance(expected,float): + _float_eq(local.get(key),expected,key) + else: + _need(local.get(key)==expected,f"{key} exact drift") + _need(40*float(local["epsilon"])+59*float(local["kappa"])<2, + "separation region violated") + grid=meta.get("grid") + _need(isinstance(grid,Mapping),"grid missing") + _need(tuple((x.get("L"),x.get("N")) for x in grid.get("sizes",()))==SIZES, + "size grid drift") + _need(tuple(grid.get("beta",()))==BETAS,"beta grid drift") + _need(tuple(grid.get("beta_exact",()))==BETA_EXACT,"beta exact drift") + _need(grid.get("full_cells")==20,"cell count drift") + random=meta.get("randomness") + _need(isinstance(random,Mapping) and random.get("chains_per_cell")==4, + "chain count drift") + _need(random.get("seed_rule")== + "121000000 + 10000*L + 10*beta_index + chain_id","seed rule drift") + _need(random.get("beta_index")=={"1/2":0,"1":1,"2":2,"4":3}, + "beta index drift") + seen=tuple((x.get("chain_id"),x.get("start"),x.get("initial_order")) + for x in random.get("chains",())) + _need(seen==CHAINS,"initialization drift") + _need(tuple(x.get("id") for x in meta.get("gates",()))== + ("G0","G1","G2","G3","G4"),"gate drift") + measurement=meta.get("measurement_protocol") + _need(isinstance(measurement,Mapping),"measurement protocol missing") + real=measurement.get("real_space_green") + _need(isinstance(real,Mapping) and + real.get("rule")=="all lattice displacements" and + real.get("indices")=="all (dx,dy) with 0<=dx None: + for stage in ("g1","production"): + value=execution.get(stage) + _need(isinstance(value,Mapping),f"execution.{stage} missing") + for key,low in (("steps",1),("warmup",0),("measure_every",1), + ("checkpoint_every",1),("rebuild_every",1)): + x=value.get(key) + _need(isinstance(x,int) and not isinstance(x,bool) and x>=low, + f"{stage}.{key} invalid") + _need(value["warmup"]=steps") + _float_eq(execution.get("woodbury_condition_max"),1e12,"condition") + moves=execution.get("move_probabilities") + names={"insert","delete","rotate_left_to_right","rotate_right_to_left"} + _need(isinstance(moves,Mapping) and set(moves)==names,"moves invalid") + _need(abs(sum(float(x) for x in moves.values())-1)<1e-15,"moves sum") + _need(moves["insert"]==moves["delete"],"birth/death asymmetry") + _need(moves["rotate_left_to_right"]==moves["rotate_right_to_left"], + "rotation asymmetry") + +def seed_for(L: int, beta_index: int, chain_id: int) -> int: + return 121000000+10000*L+10*beta_index+chain_id + +def _unique(points: Iterable[Tuple[int,int]], L: int) -> List[List[int]]: + out=[]; seen=set() + for x,y in points: + point=(int(x)%L,int(y)%L) + if point not in seen: + seen.add(point); out.append([point[0],point[1]]) + return out + +def measurements(L: int) -> Mapping[str,Any]: + gamma=[[0,0]] + qmin=[[1,0],[0,1]] + m=_unique(((L//2,0),(0,L//2),(L//2,L//2)),L) if L%2==0 else [] + k=(_unique(((L//3,2*L//3),(2*L//3,L//3)),L) + if L%3==0 else []) + momenta=_unique((tuple(x) for group in (gamma,qmin,m,k) for x in group),L) + return {"momenta":momenta, + "displacements":[[x,y] for x in range(L) for y in range(L)], + "momentum_labels":{ + "Gamma":[0,0], + "qmin":qmin, + "M_points":{"condition":"L even","indices":m}, + "K_points":{"condition":"L%3==0","indices":k}, + "deduplication": + "Deduplicate coincident momentum indices at small L while retaining all protocol labels in provenance.", + "G1_L3_note": + "L=3 has no integer M point; use Gamma, qmin, and the two K points.", + "K_note":("two exact K points included" if L%3==0 else + "K points omitted because L%3!=0")}, + "normalization":{"one_body":"phase^dagger G phase / N", + "density_raw":"phase^dagger phase / N"}} + +def runner_manifest(meta_hash: str, stage: str, L: int, beta_index: int, + chain_id: int, execution: Mapping[str,Any]) -> Mapping[str,Any]: + _need(stage in {"g1","production"},"bad stage") + beta=BETAS[beta_index]; mode="cold" if chain_id<2 else "hot" + order=0 if mode=="cold" else int(math.floor(beta*L*L+0.5)) + schedule=execution[stage] + return {"schema_version":1, + "protocol_binding":{"protocol_id":PROTOCOL_ID, + "meta_manifest_sha256":meta_hash,"stage":stage, + "cell_id":f"L{L}-b{beta_index}","chain_id":chain_id}, + "lattice":{"Lx":L,"Ly":L}, + "model":{"epsilon":"1/100","kappa":"1/50","vertex_strength":"1/4", + "g_A":"1/4","g_B":"1/4","beta":BETA_EXACT[beta_index]}, + "monte_carlo":{"steps":schedule["steps"],"warmup":schedule["warmup"], + "measure_every":schedule["measure_every"], + "checkpoint_every":schedule["checkpoint_every"], + "rebuild_every":schedule["rebuild_every"], + "seed":seed_for(L,beta_index,chain_id), + "woodbury_condition_max":execution["woodbury_condition_max"], + "move_probabilities":dict(execution["move_probabilities"]), + "initialization":{"mode":mode,"initial_order":order}}, + "measurements":measurements(L), + "exact_diagonalization":{"hermitian_tolerance":1e-10}} + +def _task_table(path: Path, entries: Sequence[Mapping[str,Any]]) -> None: + lines=["task_id\tstage\tcell_id\tchain_id\tmanifest\toutput"] + for i,x in enumerate(entries): + lines.append("\t".join(map(str,(i,x["stage"],x["cell_id"],x["chain_id"], + x["manifest"],x["output"])))) + write_bytes(path,("\n".join(lines)+"\n").encode()) + +def _array_script(table: str, count: int) -> str: + return f"""#!/bin/bash +#SBATCH --job-name=i121-{table.replace("_tasks.tsv","")} +#SBATCH --array=0-{count-1}%8 +#SBATCH --cpus-per-task=1 +#SBATCH --mem=8G +#SBATCH --time=04:00:00 +set -euo pipefail +ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +SOLUTION_DIR=${{SOLUTION_DIR:-{SOLUTION_DIR}}} +PYTHON_BIN=${{PYTHON_BIN:-python3}} +line=$(sed -n "$((SLURM_ARRAY_TASK_ID+2))p" "$ROOT/{table}") +IFS=$'\\t' read -r task stage cell chain manifest_rel output_rel <<< "$line" +output="$ROOT/$output_rel"; mkdir -p "$output" +/usr/bin/time -f 'elapsed_seconds\\t%e\\nmax_rss_kb\\t%M' -o "$output/resource.tsv" \\ + "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_ctqmc.py" \\ + --manifest "$ROOT/$manifest_rel" --output "$output" \\ + >"$output/runner.stdout" 2>"$output/runner.stderr" +""".replace("$","$") + +def _audit_script(stage: str) -> str: + ed="" + if stage=="g1": + ed="""while IFS=$'\\t' read -r cell manifest_rel exact_rel; do + [[ "$cell" == cell_id ]] && continue + exact="$ROOT/$exact_rel"; mkdir -p "$(dirname "$exact")" + [[ -f "$exact" ]] || "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_ed.py" --manifest "$ROOT/$manifest_rel" --output "$exact" +done < "$ROOT/ed_tasks.tsv" +""".replace("$","$") + flag=" --write-complete" if stage=="full" else "" + return f"""#!/bin/bash +#SBATCH --job-name=i121-audit-{stage} +#SBATCH --cpus-per-task=1 +#SBATCH --mem=8G +#SBATCH --time=04:00:00 +set -euo pipefail +ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +SOLUTION_DIR=${{SOLUTION_DIR:-{SOLUTION_DIR}}} +PYTHON_BIN=${{PYTHON_BIN:-python3}} +{ed}"$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" audit --root "$ROOT" --stage {stage}{flag} +""".replace("$","$") + +def _submit_script() -> str: + return """#!/bin/bash +# Run only after live sinfo, squeue, and scontrol node inspection. +set -euo pipefail +H=$(cd "$(dirname "$0")" && pwd -P) +g0=$(sbatch --parsable "$H/run_g0.sbatch") +g1=$(sbatch --parsable --dependency=afterok:$g0 "$H/run_g1_array.sbatch") +a1=$(sbatch --parsable --dependency=afterok:$g1 "$H/audit_g1.sbatch") +p=$(sbatch --parsable --dependency=afterok:$a1 "$H/run_pilot_array.sbatch") +ap=$(sbatch --parsable --dependency=afterok:$p "$H/audit_pilot.sbatch") +f=$(sbatch --parsable --dependency=afterok:$ap "$H/run_full_array.sbatch") +af=$(sbatch --parsable --dependency=afterok:$f "$H/audit_full.sbatch") +printf 'G0=%s G1=%s G1audit=%s pilot=%s pilotaudit=%s full=%s final=%s\\n' "$g0" "$g1" "$a1" "$p" "$ap" "$f" "$af" +""".replace("$","$") + +def materialize(meta_path: Path, root: Path, + execution: Optional[Mapping[str,Any]]=None) -> Mapping[str,Any]: + meta=load_json(meta_path); validate_meta(meta) + selected=json.loads(json.dumps(execution or DEFAULT_EXECUTION)) + validate_execution(selected) + root=Path(root) + _need(not root.exists() or not any(root.iterdir()),"output must be empty") + root.mkdir(parents=True,exist_ok=True) + meta_raw=canonical_bytes(meta); meta_hash=sha_bytes(meta_raw) + write_bytes(root/"confirmed_meta_manifest.json",meta_raw,True) + entries=[] + for stage,sizes in (("g1",(2,3)),("production",tuple(x[0] for x in SIZES))): + for L in sizes: + for bi,beta in enumerate(BETAS): + for chain in range(4): + manifest=runner_manifest(meta_hash,stage,L,bi,chain,selected) + slug=("%.8g"%beta).replace(".","p") + rel=Path("manifests")/stage/f"L{L}"/f"beta-{slug}"/f"chain-{chain}.json" + raw=canonical_bytes(manifest); write_bytes(root/rel,raw,True) + output=Path("chains")/stage/f"L{L}"/f"beta-{slug}"/f"chain-{chain}" + entries.append({"stage":stage,"cell_id":f"L{L}-b{bi}", + "L":L,"N":L*L,"beta":beta,"beta_index":bi, + "chain_id":chain,"seed":seed_for(L,bi,chain), + "initialization":manifest["monte_carlo"]["initialization"], + "manifest":rel.as_posix(),"manifest_sha256":sha_bytes(raw), + "output":output.as_posix(), + "pilot":stage=="production" and (L,bi) in PILOT}) + g1=[x for x in entries if x["stage"]=="g1"] + prod=[x for x in entries if x["stage"]=="production"] + pilot=[x for x in prod if x["pilot"]]; remaining=[x for x in prod if not x["pilot"]] + _need(tuple(map(len,(g1,prod,pilot,remaining)))==(32,80,12,68), + "task cardinality") + _task_table(root/"g1_tasks.tsv",g1); _task_table(root/"pilot_tasks.tsv",pilot) + _task_table(root/"full_tasks.tsv",remaining) + ed=["cell_id\tmanifest\texact_output"] + for x in g1: + if x["chain_id"]==0: + ed.append(f'{x["cell_id"]}\t{x["manifest"]}\texact/g1/{x["cell_id"]}.json') + write_bytes(root/"ed_tasks.tsv",("\n".join(ed)+"\n").encode()) + index={"schema_version":1,"protocol_id":PROTOCOL_ID, + "status":"materialized_not_run","meta_manifest_sha256":meta_hash, + "execution":selected,"diagnostic_method":DIAGNOSTIC_METHOD, + "counts":{"g1_chains":32,"production_chains":80, + "pilot_chains":12,"full_remaining_chains":68}, + "entries":entries, + "claim_boundary":"materialization is not compute evidence; no root COMPLETE"} + raw=canonical_bytes(index); write_bytes(root/"index.json",raw,True) + write_bytes(root/"index.sha256",(sha_bytes(raw)+" index.json\n").encode(),True) + scripts={"run_g1_array.sbatch":_array_script("g1_tasks.tsv",32), + "run_pilot_array.sbatch":_array_script("pilot_tasks.tsv",12), + "run_full_array.sbatch":_array_script("full_tasks.tsv",68), + "audit_g1.sbatch":_audit_script("g1"), + "audit_pilot.sbatch":_audit_script("pilot"), + "audit_full.sbatch":_audit_script("full"), + "submit_after_live_cluster_check.sh":_submit_script(), + "run_g0.sbatch":f"""#!/bin/bash +#SBATCH --job-name=i121-g0 +#SBATCH --cpus-per-task=1 +#SBATCH --mem=4G +#SBATCH --time=00:30:00 +set -euo pipefail +ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +SOLUTION_DIR=${{SOLUTION_DIR:-{SOLUTION_DIR}}} +PYTHON_BIN=${{PYTHON_BIN:-python3}} +"$PYTHON_BIN" -m pytest -q "$SOLUTION_DIR/test_large_lattice_protocol.py" "$SOLUTION_DIR/test_large_lattice_ctqmc.py" -m 'not slow' +"$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" record-g0 --root "$ROOT" --tests-exit-code 0 +""".replace("$","$")} + for name,text in scripts.items(): + write_bytes(root/"slurm"/name,text.encode(),True); os.chmod(root/"slurm"/name,0o755) + return index + + +def _rankdata(values: np.ndarray) -> np.ndarray: + order=np.argsort(values,kind="mergesort"); ranks=np.empty(len(values),float) + start=0 + while start List[np.ndarray]: + lengths=[len(x) for x in chains]; pooled=np.concatenate(chains) + _need(len(pooled)>0,"empty trace") + ranks=_rankdata(pooled); probabilities=(ranks-0.375)/(len(pooled)+0.25) + normal=statistics.NormalDist() + z=np.array([normal.inv_cdf(float(p)) for p in probabilities]) + out=[]; offset=0 + for length in lengths: + out.append(z[offset:offset+length]); offset+=length + return out + +def ips_tau_int(values: Sequence[float]) -> float: + x=np.asarray(values,float) + _need(x.ndim==1 and len(x)>=4 and np.all(np.isfinite(x)), + "IPS needs >=4 finite values") + centered=x-np.mean(x); gamma0=float(np.dot(centered,centered)/len(x)) + if gamma0<=np.finfo(float).eps: + return 0.5 + tau=0.5; lag=1 + while lag+1 List[np.ndarray]: + arrays=[np.asarray(x,float) for x in chains] + _need(len(arrays)>=2 and all(x.ndim==1 and len(x)>=8 and + np.all(np.isfinite(x)) for x in arrays),"short/nonfinite chains") + half=min(len(x)//2 for x in arrays) + return [part for x in arrays for part in (x[:half],x[-half:])] + +def _rhat(split: Sequence[np.ndarray]) -> float: + n=min(len(x) for x in split); values=[x[:n] for x in split] + means=np.array([np.mean(x) for x in values]) + W=float(np.mean([np.var(x,ddof=1) for x in values])) + B=float(n*np.var(means,ddof=1)) + if W<=np.finfo(float).eps: + return 1.0 if B<=np.finfo(float).eps else math.inf + return float(math.sqrt(max(0,((n-1)*W/n+B/n)/W))) + +def _ess(split: Sequence[np.ndarray]) -> float: + return float(sum(len(x)/(2*ips_tau_int(x)) for x in split)) + +def multi_chain_diagnostics(chains: Sequence[Sequence[float]]) -> Mapping[str,Any]: + split=_split(chains); ranked=_rank_normalize(split) + pooled=np.concatenate(split); low,high=np.quantile(pooled,[0.05,0.95]) + lower=[(x<=low).astype(float) for x in split] + upper=[(x>=high).astype(float) for x in split] + return {"method":DIAGNOSTIC_METHOD,"split_chains":len(split), + "samples_per_split":min(len(x) for x in split), + "split_r_hat":_rhat(ranked),"bulk_ess":_ess(ranked), + "tail_ess":min(_ess(lower),_ess(upper)), + "tau_int_by_original_chain":[ips_tau_int(x) for x in chains]} + +def verify_materialization(root: Path) -> Mapping[str,Any]: + root=Path(root); index=load_json(root/"index.json") + _need(index.get("protocol_id")==PROTOCOL_ID,"index protocol") + expected=(root/"index.sha256").read_text(encoding="ascii").split()[0] + _need(expected==sha_file(root/"index.json"),"index hash") + meta=load_json(root/"confirmed_meta_manifest.json"); validate_meta(meta) + _need(sha_bytes(canonical_bytes(meta))==index["meta_manifest_sha256"], + "meta hash") + for entry in index.get("entries",()): + path=root/entry["manifest"] + _need(path.is_file() and sha_file(path)==entry["manifest_sha256"], + f"manifest hash: {path}") + return index + +def _load_chain(root: Path, entry: Mapping[str,Any]) -> Mapping[str,Any]: + manifest_path=root/entry["manifest"]; output=root/entry["output"] + result_path=output/"result.json"; done_path=output/"COMPLETE" + _need(result_path.is_file() and done_path.is_file(), + f"missing chain {entry['cell_id']}/c{entry['chain_id']}") + manifest=load_json(manifest_path); result=load_json(result_path) + done=load_json(done_path); digest=entry["manifest_sha256"] + _need(sha_file(manifest_path)==digest,"manifest drift") + _need(result.get("manifest_sha256")==digest and + done.get("manifest_sha256")==digest,"result binding") + _need(done.get("result_json_sha256")==sha_file(result_path),"result hash") + _need(result.get("status")=="complete","chain status") + _need(result.get("completed_steps")==manifest["monte_carlo"]["steps"], + "step count") + _need(result.get("geometry",{}).get("n_sites")==entry["N"],"geometry") + _need(result.get("initialization")==entry["initialization"],"initialization") + _need(result.get("observables",{}).get("count",0)>0,"no measurements") + canonical_bytes(result) + return result + +def _momentum(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: + total=sum(int(x["observables"]["count"]) for x in results); out={} + for momentum in results[0]["observables"].get("momentum",{}): + out[momentum]={} + for name in ("one_body","density_raw","density_mode"): + pairs=[x["observables"]["momentum"][momentum][name]["mean"] + for x in results] + weights=[int(x["observables"]["count"]) for x in results] + mean=[sum(w*float(p[i]) for w,p in zip(weights,pairs))/total + for i in (0,1)] + out[momentum][name]={"mean":mean,"chain_means":pairs} + raw=out[momentum]["density_raw"]["mean"] + mode=out[momentum]["density_mode"]["mean"] + out[momentum]["density_connected_from_means"]=[ + raw[0]-mode[0]**2-mode[1]**2,raw[1]] + return out + +def summarize_cell(results: Sequence[Mapping[str,Any]], beta: float, n_sites: int, + thresholds: Mapping[str,Any], + acceptance_range: Sequence[float]) -> Mapping[str,Any]: + _need(len(results)==4,"cell needs four chains") + names=("order","energy_density","particle_number", + "particle_number_squared","particle_density") + traces={name:[[float(v) for v in x["observables"]["primary_traces"][name]] + for x in results] for name in names} + diagnostics={name:multi_chain_diagnostics(value) for name,value in traces.items() + if name!="particle_number_squared"} + pooled={name:np.concatenate(value) for name,value in traces.items()} + scalar={name:{"mean":float(np.mean(value)), + "sample_std":float(np.std(value,ddof=1))} + for name,value in pooled.items()} + mean_n=scalar["particle_number"]["mean"] + compressibility=beta*(scalar["particle_number_squared"]["mean"]-mean_n**2)/n_sites + influence=[beta*(np.asarray(n2)-2*mean_n*np.asarray(n))/n_sites + for n,n2 in zip(traces["particle_number"], + traces["particle_number_squared"])] + comp_diag=multi_chain_diagnostics(influence) + comp_mcse=float(np.std(np.concatenate(influence),ddof=1)/ + math.sqrt(max(1,comp_diag["bulk_ess"]))) + attempted=accepted=zeros=0 + keys=("delta_logdet","relative_T_drift_inf","relative_Q_drift_inf", + "fast_inverse_residual_inf","rebuilt_inverse_residual_inf") + values={key:[] for key in keys} + for result in results: + moves=result["counters"]["moves"] + for name in ("insert","delete"): + attempted+=int(moves[name]["attempted"]) + accepted+=int(moves[name]["accepted"]) + zeros+=int(result["counters"].get("zero_weight_rejections",0)) + for record in result.get("rebuild_diagnostics",()): + for key in keys: + if record.get(key) is not None: + number=abs(float(record[key])) + _need(math.isfinite(number),f"nonfinite {key}") + values[key].append(number) + _need(attempted>0,"no insert/delete attempts") + acceptance=accepted/attempted + maxima={key:max(value,default=0.0) for key,value in values.items()} + convergence=all(x["split_r_hat"]<=float(thresholds["r_hat_max"]) and + x["bulk_ess"]>=float(thresholds["bulk_ess_min"]) and + x["tail_ess"]>=float(thresholds["tail_ess_min"]) + for x in diagnostics.values()) + rebuild=max(maxima["delta_logdet"],maxima["relative_T_drift_inf"], + maxima["relative_Q_drift_inf"])<=float( + thresholds["fast_vs_rebuild_relative_error_max"]) and max( + maxima["fast_inverse_residual_inf"], + maxima["rebuilt_inverse_residual_inf"])<=float( + thresholds["inverse_residual_max"]) + accept=float(acceptance_range[0])<=acceptance<=float(acceptance_range[1]) + return {"chains":4,"samples":sum(map(len,traces["order"])),"scalar":scalar, + "compressibility":compressibility,"compressibility_mcse":comp_mcse, + "diagnostics":diagnostics,"compressibility_diagnostics":comp_diag, + "momentum":_momentum(results), + "acceptance":{"attempted":attempted,"accepted":accepted,"rate":acceptance, + "required_range":list(acceptance_range),"pass":accept}, + "rebuild":{"maxima":maxima,"pass":rebuild}, + "positivity":{"zero_weight_count":zeros,"negative_sign_count":0, + "negative_count_provenance": + "successful strict-support runner; negatives abort before chain COMPLETE", + "pass":zeros==0}, + "pass":convergence and rebuild and accept and zeros==0} + +def _mean_se(pairs: Sequence[Sequence[float]], component: int) -> float: + values=np.array([float(x[component]) for x in pairs]) + return float(np.std(values,ddof=1)/math.sqrt(len(values))) + +def compare_ed(cell: Mapping[str,Any], exact: Mapping[str,Any], + zmax: float) -> Mapping[str,Any]: + scalar={} + for name in ("energy_density","particle_density"): + diag=cell["diagnostics"][name] + se=cell["scalar"][name]["sample_std"]/math.sqrt(max(1,diag["bulk_ess"])) + estimate=cell["scalar"][name]["mean"] + target=float(exact["observables"]["scalar"][name]) + allowance=max(zmax*se,1e-10) + scalar[name]={"estimate":estimate,"exact":target,"mcse":se, + "allowance":allowance, + "pass":abs(estimate-target)<=allowance} + estimate=cell["compressibility"] + target=float(exact["observables"]["scalar"]["compressibility"]) + allowance=max(zmax*cell["compressibility_mcse"],1e-10) + scalar["compressibility"]={"estimate":estimate,"exact":target, + "mcse":cell["compressibility_mcse"],"allowance":allowance, + "pass":abs(estimate-target)<=allowance} + momentum={} + for key,reference in exact["observables"].get("momentum",{}).items(): + if key not in cell["momentum"]: + momentum[key]={"pass":False,"reason":"missing momentum"}; continue + item={} + for name in ("one_body","density_raw","density_mode"): + sampled=cell["momentum"][key][name] + se=max(_mean_se(sampled["chain_means"],i) for i in (0,1)) + allowance=max(zmax*se,1e-10) + error=max(abs(float(sampled["mean"][i])-float(reference[name][i])) + for i in (0,1)) + item[name]={"max_abs_error":error, + "mcse_from_four_chain_means":se, + "allowance":allowance,"pass":error<=allowance} + item["pass"]=all(v["pass"] for k,v in item.items() if k!="pass") + momentum[key]=item + return {"scalar":scalar,"momentum":momentum, + "momentum_mcse_note":"SE across four chain means; core stores no momentum traces", + "pass":all(x["pass"] for x in scalar.values()) and + all(x["pass"] for x in momentum.values())} + +def _gate(root: Path, name: str, payload: Mapping[str,Any]) -> Mapping[str,Any]: + record={"schema_version":1,"protocol_id":PROTOCOL_ID,"gate":name,**payload} + write_json(Path(root)/"gates"/f"{name}.json",record); return record + +def record_g0(root: Path, code: int) -> Mapping[str,Any]: + verify_materialization(root) + return _gate(root,"G0",{"status":"PASS" if code==0 else "FAIL", + "tests_exit_code":code,"index_sha256":sha_file(Path(root)/"index.json")}) + +def _require_gate(root: Path, name: str) -> Mapping[str,Any]: + value=load_json(Path(root)/"gates"/f"{name}.json") + _need(value.get("protocol_id")==PROTOCOL_ID and value.get("gate")==name and + value.get("status")=="PASS",f"required {name} not PASS") + return value + +def audit(root: Path, stage: str, write_complete: bool=False) -> Mapping[str,Any]: + root=Path(root); index=verify_materialization(root) + thresholds=load_json(root/"confirmed_meta_manifest.json")["thresholds"] + _require_gate(root,"G0") + if stage in {"pilot","full"}: _require_gate(root,"G1") + if stage=="full": _require_gate(root,"G2") + if stage=="g1": + entries=[x for x in index["entries"] if x["stage"]=="g1"] + name="G1"; arange=thresholds["full_acceptance_hard_range"] + elif stage=="pilot": + entries=[x for x in index["entries"] if x["stage"]=="production" and x["pilot"]] + name="G2"; arange=thresholds["pilot_acceptance_target"] + elif stage=="full": + entries=[x for x in index["entries"] if x["stage"]=="production"] + name="G3"; arange=thresholds["full_acceptance_hard_range"] + else: + raise ProtocolError("bad audit stage") + grouped={}; metadata={} + for entry in entries: + grouped.setdefault(entry["cell_id"],[]).append(_load_chain(root,entry)) + metadata.setdefault(entry["cell_id"],entry) + cells={} + for cell_id,results in grouped.items(): + first=metadata[cell_id] + cell=summarize_cell(results,float(first["beta"]),int(first["N"]), + thresholds,arange) + if stage=="g1": + exact=root/"exact"/"g1"/f"{cell_id}.json" + _need(exact.is_file(),f"missing ED {exact}") + cell["ed"]=compare_ed(cell,load_json(exact), + float(thresholds["ed_z_score_max"])) + cell["pass"]=cell["pass"] and cell["ed"]["pass"] + cells[cell_id]=cell + passed=bool(cells) and all(x["pass"] for x in cells.values()) + limits=[] + if stage=="pilot": + limits=["rank3-versus-rebuild kernel speedup unavailable from core v1"] + passed=False + report=_gate(root,name,{"status":"PASS" if passed else "INCONCLUSIVE", + "stage":stage,"cells":cells,"all_cells_pass":passed, + "evidence_limits":limits,"diagnostic_method":DIAGNOSTIC_METHOD, + "index_sha256":sha_file(root/"index.json")}) + if stage=="full": + _gate(root,"G4",{"status":"PASS" if passed else "INCONCLUSIVE", + "provenance_reconstruction": + "canonical manifests and all chain result hashes reverified", + "index_sha256":sha_file(root/"index.json")}) + if write_complete and passed: + write_protocol_complete(root) + return report + +def write_protocol_complete(root: Path) -> Mapping[str,Any]: + root=Path(root); index=verify_materialization(root); hashes={} + for name in ("G0","G1","G2","G3","G4"): + _require_gate(root,name); hashes[name]=sha_file(root/"gates"/f"{name}.json") + payload={"schema_version":1,"protocol_id":PROTOCOL_ID,"status":"complete", + "index_sha256":sha_file(root/"index.json"), + "meta_manifest_sha256":index["meta_manifest_sha256"], + "gate_report_sha256":hashes, + "claim_boundary":"mu=0 finite-temperature scaling only; no finite-density ground-state or rapid-mixing claim"} + write_json(root/"COMPLETE",payload,True); return payload + +def _execution(args: argparse.Namespace) -> Mapping[str,Any]: + value=json.loads(json.dumps(DEFAULT_EXECUTION)) + for stage in ("g1","production"): + for key in ("steps","warmup","measure_every","checkpoint_every","rebuild_every"): + override=getattr(args,f"{stage}_{key}",None) + if override is not None: value[stage][key]=override + return value + +def main(argv: Optional[Sequence[str]]=None) -> int: + parser=argparse.ArgumentParser(description=__doc__) + sub=parser.add_subparsers(dest="command",required=True) + make=sub.add_parser("materialize") + make.add_argument("--meta",type=Path,required=True) + make.add_argument("--output",type=Path,required=True) + for stage in ("g1","production"): + for key in ("steps","warmup","measure_every","checkpoint_every","rebuild_every"): + make.add_argument(f"--{stage}-{key.replace('_','-')}", + dest=f"{stage}_{key}",type=int) + check=sub.add_parser("validate"); check.add_argument("--root",type=Path,required=True) + g0=sub.add_parser("record-g0"); g0.add_argument("--root",type=Path,required=True) + g0.add_argument("--tests-exit-code",type=int,required=True) + inspect=sub.add_parser("audit"); inspect.add_argument("--root",type=Path,required=True) + inspect.add_argument("--stage",choices=("g1","pilot","full"),required=True) + inspect.add_argument("--write-complete",action="store_true") + args=parser.parse_args(argv) + if args.command=="materialize": + result=materialize(args.meta,args.output,_execution(args)) + elif args.command=="validate": + result=verify_materialization(args.root) + elif args.command=="record-g0": + result=record_g0(args.root,args.tests_exit_code) + else: + result=audit(args.root,args.stage,args.write_complete) + print(json.dumps({"protocol_id":PROTOCOL_ID,"command":args.command, + "status":result.get("status","ok")}, + sort_keys=True,allow_nan=False),flush=True) + return 2 if args.command=="audit" and result.get("status")!="PASS" else 0 + +if __name__=="__main__": + raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json new file mode 100644 index 000000000..630e8b76f --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json @@ -0,0 +1,248 @@ +{ + "schema_version": 1, + "document_type": "preregistered_large_lattice_run", + "issue": 121, + "team": "Genshin_Impact", + "status": "ratified_setup_frozen_pending_gates", + "ratification": { + "required_before_any_compute": true, + "status": "confirmed", + "confirmed_at": "2026-07-30 Asia/Shanghai", + "confirmation_text": "\u786e\u8ba4\u8be5\u5927\u7cfb\u7edf\u8bbe\u7f6e", + "scope": "One confirm-or-correct of model, signs, lattice, boundary, observables, and grid.", + "rule": "Ratification is satisfied. Any physics-parameter or measurement-protocol change requires a versioned amendment and renewed ratification." + }, + "model": { + "fermions": "spinless, one orbital per site", + "particle_number_conserving": true, + "chemical_potential_mu": 0.0, + "lattice": { + "type": "periodic triangular L by L", + "boundary_conditions": "periodic in both primitive directions", + "vertices": "all elementary up and down triangles", + "sites": "N=L*L", + "triangle_count": "2*N for production sizes" + }, + "local_parameters": { + "epsilon": 0.01, + "epsilon_exact": "1/100", + "kappa": 0.02, + "kappa_exact": "1/50", + "s": 0.25, + "s_exact": "1/4", + "g_A": 0.25, + "g_A_exact": "1/4", + "g_B": 0.25, + "g_B_exact": "1/4" + } + }, + "analytic_qa_bound": { + "provenance": "analytic", + "q_exact": "exp(-kappa*s)=exp(-1/200)", + "q_approx": "0.995012 (analytic approximation)", + "word_bound": "For the subspace U of sites touched by a nonempty fixed-s word, ||T_U||_infinity <= q < 1, using the last local factor touching each row.", + "strict_weight": "det(I+T)>0 for every configuration; untouched sites contribute identity blocks.", + "inverse_bound": "||(I+T_U)^(-1)||_infinity <= 1/(1-q)", + "condition_bound": "cond_infinity(I+T_U) <= (1+q)/(1-q), approximately 400 (analytic)", + "qa_consequence": "Any computed zero or negative weight is an implementation or numerical-stability failure, not an allowed boundary case." + }, + "grid": { + "sizes": [ + {"L": 4, "N": 16}, + {"L": 6, "N": 36}, + {"L": 8, "N": 64}, + {"L": 12, "N": 144}, + {"L": 16, "N": 256} + ], + "beta": [0.5, 1.0, 2.0, 4.0], + "beta_exact": ["1/2", "1", "2", "4"], + "full_cells": 20 + }, + "randomness": { + "engine": "NumPy PCG64DXSM; exact package version frozen in run snapshot", + "chains_per_cell": 4, + "seed_rule": "121000000 + 10000*L + 10*beta_index + chain_id", + "beta_index": {"1/2": 0, "1": 1, "2": 2, "4": 3}, + "chains": [ + {"chain_id": 0, "start": "cold", "initial_order": 0}, + {"chain_id": 1, "start": "cold", "initial_order": 0}, + {"chain_id": 2, "start": "hot", "initial_order": "round(beta*N)"}, + {"chain_id": 3, "start": "hot", "initial_order": "round(beta*N)"} + ], + "hot_start_rule": "Ordered CT times are analytically integrated into beta^m/m!; at initial_order=round(beta*N), draw each resolved word label independently from q(a)=lambda_a/G0 (uniform among 2*N triangles, equal A/B probability, and uniform S3 at the frozen equal couplings).", + "algebra_test_seed": 121, + "ed_fixture_seed": 121000121, + "independent_audit_seed": 121999999, + "seed_policy": "Seeds are immutable; diagnose a failed chain rather than replace it." + }, + "measurement_protocol": { + "real_space_green": { + "rule": "all lattice displacements", + "indices": "all (dx,dy) with 0<=dx-^2)/N", + "translation-averaged equal-time Green function G(r)", + "density structure factor S_n(q)" + ], + "diagnostic": [ + "expansion order and insertion/deletion acceptance", + "determinant sign and zero/negative weight counts", + "fast-vs-rebuild relative error and inverse residual", + "R-hat, bulk ESS, tail ESS, and tau_int", + "time per proposal and sweep", + "peak resident memory and scaling" + ] + }, + "thresholds": { + "deterministic_absolute_tolerance": 1e-10, + "fast_vs_rebuild_relative_error_max": 1e-9, + "inverse_residual_max": 1e-8, + "negative_sign_count_required": 0, + "zero_weight_count_required": 0, + "analytic_condition_number_upper_approx": 400, + "pilot_acceptance_target": [0.2, 0.7], + "full_acceptance_hard_range": [0.1, 0.9], + "r_hat_max": 1.01, + "bulk_ess_min": 1000, + "tail_ess_min": 400, + "ed_z_score_max": 5.0, + "scalability_claim_rule": "Withhold scalability if speedup is not above 2 by N=144, update time scales worse than N^2.7, or memory worse than N^2.5 after excluding N=16." + }, + "resources": { + "policy": "proposed/TBD based on pilot", + "pilot": { + "partition": null, + "nodes": null, + "cpus_per_task": null, + "gpus": null, + "memory_gb": null, + "walltime": null, + "status": "proposed/TBD; inspect live Slurm state before submission" + }, + "full": { + "partition": null, + "nodes": null, + "cpus_per_task": null, + "gpus": null, + "memory_gb": null, + "walltime": null, + "status": "proposed/TBD from accepted pilot throughput, memory, and tau_int" + }, + "submission_rule": "Assume no partition. Check sinfo, squeue, and node State/CfgTRES/AllocTRES before each submission; use durable stages and afterok dependencies." + }, + "stop_fail_conditions": [ + "No compute before setup ratification and no gate skipping.", + "Any computed zero or negative weight is a hard failure, never a discarded sample.", + "Persistent fast-vs-rebuild mismatch or residual above threshold stops the run.", + "Acceptance outside the full hard range after pilot-frozen tuning fails or makes the cell inconclusive.", + "R-hat or ESS failure after equal extension to the pilot-frozen cap makes the cell inconclusive.", + "OOM, timeout, missing durable checkpoint, or missing completion sentinel is failure.", + "Do not start L greater than 12 before a stable, faster rank-3 update passes the pilot.", + "Never change seeds, discard chains, or retune physics after inspecting full-grid observables.", + "State the mu=0 low-temperature vacuum and unresolved itinerant finite-density problem in every interpretation." + ], + "interpretation_limits": { + "mu_zero_low_temperature": "The positive-semidefinite construction has a vacuum ground state at mu=0, so low-temperature density can be trivial.", + "finite_density": "No nontrivial itinerant finite-density sign-free extension is preregistered here.", + "claim_scope": "A pass supports this fixed mu=0 correctness and scaling benchmark only." + } +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py new file mode 100644 index 000000000..773e72ef7 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py @@ -0,0 +1,1090 @@ +from __future__ import annotations + +from collections import Counter, deque +from copy import deepcopy +import hashlib +import json +import math +from pathlib import Path +from typing import Any, Sequence + +import numpy as np +import pytest + +import large_lattice_ctqmc as ctqmc +import large_lattice_ed as ed + + +EPSILON = 1.0 / 100.0 +KAPPA = 1.0 / 50.0 +VERTEX_STRENGTH = 1.0 / 4.0 +G_A = 1.0 / 4.0 +G_B = 1.0 / 4.0 +CONDITION_MAX = 1.0e12 + + +def _geometry(lx: int = 4, ly: int = 3) -> ctqmc.TriangularGeometry: + return ctqmc.build_triangular_geometry(lx, ly) + + +def _catalog() -> list[ctqmc.LocalVertex]: + return ctqmc.build_vertex_catalog( + EPSILON, + KAPPA, + VERTEX_STRENGTH, + G_A, + G_B, + ) + + +def _event(value: tuple[int, int]) -> ctqmc.Event: + return ctqmc.Event(int(value[0]), int(value[1])) + + +def _events(word: Sequence[tuple[int, int]]) -> list[ctqmc.Event]: + return [_event(value) for value in word] + + +def _sites( + geometry: ctqmc.TriangularGeometry, + value: tuple[int, int], +) -> tuple[int, int, int]: + return geometry.triangles[value[0]].sites + + +def _embedded_factor( + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], + value: tuple[int, int], + *, + inverse: bool = False, +) -> np.ndarray: + result = np.eye(geometry.n_sites) + sites = _sites(geometry, value) + vertex = catalog[value[1]] + block = vertex.block_inv if inverse else vertex.block + result[np.ix_(sites, sites)] = np.asarray(block) + return result + + +def _full_product( + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], + word: Sequence[tuple[int, int]], +) -> np.ndarray: + product = np.eye(geometry.n_sites) + for value in word: + product = _embedded_factor(geometry, catalog, value) @ product + return product + + +def _proposal( + factors: ctqmc.DenseFactors, + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], + value: tuple[int, int], + *, + inverse: bool = False, +) -> ctqmc.LowRankProposal: + vertex = catalog[value[1]] + block = vertex.block_inv if inverse else vertex.block + return ctqmc.low_rank_left_proposal( + factors, + _sites(geometry, value), + block, + condition_max=CONDITION_MAX, + ) + + +def _acceptance(log_acceptance: float) -> float: + return math.exp(float(log_acceptance)) + + +def _word_weight( + beta: float, + catalog: Sequence[ctqmc.LocalVertex], + word: Sequence[tuple[int, int]], + logdet: float, +) -> float: + activity_product = math.prod( + float(catalog[value[1]].activity) for value in word + ) + return ( + beta ** len(word) + / math.factorial(len(word)) + * activity_product + * math.exp(logdet) + ) + + +def _manifest( + *, + lx: int = 2, + ly: int = 2, + steps: int = 20, + warmup: int = 2, + seed: int = 121_2026, + mode: str = "cold", + initial_order: int = 0, +) -> dict[str, Any]: + return { + "schema_version": 1, + "lattice": {"Lx": lx, "Ly": ly}, + "model": { + "epsilon": EPSILON, + "kappa": KAPPA, + "vertex_strength": VERTEX_STRENGTH, + "g_A": G_A, + "g_B": G_B, + "beta": 0.5, + }, + "monte_carlo": { + "steps": steps, + "warmup": warmup, + "measure_every": 1, + "checkpoint_every": max(1, steps // 2), + "rebuild_every": 7, + "seed": seed, + "woodbury_condition_max": CONDITION_MAX, + "move_probabilities": { + "insert": 0.35, + "delete": 0.35, + "rotate_left_to_right": 0.15, + "rotate_right_to_left": 0.15, + }, + "initialization": { + "mode": mode, + "initial_order": initial_order, + }, + }, + "measurements": { + "momenta": [[0, 0], [1, 0], [0, 1]], + "displacements": [[0, 0], [1, 0], [0, 1]], + }, + "exact_diagonalization": {"hermitian_tolerance": 1.0e-10}, + } + + +def _sampler( + tmp_path: Path, + *, + mode: str = "cold", + initial_order: int = 0, + seed: int = 121_2026, +) -> ctqmc.CTQMC: + return ctqmc.CTQMC.from_manifest( + _manifest( + mode=mode, + initial_order=initial_order, + seed=seed, + ), + tmp_path, + manifest_sha256="unit-test-manifest", + ) + + +def _oracle_input( + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], +) -> ed.OracleInput: + return ed.OracleInput( + "unit-test-manifest", + geometry, + tuple(catalog), + { + "epsilon": EPSILON, + "kappa": KAPPA, + "vertex_strength": VERTEX_STRENGTH, + "g_A": G_A, + "g_B": G_B, + "beta": 0.5, + }, + ((0, 0), (1, 0), (0, 1)), + 1.0e-10, + ) + + +def _assert_complex_pair_close( + actual: Sequence[float], + expected: Sequence[float], + *, + atol: float, +) -> None: + np.testing.assert_allclose( + np.asarray(actual, dtype=float), + np.asarray(expected, dtype=float), + rtol=0.0, + atol=atol, + ) + + +def test_triangular_geometry_vertex_count_and_g0() -> None: + geometry = _geometry(4, 3) + catalog = _catalog() + + assert geometry.n_sites == 12 + assert geometry.n_triangles == 2 * geometry.n_sites == 24 + assert [triangle.triangle_id for triangle in geometry.triangles] == list( + range(geometry.n_triangles) + ) + assert len({triangle.sites for triangle in geometry.triangles}) == 24 + assert all( + len(set(triangle.sites)) == 3 for triangle in geometry.triangles + ) + assert all( + 0 <= site < geometry.n_sites + for triangle in geometry.triangles + for site in triangle.sites + ) + + assert len(catalog) == 2 * math.factorial(3) == 12 + assert {vertex.family for vertex in catalog} == {"A", "B"} + assert [vertex.vertex_id for vertex in catalog] == list(range(12)) + assert all(vertex.activity > 0.0 for vertex in catalog) + assert all(vertex.block.shape == (3, 3) for vertex in catalog) + assert all(vertex.block_inv.shape == (3, 3) for vertex in catalog) + + resolved_event_count = geometry.n_triangles * len(catalog) + assert resolved_event_count == 24 * 12 + g0 = geometry.n_triangles * sum( + vertex.activity for vertex in catalog + ) + expected_g0 = geometry.n_triangles * (G_A + G_B) + assert g0 == pytest.approx(expected_g0, rel=0.0, abs=1.0e-14) + + +def test_l2_periodic_fixture_keeps_directed_triangle_multiplicity() -> None: + geometry = _geometry(2, 2) + + assert geometry.n_sites == 4 + assert geometry.n_triangles == 8 + assert all( + len(set(triangle.sites)) == 3 for triangle in geometry.triangles + ) + undirected = Counter( + frozenset(triangle.sites) for triangle in geometry.triangles + ) + assert len(undirected) == 4 + assert set(undirected.values()) == {2} + assert Counter( + triangle.orientation for triangle in geometry.triangles + ) == {"up": 4, "down": 4} + + +def test_l3_triangles_are_unique_and_each_site_has_incidence_six() -> None: + geometry = _geometry(3, 3) + + assert geometry.n_sites == 9 + assert geometry.n_triangles == 18 + assert len({triangle.sites for triangle in geometry.triangles}) == 18 + assert len( + {frozenset(triangle.sites) for triangle in geometry.triangles} + ) == 18 + incidence = Counter( + site + for triangle in geometry.triangles + for site in triangle.sites + ) + assert incidence == {site: 6 for site in range(geometry.n_sites)} + + +@pytest.mark.parametrize("depth", [0, 1, 2, 5, 13]) +def test_structured_product_matches_full_embedded_factors( + depth: int, +) -> None: + geometry = _geometry() + catalog = _catalog() + rng = np.random.default_rng(121_000 + depth) + word = [ + ( + int(rng.integers(geometry.n_triangles)), + int(rng.integers(len(catalog))), + ) + for _ in range(depth) + ] + + structured = ctqmc.structured_product( + geometry.n_sites, + geometry.triangles, + catalog, + _events(word), + ) + full = _full_product(geometry, catalog, word) + np.testing.assert_allclose( + structured, + full, + rtol=3.0e-13, + atol=3.0e-13, + ) + + +def test_insert_delete_small_determinant_ratio_matches_full() -> None: + geometry = _geometry(3, 3) + catalog = _catalog() + word = [(0, 0), (2, 7), (5, 3), (1, 10)] + value = (4, 5) + product = _full_product(geometry, catalog, word) + factors = ctqmc.factor_dense(product) + + insertion = _proposal(factors, geometry, catalog, value) + inserted = ctqmc.apply_low_rank_proposal(factors, insertion) + full_inserted = _embedded_factor( + geometry, + catalog, + value, + ) @ product + old_det = np.linalg.det(np.eye(geometry.n_sites) + product) + new_det = np.linalg.det(np.eye(geometry.n_sites) + full_inserted) + + assert math.exp(insertion.log_det_ratio) == pytest.approx( + new_det / old_det, + rel=2.0e-11, + abs=2.0e-12, + ) + assert inserted.logdet == pytest.approx( + math.log(new_det), + rel=2.0e-11, + ) + np.testing.assert_allclose( + inserted.T, + full_inserted, + rtol=2.0e-12, + atol=2.0e-12, + ) + + deletion = _proposal( + inserted, + geometry, + catalog, + value, + inverse=True, + ) + restored = ctqmc.apply_low_rank_proposal(inserted, deletion) + assert math.exp(deletion.log_det_ratio) == pytest.approx( + old_det / new_det, + rel=2.0e-11, + abs=2.0e-12, + ) + np.testing.assert_allclose( + restored.T, + product, + rtol=3.0e-12, + atol=3.0e-12, + ) + np.testing.assert_allclose( + restored.Q, + factors.Q, + rtol=3.0e-11, + atol=3.0e-12, + ) + + +def test_woodbury_q_matches_direct_inverse() -> None: + geometry = _geometry(3, 3) + catalog = _catalog() + word = [(0, 1), (1, 4), (3, 9), (5, 2), (2, 11)] + factors = ctqmc.factor_dense( + _full_product(geometry, catalog, word) + ) + value = (4, 8) + + proposal = _proposal(factors, geometry, catalog, value) + assert proposal.T_new is not None + assert proposal.Q_new is not None + expected_q = np.linalg.inv( + np.eye(geometry.n_sites) + proposal.T_new + ) + np.testing.assert_allclose( + proposal.Q_new, + expected_q, + rtol=3.0e-11, + atol=3.0e-12, + ) + assert proposal.local_solve_residual_inf <= 1.0e-9 + + applied = ctqmc.apply_low_rank_proposal(factors, proposal) + np.testing.assert_allclose( + applied.Q, + expected_q, + rtol=3.0e-11, + atol=3.0e-12, + ) + assert ctqmc.inverse_residual_inf(applied.T, applied.Q) <= 1.0e-9 + + +def test_both_cyclic_rotation_matrix_directions() -> None: + geometry = _geometry(3, 3) + catalog = _catalog() + word = [(0, 0), (2, 5), (4, 9), (1, 3)] + product = _full_product(geometry, catalog, word) + factors = ctqmc.factor_dense(product) + + left_value = word[-1] + left_factor = _embedded_factor(geometry, catalog, left_value) + expected_ltr = np.linalg.inv(left_factor) @ product @ left_factor + ltr = ctqmc.rotate_left_factor_to_right( + factors, + _event(left_value), + geometry.triangles, + catalog, + ) + np.testing.assert_allclose( + ltr.T, + expected_ltr, + rtol=3.0e-11, + atol=3.0e-12, + ) + np.testing.assert_allclose( + ltr.Q, + np.linalg.inv(left_factor) @ factors.Q @ left_factor, + rtol=3.0e-11, + atol=3.0e-12, + ) + assert ltr.logdet == pytest.approx(factors.logdet, abs=3.0e-12) + + right_value = word[0] + right_factor = _embedded_factor(geometry, catalog, right_value) + expected_rtl = right_factor @ product @ np.linalg.inv(right_factor) + rtl = ctqmc.rotate_right_factor_to_left( + factors, + _event(right_value), + geometry.triangles, + catalog, + ) + np.testing.assert_allclose( + rtl.T, + expected_rtl, + rtol=3.0e-11, + atol=3.0e-12, + ) + np.testing.assert_allclose( + rtl.Q, + right_factor @ factors.Q @ np.linalg.inv(right_factor), + rtol=3.0e-11, + atol=3.0e-12, + ) + assert rtl.logdet == pytest.approx(factors.logdet, abs=3.0e-12) + + +def test_word_deque_rotation_matches_product_convention( + tmp_path: Path, +) -> None: + sampler = _sampler(tmp_path) + original = [_event(value) for value in [(0, 0), (2, 5), (4, 9)]] + sampler.word = deque(original) + sampler.rebuild("rotation-fixture", compare_fast=False) + + assert sampler._rotate_ltr() + assert list(sampler.word) == [original[-1], *original[:-1]] + expected = ctqmc.structured_product( + sampler.geometry.n_sites, + sampler.geometry.triangles, + sampler.catalog, + list(sampler.word), + ) + np.testing.assert_allclose( + sampler.factors.T, + expected, + rtol=3.0e-11, + atol=3.0e-12, + ) + + assert sampler._rotate_rtl() + assert list(sampler.word) == original + expected_original = ctqmc.structured_product( + sampler.geometry.n_sites, + sampler.geometry.triangles, + sampler.catalog, + original, + ) + np.testing.assert_allclose( + sampler.factors.T, + expected_original, + rtol=3.0e-11, + atol=3.0e-12, + ) + + +def test_microscopic_forward_reverse_acceptance_flux() -> None: + geometry = _geometry(3, 3) + catalog = _catalog() + beta = 0.7 + word = [(0, 0), (2, 7), (3, 4)] + value = (5, 10) + old = ctqmc.factor_dense(_full_product(geometry, catalog, word)) + insertion = _proposal(old, geometry, catalog, value) + new = ctqmc.apply_low_rank_proposal(old, insertion) + deletion = _proposal( + new, + geometry, + catalog, + value, + inverse=True, + ) + + label_probability = ( + catalog[value[1]].activity + / ( + geometry.n_triangles + * sum(vertex.activity for vertex in catalog) + ) + ) + p_insert = 0.41 + p_delete = 0.37 + activity = float(catalog[value[1]].activity) + log_forward = ctqmc.log_accept_insert( + beta, + activity, + len(word), + insertion.log_det_ratio, + p_insert, + p_delete, + label_probability, + ) + log_reverse = ctqmc.log_accept_delete( + beta, + activity, + len(word) + 1, + deletion.log_det_ratio, + p_insert, + p_delete, + label_probability, + ) + + old_weight = _word_weight(beta, catalog, word, old.logdet) + new_word = [*word, value] + new_weight = _word_weight(beta, catalog, new_word, new.logdet) + forward_flux = ( + old_weight + * p_insert + * label_probability + * _acceptance(log_forward) + ) + reverse_flux = ( + new_weight + * p_delete + * _acceptance(log_reverse) + ) + assert forward_flux == pytest.approx( + reverse_flux, + rel=2.0e-11, + abs=1.0e-14, + ) + + +def test_empty_word_boundary_keeps_delete_as_self_loop( + tmp_path: Path, +) -> None: + sampler = _sampler(tmp_path) + before_t = sampler.factors.T.copy() + before_q = sampler.factors.Q.copy() + before_logdet = sampler.factors.logdet + + assert len(sampler.word) == 0 + assert not sampler._delete() + assert len(sampler.word) == 0 + np.testing.assert_array_equal(sampler.factors.T, before_t) + np.testing.assert_array_equal(sampler.factors.Q, before_q) + assert sampler.factors.logdet == before_logdet + assert sampler.counters["moves"]["delete"] == { + "attempted": 1, + "accepted": 0, + } + + with pytest.raises(ValueError, match="m>=1"): + ctqmc.log_accept_delete( + 1.0, + 1.0 / 24.0, + 0, + 0.0, + 0.35, + 0.35, + 1.0 / 96.0, + ) + + +def test_observable_formulas_momenta_real_space_and_compressibility() -> None: + geometry = _geometry(2, 2) + catalog = _catalog() + word = [(0, 0), (2, 7), (5, 3)] + factors = ctqmc.factor_dense( + _full_product(geometry, catalog, word) + ) + beta = 0.5 + g0 = geometry.n_triangles * (G_A + G_B) + momenta = [(0, 0), (1, 0)] + displacements = [(0, 0), (1, 0), (0, 1)] + observed = ctqmc.measure_configuration( + factors, + geometry, + beta, + g0, + len(word), + momenta, + displacements, + ) + + green = (np.eye(geometry.n_sites) - factors.Q).T + density = np.diag(green) + density_pair = np.outer(density, density) - green * green.T + np.fill_diagonal(density_pair, density) + particle_number = float(density.sum()) + particle_number_squared = float(density_pair.sum()) + + assert observed["energy_density"] == pytest.approx( + (g0 - len(word) / beta) / geometry.n_sites + ) + assert observed["particle_number"] == pytest.approx(particle_number) + assert observed["particle_number_squared"] == pytest.approx( + particle_number_squared + ) + assert observed["particle_density"] == pytest.approx( + particle_number / geometry.n_sites + ) + + x = geometry.coordinates[:, 0] + y = geometry.coordinates[:, 1] + for kx, ky in momenta: + phase = np.exp( + 2.0j + * math.pi + * (kx * x / geometry.Lx + ky * y / geometry.Ly) + ) + expected_one = np.vdot(phase, green @ phase) / geometry.n_sites + expected_raw = ( + np.vdot(phase, density_pair @ phase) / geometry.n_sites + ) + expected_mode = ( + np.vdot(phase, density) / math.sqrt(geometry.n_sites) + ) + values = observed["momenta"][f"{kx},{ky}"] + _assert_complex_pair_close( + values["one_body"], + [expected_one.real, expected_one.imag], + atol=3.0e-12, + ) + _assert_complex_pair_close( + values["density_raw"], + [expected_raw.real, expected_raw.imag], + atol=3.0e-12, + ) + _assert_complex_pair_close( + values["density_mode"], + [expected_mode.real, expected_mode.imag], + atol=3.0e-12, + ) + + for dx, dy in displacements: + expected = 0.0 + for sx in range(geometry.Lx): + for sy in range(geometry.Ly): + i = sx * geometry.Ly + sy + j = ( + ((sx + dx) % geometry.Lx) * geometry.Ly + + (sy + dy) % geometry.Ly + ) + expected += float(green[i, j]) + expected /= geometry.n_sites + _assert_complex_pair_close( + observed["real_space_green"][f"{dx},{dy}"], + [expected, 0.0], + atol=3.0e-12, + ) + + accumulator = ctqmc.ObservableAccumulator() + accumulator.add(observed) + summary = accumulator.summary(beta, geometry.n_sites) + expected_compressibility = ( + beta + * (particle_number_squared - particle_number**2) + / geometry.n_sites + ) + assert summary["compressibility"] == pytest.approx( + expected_compressibility, + abs=3.0e-12, + ) + assert summary["primary_traces"]["particle_number"] == [ + particle_number + ] + zero_momentum = summary["momentum"]["0,0"] + raw = zero_momentum["density_raw"]["mean"] + mode = zero_momentum["density_mode"]["mean"] + assert zero_momentum["density_connected_from_means"] == pytest.approx( + [raw[0] - mode[0] ** 2 - mode[1] ** 2, raw[1]] + ) + + +def test_fock_gamma_one_particle_block_has_destination_source_orientation() -> None: + geometry = _geometry(2, 2) + catalog = _catalog() + matrix = _embedded_factor(geometry, catalog, (0, 7)) + layout = ed.build_fock_layout(geometry.n_sites) + + gamma, residual = ed.fock_gamma(matrix, layout) + one_particle_masks = list(layout.sectors[1].masks) + one_particle_block = gamma[ + np.ix_(one_particle_masks, one_particle_masks) + ] + np.testing.assert_allclose( + one_particle_block, + matrix, + rtol=0.0, + atol=2.0e-14, + ) + assert residual <= 2.0e-14 + destination = 2 + source = 1 + assert one_particle_block[destination, source] == pytest.approx( + matrix[destination, source] + ) + + +def test_ed_hamiltonian_is_hermitian_and_uses_all_resolved_terms() -> None: + geometry = _geometry(2, 2) + catalog = _catalog() + oracle = _oracle_input(geometry, catalog) + layout = ed.build_fock_layout(geometry.n_sites) + + hamiltonian, diagnostics = ed.build_hamiltonian(oracle, layout) + np.testing.assert_allclose( + hamiltonian, + hamiltonian.conj().T, + rtol=0.0, + atol=2.0e-11, + ) + assert diagnostics["resolved_term_count"] == ( + geometry.n_triangles * len(catalog) + ) + assert diagnostics["G0"] == pytest.approx( + geometry.n_triangles * (G_A + G_B) + ) + assert diagnostics["hermitian_residual_relative_inf"] <= 1.0e-10 + + +def test_ed_conditional_gaussian_matches_sampler_observable_conventions() -> None: + geometry = _geometry(2, 2) + catalog = _catalog() + word = [(0, 1), (2, 8), (7, 4)] + product = _full_product(geometry, catalog, word) + factors = ctqmc.factor_dense(product) + layout = ed.build_fock_layout(geometry.n_sites) + gamma, orientation_residual = ed.fock_gamma(product, layout) + density_matrix = gamma / np.trace(gamma) + + green = ed.one_body_green(density_matrix, geometry.n_sites) + density, density_pair, number, number2 = ed.density_moments( + density_matrix, + geometry.n_sites, + ) + momenta = [(0, 0), (1, 0), (0, 1)] + exact_momentum = ed.momentum_observables( + geometry, + green, + density, + density_pair, + momenta, + ) + measured = ctqmc.measure_configuration( + factors, + geometry, + 0.5, + geometry.n_triangles * (G_A + G_B), + len(word), + momenta, + ) + + assert orientation_residual <= 2.0e-14 + assert measured["particle_number"] == pytest.approx( + number, + abs=3.0e-12, + ) + assert measured["particle_number_squared"] == pytest.approx( + number2, + abs=3.0e-12, + ) + for momentum in exact_momentum: + for name in ("one_body", "density_raw", "density_mode"): + _assert_complex_pair_close( + measured["momenta"][momentum][name], + exact_momentum[momentum][name], + atol=4.0e-12, + ) + + +def test_ed_hard_rejects_more_than_nine_sites() -> None: + with pytest.raises(ed.EDOracleError, match="1<=N<=9"): + ed.build_fock_layout(10) + + +def test_hot_cold_initialization_and_pcg64dxsm(tmp_path: Path) -> None: + cold = _sampler(tmp_path / "cold") + hot = _sampler( + tmp_path / "hot", + mode="hot", + initial_order=7, + seed=121_2027, + ) + + assert isinstance(cold.rng.bit_generator, np.random.PCG64DXSM) + assert isinstance(hot.rng.bit_generator, np.random.PCG64DXSM) + assert len(cold.word) == 0 + assert cold.initialization == {"mode": "cold", "initial_order": 0} + assert len(hot.word) == 7 + assert hot.initialization == {"mode": "hot", "initial_order": 7} + hot_product = ctqmc.structured_product( + hot.geometry.n_sites, + hot.geometry.triangles, + hot.catalog, + list(hot.word), + ) + np.testing.assert_allclose( + hot.factors.T, + hot_product, + rtol=0.0, + atol=2.0e-14, + ) + + bad_cold = _manifest(mode="cold", initial_order=1) + with pytest.raises(ctqmc.ManifestError, match="cold"): + ctqmc.CTQMC.from_manifest(bad_cold, tmp_path / "bad-cold") + bad_hot = _manifest(mode="hot", initial_order=0) + with pytest.raises(ctqmc.ManifestError, match="hot"): + ctqmc.CTQMC.from_manifest(bad_hot, tmp_path / "bad-hot") + + +def test_rebuild_records_logdet_t_q_and_residual_drift( + tmp_path: Path, +) -> None: + sampler = _sampler( + tmp_path, + mode="hot", + initial_order=5, + ) + value = (3, 6) + proposal = _proposal( + sampler.factors, + sampler.geometry, + sampler.catalog, + value, + ) + sampler.factors = ctqmc.apply_low_rank_proposal( + sampler.factors, + proposal, + ) + sampler.word.append(_event(value)) + + fast = sampler.factors + rebuilt_product = ctqmc.structured_product( + sampler.geometry.n_sites, + sampler.geometry.triangles, + sampler.catalog, + list(sampler.word), + ) + expected = ctqmc.factor_dense(rebuilt_product) + expected_delta = expected.logdet - fast.logdet + expected_t_drift = ( + np.linalg.norm(expected.T - fast.T, ord=np.inf) + / max(1.0, np.linalg.norm(expected.T, ord=np.inf)) + ) + expected_q_drift = ( + np.linalg.norm(expected.Q - fast.Q, ord=np.inf) + / max(1.0, np.linalg.norm(expected.Q, ord=np.inf)) + ) + expected_fast_residual = ctqmc.inverse_residual_inf( + fast.T, + fast.Q, + ) + + sampler.rebuild("unit-drift") + diagnostic = sampler.rebuild_diagnostics[-1] + assert diagnostic["reason"] == "unit-drift" + assert diagnostic["fast_inverse_residual_inf"] == pytest.approx( + expected_fast_residual + ) + assert diagnostic["rebuilt_inverse_residual_inf"] == pytest.approx( + expected.inverse_residual_inf + ) + assert diagnostic["delta_logdet"] == pytest.approx(expected_delta) + assert diagnostic["relative_T_drift_inf"] == pytest.approx( + expected_t_drift + ) + assert diagnostic["relative_Q_drift_inf"] == pytest.approx( + expected_q_drift + ) + np.testing.assert_allclose(sampler.factors.T, expected.T) + np.testing.assert_allclose(sampler.factors.Q, expected.Q) + + +def test_checkpoint_roundtrip_preserves_word_rng_and_primary_traces( + tmp_path: Path, +) -> None: + sampler = _sampler( + tmp_path, + mode="hot", + initial_order=6, + seed=121_2030, + ) + sampler.moves_since_rebuild = 5 + sampler.completed_steps = 11 + observation = ctqmc.measure_configuration( + sampler.factors, + sampler.geometry, + sampler.beta, + sampler.G0, + len(sampler.word), + sampler.momenta, + sampler.displacements, + ) + sampler.accumulator.add(observation) + sampler.save_checkpoint("running") + + saved = json.loads( + (tmp_path / "checkpoint.json").read_text(encoding="utf-8") + ) + assert saved["rng_state"]["bit_generator"] == "PCG64DXSM" + assert saved["moves_since_rebuild"] == 5 + assert saved["accumulator"]["primary_traces"] == ( + sampler.accumulator.primary_traces + ) + expected_random = sampler.rng.random(8) + + restored = _sampler( + tmp_path, + mode="hot", + initial_order=6, + seed=121_2030, + ) + restored.load_checkpoint() + actual_random = restored.rng.random(8) + + assert restored.completed_steps == 11 + assert restored.moves_since_rebuild == 5 + assert list(restored.word) == list(sampler.word) + assert restored.accumulator.state() == sampler.accumulator.state() + np.testing.assert_array_equal(actual_random, expected_random) + expected_t = ctqmc.structured_product( + restored.geometry.n_sites, + restored.geometry.triangles, + restored.catalog, + list(restored.word), + ) + np.testing.assert_allclose( + restored.factors.T, + expected_t, + rtol=0.0, + atol=2.0e-14, + ) + np.testing.assert_allclose( + restored.factors.Q, + np.linalg.inv(np.eye(restored.geometry.n_sites) + expected_t), + rtol=3.0e-12, + atol=3.0e-13, + ) + + +@pytest.mark.slow +def test_n4_ed_mcmc_interface_and_complete_protocol( + tmp_path: Path, +) -> None: + manifest = _manifest( + lx=2, + ly=2, + steps=30_000, + warmup=3_000, + seed=121_2040, + mode="hot", + initial_order=2, + ) + manifest_path = tmp_path / "manifest.json" + ctqmc.atomic_write_json(manifest_path, manifest) + exact = ed.run_oracle(manifest_path) + + run_dir = tmp_path / "mcmc" + sampler = ctqmc.CTQMC.from_manifest( + manifest, + run_dir, + manifest_sha256=exact["runner_manifest_sha256"], + ) + result = sampler.run() + + assert result["status"] == "run_complete_unvalidated" + assert result["scope"] == "single_chain_execution_only" + assert result["geometry"]["n_sites"] == 4 + assert set(result["move_acceptance"]) == { + "insert", + "delete", + "rotate_left_to_right", + "rotate_right_to_left", + } + for values in result["move_acceptance"].values(): + assert values["attempted"] >= values["accepted"] >= 0 + if values["attempted"]: + assert values["rate"] == pytest.approx( + values["accepted"] / values["attempted"] + ) + else: + assert values["rate"] is None + assert result["timing"]["wall_seconds"] >= 0.0 + max_rss_kb = result["resource_usage"]["max_rss_kb"] + assert max_rss_kb is None or max_rss_kb > 0 + assert result["observables"]["count"] > 0 + traces = result["observables"]["primary_traces"] + assert all( + len(values) == result["observables"]["count"] + for values in traces.values() + ) + + scalar = result["observables"]["scalar"] + exact_scalar = exact["observables"]["scalar"] + for name in ("energy_density", "particle_density"): + tolerance = max( + 8.0 * scalar[name]["naive_stderr"], + 0.08, + ) + assert scalar[name]["mean"] == pytest.approx( + exact_scalar[name], + abs=tolerance, + ) + assert result["observables"]["compressibility"] == pytest.approx( + exact_scalar["compressibility"], + abs=0.12, + ) + + for momentum, exact_values in exact["observables"]["momentum"].items(): + sampled = result["observables"]["momentum"][momentum] + for name in ("one_body", "density_raw", "density_mode"): + tolerance = max( + 8.0 * sampled[name]["naive_stderr_abs"], + 0.12, + ) + _assert_complex_pair_close( + sampled[name]["mean"], + exact_values[name], + atol=tolerance, + ) + _assert_complex_pair_close( + sampled["density_connected_from_means"], + exact_values["density_connected_from_means"], + atol=0.15, + ) + + complete_path = run_dir / "CHAIN_COMPLETE" + assert complete_path.is_file() + complete = json.loads(complete_path.read_text(encoding="utf-8")) + result_bytes = (run_dir / "result.json").read_bytes() + assert complete == { + "schema_version": 1, + "status": "run_complete_unvalidated", + "scope": "single_chain_execution_only", + "algorithm_id": ctqmc.ALGORITHM_ID, + "manifest_sha256": exact["runner_manifest_sha256"], + "result_json_sha256": hashlib.sha256(result_bytes).hexdigest(), + "completed_steps": manifest["monte_carlo"]["steps"], + } + + +def test_manifest_helpers_do_not_mutate_input(tmp_path: Path) -> None: + manifest = _manifest() + original = deepcopy(manifest) + ctqmc.CTQMC.from_manifest(manifest, tmp_path) + assert manifest == original diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py new file mode 100644 index 000000000..d9f2237d5 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -0,0 +1,319 @@ +from __future__ import annotations + +from copy import deepcopy +import json +import math +from pathlib import Path + +import numpy as np +import pytest + +import large_lattice_protocol as protocol + + +META = Path(__file__).with_name("large_lattice_run.json") + + +def confirmed_meta() -> dict: + return json.loads(META.read_text(encoding="utf-8")) + + +def small_execution() -> dict: + value = deepcopy(protocol.DEFAULT_EXECUTION) + value["g1"].update( + steps=20, warmup=4, measure_every=2, + checkpoint_every=10, rebuild_every=4, + ) + value["production"].update( + steps=24, warmup=4, measure_every=2, + checkpoint_every=12, rebuild_every=4, + ) + return value + + +def write_meta(path: Path, value: dict) -> None: + protocol.write_json(path, value) + + +def test_pending_and_physics_drift_are_rejected() -> None: + pending = confirmed_meta() + pending["document_type"] = "preregistered_large_lattice_run_draft" + pending["status"] = "proposed_pending_single_setup_ratification" + pending["ratification"]["status"] = "pending" + with pytest.raises(protocol.ProtocolError): + protocol.validate_meta(pending) + drift = confirmed_meta() + drift["model"]["local_parameters"]["kappa"] = 0.021 + with pytest.raises(protocol.ProtocolError, match="kappa"): + protocol.validate_meta(drift) + measurement_drift = confirmed_meta() + measurement_drift["measurement_protocol"]["momenta"]["qmin"].append([1, 1]) + with pytest.raises(protocol.ProtocolError, match="qmin"): + protocol.validate_meta(measurement_drift) + + +def test_strict_json_rejects_nonfinite(tmp_path: Path) -> None: + with pytest.raises(protocol.ProtocolError, match="finite"): + protocol.canonical_bytes({"bad": math.nan}) + bad = tmp_path / "bad.json" + bad.write_text('{"bad": NaN}\n', encoding="utf-8") + with pytest.raises(protocol.ProtocolError, match="finite"): + protocol.load_json(bad) + + +def test_materialization_cardinality_hashes_and_frozen_manifests( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize( + meta_path, root, small_execution() + ) + assert index["counts"] == { + "g1_chains": 32, + "production_chains": 80, + "pilot_chains": 12, + "full_remaining_chains": 68, + } + assert len(index["entries"]) == 112 + assert not (root / "COMPLETE").exists() + assert protocol.verify_materialization(root) == index + + production = [ + entry for entry in index["entries"] + if entry["stage"] == "production" + and entry["L"] == 6 + and entry["beta_index"] == 2 + ] + assert len(production) == 4 + assert [entry["seed"] for entry in production] == [ + 121060020, 121060021, 121060022, 121060023 + ] + manifests = [ + protocol.load_json(root / entry["manifest"]) + for entry in production + ] + assert [item["monte_carlo"]["initialization"] for item in manifests] == [ + {"mode": "cold", "initial_order": 0}, + {"mode": "cold", "initial_order": 0}, + {"mode": "hot", "initial_order": 72}, + {"mode": "hot", "initial_order": 72}, + ] + first = manifests[0] + assert first["model"] == { + "epsilon": "1/100", + "kappa": "1/50", + "vertex_strength": "1/4", + "g_A": "1/4", + "g_B": "1/4", + "beta": "2", + } + measurements = first["measurements"] + assert len(measurements["displacements"]) == 36 + assert measurements["momenta"] == [ + [0, 0], [1, 0], [0, 1], + [3, 0], [0, 3], [3, 3], + [2, 4], [4, 2], + ] + labels = measurements["momentum_labels"] + assert labels["Gamma"] == [0, 0] + assert labels["qmin"] == [[1, 0], [0, 1]] + assert labels["M_points"] == { + "condition": "L even", + "indices": [[3, 0], [0, 3], [3, 3]], + } + assert labels["K_points"] == { + "condition": "L%3==0", + "indices": [[2, 4], [4, 2]], + } + assert labels["K_note"] == "two exact K points included" + + def manifest_for(size: int) -> dict: + return next( + protocol.load_json(root / entry["manifest"]) + for entry in index["entries"] + if entry["stage"] == "production" + and entry["L"] == size + and entry["beta_index"] == 0 + and entry["chain_id"] == 0 + ) + + l4 = manifest_for(4) + assert len(l4["measurements"]["displacements"]) == 16 + assert l4["measurements"]["momenta"] == [ + [0, 0], [1, 0], [0, 1], + [2, 0], [0, 2], [2, 2], + ] + assert l4["measurements"]["momentum_labels"]["K_points"]["indices"] == [] + assert l4["measurements"]["momentum_labels"]["K_note"] == ( + "K points omitted because L%3!=0" + ) + + l16 = manifest_for(16) + assert len(l16["measurements"]["displacements"]) == 256 + assert l16["measurements"]["momenta"] == [ + [0, 0], [1, 0], [0, 1], + [8, 0], [0, 8], [8, 8], + ] + assert l16["measurements"]["momentum_labels"]["K_points"]["indices"] == [] + + assert "#SBATCH --array=0-31%8" in ( + root / "slurm" / "run_g1_array.sbatch" + ).read_text(encoding="utf-8") + submit = ( + root / "slurm" / "submit_after_live_cluster_check.sh" + ).read_text(encoding="utf-8") + assert submit.count("afterok:") == 6 + assert "sinfo" in submit and "squeue" in submit + + +def test_manifest_tamper_is_detected(tmp_path: Path) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize( + meta_path, root, small_execution() + ) + manifest = root / index["entries"][0]["manifest"] + manifest.write_text( + manifest.read_text(encoding="utf-8") + " ", + encoding="utf-8", + ) + with pytest.raises(protocol.ProtocolError, match="manifest hash"): + protocol.verify_materialization(root) + + +def test_ips_and_rank_split_diagnostics_are_finite() -> None: + constant = [np.ones(32) for _ in range(4)] + result = protocol.multi_chain_diagnostics(constant) + assert result["split_r_hat"] == pytest.approx(1.0) + assert result["bulk_ess"] == pytest.approx(128.0) + assert result["tail_ess"] == pytest.approx(128.0) + assert result["tau_int_by_original_chain"] == pytest.approx( + [0.5] * 4 + ) + + rng = np.random.default_rng(121) + chains = [rng.normal(size=256) for _ in range(4)] + noisy = protocol.multi_chain_diagnostics(chains) + assert math.isfinite(noisy["split_r_hat"]) + assert 0.9 <= noisy["split_r_hat"] <= 1.1 + assert 0 < noisy["bulk_ess"] <= 1024 + assert 0 < noisy["tail_ess"] <= 1024 + + +def fake_result(offset: float) -> dict: + length = 64 + phase = np.linspace(0.0, 4.0 * np.pi, length, endpoint=False) + order = 10.0 + np.sin(phase + offset) + density = 0.5 + 0.01 * np.cos(phase + offset) + number = 4.0 * density + number2 = number * number + 0.25 + energy = -0.2 + 0.01 * np.sin(phase + offset) + traces = { + "order": order.tolist(), + "energy_density": energy.tolist(), + "particle_number": number.tolist(), + "particle_number_squared": number2.tolist(), + "particle_density": density.tolist(), + "particle_density_squared": ( + number2 / 16.0 + ).tolist(), + } + return { + "observables": { + "count": length, + "primary_traces": traces, + "momentum": {}, + }, + "counters": { + "moves": { + "insert": {"attempted": 100, "accepted": 50}, + "delete": {"attempted": 100, "accepted": 50}, + "rotate_left_to_right": { + "attempted": 0, "accepted": 0 + }, + "rotate_right_to_left": { + "attempted": 0, "accepted": 0 + }, + }, + "zero_weight_rejections": 0, + }, + "rebuild_diagnostics": [ + { + "delta_logdet": 1.0e-12, + "relative_T_drift_inf": 1.0e-12, + "relative_Q_drift_inf": 1.0e-12, + "fast_inverse_residual_inf": 1.0e-12, + "rebuilt_inverse_residual_inf": 1.0e-12, + } + ], + } + + +def test_cell_merge_acceptance_rebuild_and_observables() -> None: + thresholds = { + "r_hat_max": 2.0, + "bulk_ess_min": 1, + "tail_ess_min": 1, + "fast_vs_rebuild_relative_error_max": 1.0e-9, + "inverse_residual_max": 1.0e-8, + } + results = [ + fake_result(0.0), + fake_result(0.2), + fake_result(0.4), + fake_result(0.6), + ] + summary = protocol.summarize_cell( + results, beta=1.0, n_sites=4, + thresholds=thresholds, acceptance_range=(0.2, 0.7), + ) + assert summary["acceptance"]["rate"] == pytest.approx(0.5) + assert summary["acceptance"]["pass"] + assert summary["rebuild"]["pass"] + assert summary["positivity"]["pass"] + assert math.isfinite(summary["compressibility"]) + assert summary["pass"] + + +def test_only_outer_all_pass_protocol_writes_complete( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + protocol.materialize(meta_path, root, small_execution()) + + with pytest.raises(protocol.ProtocolError): + protocol.write_protocol_complete(root) + + for gate in ("G0", "G1", "G2", "G3", "G4"): + protocol._gate( + root, gate, + {"status": "PASS", "test_fixture": True}, + ) + complete = protocol.write_protocol_complete(root) + assert complete["status"] == "complete" + assert (root / "COMPLETE").is_file() + with pytest.raises(protocol.ProtocolError, match="overwrite"): + protocol.write_protocol_complete(root) + + monkeypatch.setattr( + protocol, "audit", + lambda root, stage, write_complete=False: { + "status": "INCONCLUSIVE" + }, + ) + assert protocol.main([ + "audit", "--root", str(root), "--stage", "pilot" + ]) == 2 + monkeypatch.setattr( + protocol, "audit", + lambda root, stage, write_complete=False: {"status": "PASS"}, + ) + assert protocol.main([ + "audit", "--root", str(root), "--stage", "g1" + ]) == 0 From f69e4ee846c2b5db4c7a499c0fb4eaf761f14792 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 14:05:04 +0800 Subject: [PATCH 07/13] qmc: harden large-lattice validation and physics audit --- .../finite_density_design_routes.md | 440 +++++++ .../finite_fugacity_obstruction.md | 512 ++++++++ .../Genshin_Impact-121/large_lattice_ctqmc.py | 92 +- .../Genshin_Impact-121/large_lattice_ed.py | 48 + .../large_lattice_kernel_benchmark.py | 668 ++++++++++ .../large_lattice_protocol.py | 962 +++++++++++++-- .../local_vertex_physics.py | 644 ++++++++++ .../local_vertex_physics_frozen.json | 1080 +++++++++++++++++ .../test_large_lattice_ctqmc.py | 92 +- .../test_large_lattice_kernel_benchmark.py | 151 +++ .../test_large_lattice_protocol.py | 643 +++++++++- .../test_local_vertex_physics.py | 36 + 12 files changed, 5225 insertions(+), 143 deletions(-) create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/finite_density_design_routes.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/finite_fugacity_obstruction.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics_frozen.json create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/test_local_vertex_physics.py diff --git a/tracks/qmc/solutions/Genshin_Impact-121/finite_density_design_routes.md b/tracks/qmc/solutions/Genshin_Impact-121/finite_density_design_routes.md new file mode 100644 index 000000000..300c8442b --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/finite_density_design_routes.md @@ -0,0 +1,440 @@ +# Finite-density design routes from the all-fugacity spectral criterion + +Date: 2026-07-30 + +Status: analytic design and obstruction note. No new sign-free class is claimed. +The compact-orthogonal route is exact, but it fails the novelty and finite-density +physics gates. No code, frozen benchmark, protocol, or existing result is changed +by this note. + + +## Executive verdict + +For a real one-particle word T and fugacity z>0, + + p_T(z) = det(I + z T) + +is strictly positive for every z exactly when T has no negative real eigenvalue. +Weak nonnegativity permits negative eigenvalues only when each distinct negative +value has even algebraic multiplicity. + +The strongest exact control in this pass is compact special orthogonality. Local +vertices embed in SO(N), arbitrary overlapping products remain in SO(N), and +p_T(z)>=0 for every z>0. Pairing R with R^(-1)=R^T gives a local Hermitian, +number-conserving, genuinely interacting S3 triangle Hamiltonian on a nonbipartite +lattice. Thus this route meets the algebraic parts of conditions (a)-(d). + +It does not meet the novelty/physics condition (e): + +1. Compact rotations and their inverse-paired fermion vertices are a known + Majorana-reflection/antisymmetric-hopping mechanism. Equation (9) of Wang et al. + (2015) already uses an inverse pair of SO(2) rotations. +2. Positive coefficients make vacuum and full filling minimize every local term. + A uniform chemical potential picks full filling for mu>0 and vacuum for mu<0; + there is no stable intermediate-density ground-state phase. + +There is also a sharp Hermitian-slice obstruction. Three C3 conjugates of any +non-scalar 2-by-2 SPD boost generate a word with two negative real eigenvalues. +This gives an exact, dimension-two no-go for the idea that S3-related local +Hermitian Gaussian factors should be safe at all fugacity. + +The one route left structurally capable of meeting all five targets is a generalized +oscillatory semigroup: common proper cones on every exterior power, not necessarily +coordinate or simplicial. It would force every word to have positive real spectrum +and would make every canonical coefficient positive. No scalable local S3/Hermitian +realization is known, and a representation obstruction rules out an S3-invariant +second-compound cone on the natural three-site representation. This remains a +research direction, not a solution. + +## 1. Exact target + +Let S be the semigroup generated by every resolved Gaussian vertex that occurs with +a nonnegative scalar coefficient. Realness pairs nonreal eigenvalues, so + + det(I+zT) + = product_(lambda real) (1+z lambda) + product_(Im lambda>0) |1+z lambda|^2. (1) + +Therefore: + +- strict positivity for all z>0 is equivalent to no negative real eigenvalue; +- weak nonnegativity is equivalent to even algebraic multiplicity for every + distinct negative real eigenvalue. + +Zero weights are formally sign-free but are undesirable for conditioning. SO(N) +is uniformly weak and is strict unless a word has eigenvalue -1 at z=1. + +The fixed-particle coefficient is + + Z_q(T) = Tr(wedge^q T). + +All-z grand-canonical positivity alone does not imply Z_q(T)>=0. Forcing every +eigenvalue of every word to be positive real would solve both problems. + +## 2. Compact SO(N): exact all-fugacity control + +### 2.1 Determinant theorem + +**Proposition 2.1 (Derived).** If T is in SO(N), then + + det(I+zT) >= 0 for every z>0. (2) + +The spectrum consists of +1, -1, and pairs exp(+/- i theta). Since det T=+1, the +multiplicity n_- of -1 is even. Thus + + det(I+zT) + = (1+z)^(n_+) (1-z)^(n_-) + product_theta (1+2z cos(theta)+z^2) >= 0. (3) + +Equality occurs only at z=1 when -1 is present. If R in SO(k) is embedded as R on +a proper support and identity elsewhere, its global determinant remains +1. +Products on arbitrary overlapping supports remain in SO(N), with no bipartite +condition. + +Generic continuous angles can avoid exact -1 for every finite word outside a +countable exceptional set. This does not give an open, uniformly conditioned strict +class: a dense subgroup can approach -1 arbitrarily closely. The robust theorem is +(2), not a strict lower bound. + +### 2.2 Fock lift and positive expansion + +Let Gamma be number-conserving second quantization: + + Gamma(R_2) Gamma(R_1) = Gamma(R_2 R_1), + Gamma(R)^dagger = Gamma(R^T), + Tr_Fock Gamma(zT) = det(I+zT). (4) + +For local R_a in SO(k_a), define + + M_a = [Gamma(R_a) + Gamma(R_a^(-1))]/2, + + H = sum_a g_a (I-M_a) - mu N, g_a>=0. (5) + +Every M_a is Hermitian and number conserving. In the continuous-time/SSE expansion, +an insertion selects R_a or R_a^(-1), each with coefficient g_a/2. Therefore + + T_C = R_(a_m)^(s_m) ... R_(a_1)^(s_1) in SO(N), + z = exp(beta mu), + w_C = positive_prefactor times det(I+z T_C) >= 0. (6) + +This is an all-orders proof, not a Trotter claim. It survives arbitrary support +overlap, spatial dimension, graph frustration, and expansion depth. + + +### 2.3 Explicit S3 triangle: current-square interaction + +On Delta=(1,2,3), set omega=exp(2 pi i/3) and define + + a_0 = (c_1+c_2+c_3)/sqrt(3), + a_+ = (c_1+omega c_2+omega^2 c_3)/sqrt(3), + a_- = (c_1+omega^2 c_2+omega c_3)/sqrt(3). + +Let q_Delta=n_+-n_- and let R_Delta(theta) fix a_0 while rotating the real +standard plane by theta. Up to orientation, + + Gamma(R_Delta(theta)) = exp(i theta q_Delta). + +Consequently + + M_Delta + = [Gamma(R_Delta(theta))+Gamma(R_Delta(-theta))]/2 + = I - (1-cos theta) q_Delta^2, (7) + +and the local positive term is + + h_Delta = g(1-cos theta) q_Delta^2. (8) + +In the site basis, + + q_Delta = (i/sqrt(3))[ + c_1^dagger c_2 + c_2^dagger c_3 + c_3^dagger c_1 + - c_2^dagger c_1 - c_3^dagger c_2 - c_1^dagger c_3]. (9) + +This is the oriented loop current. Cyclic permutations preserve q and reflections +reverse it, so q^2 is a full S3 scalar. It is genuinely interacting because + + q_Delta^2 = n_+ + n_- - 2 n_+ n_-. (10) + +The four energies on the (+,-) subsystem are proportional to (0,1,1,0), which +cannot be an additive one-body spectrum for nonzero coupling. + +Overlapping terms do not commute. In the one-particle sector q_Delta^2 is + + P_Delta = I_Delta - |u_Delta>=0. (12) + +Local embeddings and positive convex twirls are allowed. Vacuum and the fully +filled Slater determinant are simultaneous ground states of H_0. + +For unitary U, Re U<=I. Every term in (12) is bounded below by -g_a, and both +endpoint states attain this bound term by term: + + Gamma(R_a)|vac> = |vac>, + Gamma(R_a)|full> = det(R_a)|full> = |full>. (13) + +Adding -mu N gives the exact zero-temperature result: + +- mu>0: full filling is the unique global ground state; +- mu<0: vacuum is the unique global ground state; +- mu=0: at least both endpoints remain degenerate ground states. + +Thus arbitrary fugacity is an algorithmic finite-temperature statement, not a +compressible or intermediate-density ground-state phase. At mu=0 a symmetric +thermal ensemble can average to half filling, but this is endpoint coexistence. + +### Local conformal scaling cannot repair the filling + +The global group CSO(N)={rR:r>0,R in SO(N)} also has weak all-z positivity. +A proper-support factor + + G_Delta = (rR)_Delta direct-sum I_(Delta^c) + +obeys + + G_Delta^T G_Delta = r^2 I_Delta direct-sum I_(Delta^c). (14) + +Membership in CSO(N) requires one scalar multiple of I_N, forcing r=1. Equivalently, +the conformal Lie algebra has symmetric part alpha I_N, whereas a local dilation has +alpha P_Delta. A global r is only a fugacity factor; it is not a local +density-stabilizing interaction. + +## 4. Why compact SO is known + +The route has direct QMC prior art. + +- Wang, Liu, Iazzi, Troyer, and Harcos, PRL 115, 250601 (2015), Eq. (9), use the + inverse pair + + exp[+lambda(c_i^dagger c_j-c_j^dagger c_i)] + + exp[-lambda(c_i^dagger c_j-c_j^dagger c_i)], + + whose one-particle factors are SO(2) rotations. The paper explicitly relates the + construction to Majorana QMC. +- For X=alpha I+K with K^T=-K, the Majorana kernel has the reflection-positive form + + [[K, i alpha I],[-i alpha I,K]]. (15) + + Pure SO is its equality boundary alpha=0. A real R acts as two identical R blocks + on the two Majorana components of one complex fermion. +- Equation (8) is a three-site, multi-bond extension of this inverse-rotation + identity. A targeted search did not locate this exact triangle formula, but a + negative search cannot make the underlying mechanism new. + +The determinant in (3) is not generally a literal square. The precise rejection is +"known compact-orthogonal/Majorana-reflection mechanism", not "two identical +complex flavors". It nevertheless fails condition (e). + +Primary anchors: + +- https://doi.org/10.1103/PhysRevLett.115.250601 +- https://arxiv.org/abs/1506.05349 +- https://doi.org/10.1103/PhysRevLett.116.250601 +- https://doi.org/10.1103/PhysRevB.110.075146 + + +## 5. Exact S3-SPD obstruction + +The tempting Hermitian alternative is to make each resolved one-particle factor +symmetric positive definite. One or two SPD factors are safe because AB is similar +to A^(1/2) B A^(1/2). Arbitrary words are not. + +Let C be rotation by 2 pi/3 and define + + H_0 = [[1,0],[0,-1]], + H_j = C^j H_0 C^(-j), j=0,1,2, + S_j(x) = exp(x H_j) = cosh(x) I + sinh(x) H_j. (16) + +The H_j are symmetric traceless involutions forming the C3 orbit in the standard +S3 plane. For i!=j, tr(H_i H_j)=-1, while a product of three H_j has zero trace. +Writing c=cosh x and s=sinh x gives exactly + + det[S_2(x)S_1(x)S_0(x)] = 1, + + tr[S_2(x)S_1(x)S_0(x)] + = 2c^3 - 3cs^2 + = 2c(1-s^2/2). (17) + +At x=arcosh(2), both eigenvalues are -1. For x>arcosh(2), the trace is below -2, +so both eigenvalues are distinct and negative. At x=arcosh(3), + + spectrum[S_2 S_1 S_0] = {-9+4sqrt(5), -9-4sqrt(5)}. (18) + +Both values are negative. + +**Corollary 5.1 (Derived).** For any fixed r>0, + + S_j(r)^m = S_j(mr), + +so the allowed word + + S_2(r)^m S_1(r)^m S_0(r)^m (19) + +fails whenever mr>arcosh(2). Positive scalar multiples and spectator identity +directions do not change this conclusion. The two distinct negative eigenvalues +create a genuinely negative fugacity interval between their roots. + +This is minimal: dimension one is scalar; one SPD factor and a product of two SPD +factors are safe; three factors in dimension two fail. It closes the naive route + + Hermitian Gaussian vertex + S3 orbit + arbitrary expansion depth. + +It does not rule out a Hermitian physical Hamiltonian made from a positive twirl of +individually non-Hermitian vertices. That distinction is essential in the original +polyhedral construction. + +## 6. Other exact routes and their collapse + +### 6.1 Full-word SPD and palindromes + +If every local factor is SPD and every two-letter word AB is also SPD, then AB is +symmetric and AB=BA. Requiring every word to remain SPD therefore forces pairwise +commutativity. + +Grouping vertices into X^dagger X does not help: arbitrary products of three SPD +macrovertices can fail by section 5. Enforcing one global imaginary-time palindrome +is a nonlocal configuration constraint, not the ordinary expansion of a local +equilibrium Hamiltonian. + +### 6.2 Fixed positive flags + +A common upper-triangular semigroup with positive diagonal is strictly safe for all +z. Invariantly, it has a common complete flag with positive one-dimensional quotient +characters. + +If a positive vertex sum used as a Hamiltonian is Hermitian, it preserves that flag. +A Hermitian operator also preserves the orthogonal complements of all flag +subspaces, so all such Hermitian sums are diagonal in the same orthogonal +one-dimensional decomposition. This gives commuting density/classical interactions, +not the requested itinerant two-dimensional model. + +### 6.3 Contraction, Perron, and generic positive factors + +The current polyhedral contraction family controls z=1 and a bounded fugacity +window, not the sign of every subdominant eigenvalue. A proper Perron cone fixes only +the dominant eigenvalue. The D4 Perron-plus-second-compound construction favors one +fermion per decoupled cell, but its scalable proof uses fixed blocks and supplies no +all-z itinerant hopping. + +Products of Metzler exponentials and products of SPD factors have exact all-z +counterexamples; see finite_fugacity_obstruction.md and finite_density_extension.md. +The common lesson is that singular-value bounds and one Perron eigenvalue do not +control the phase of every real subdominant eigenvalue. + + +## 7. Surviving principle: compound Perron cones + +### 7.1 Positive-spectrum theorem + +Let S be a real semigroup with det G>0. Suppose for k=1,...,n-1 there is a +proper cone K_k in wedge^k R^n such that every nonidentity generator obeys + + (wedge^k G)(K_k minus {0}) is contained in int(K_k). (20) + +Then every nonempty word is strongly positive on each compound space. + +**Proposition 7.1 (Derived).** Under (20), every eigenvalue of every nonempty word +is real, positive, simple, and has a distinct modulus. + +Perron-Frobenius on k=1 gives lambda_1>0 and +|lambda_1|>|lambda_2|. On wedge^2 the unique dominant eigenvalue is +lambda_1 lambda_2. If lambda_2 were nonreal, its conjugate would give a second +dominant compound eigenvalue of the same modulus. Thus lambda_2 is real, and +positivity of the compound Perron root makes it positive. Induction gives + + lambda_k = rho_k/rho_(k-1) > 0. (21) + +Consequently + + det(I+zT)>0 for all z>0, + Tr(wedge^q T)>0 for every q. (22) + +This solves grand-canonical and canonical positivity simultaneously. Coordinate +total positivity is one example, but (20) permits noncoordinate, nonsimplicial +cones. The theorem is generalized oscillatory/strict-total-positive mathematics; +novelty would have to be in a local QMC realization. + +### 7.2 S3 representation obstruction + +For the natural three-site representation, + + V = trivial direct-sum standard, + wedge^2 V = sign direct-sum standard. (23) + +The second compound has no trivial S3 subrepresentation. + +**Lemma 7.2 (Derived).** A finite-group representation with no invariant vector +cannot preserve a proper cone setwise. + +Indeed, average an interior cone vector over the group. Convexity keeps the average +in the interior, so it is nonzero and invariant, a contradiction. + +Therefore no S3-invariant proper second-compound cone exists on one natural +three-mode cell. A surviving compound-cone construction must either use a +nonsymmetric certificate preserved by every conjugate, add a rigorously oriented +multicone, enlarge the local representation without becoming a flavor/Kramers +double, or abandon this route. A multicone alone is insufficient: a word that swaps +two components can acquire a negative Perron eigenvalue. + +### 7.3 Lattice scalability + +A local embedded factor has spectator identity directions and is reducible globally. +Strong positivity must be proved on active connected blocks with a direct-sum proof +for untouched components, or replaced by an eventual-positivity theorem that also +handles every partially covered word. Arbitrary SSE words need not cover the +lattice. Long random products are not an all-orders certificate. + +## 8. Decision table + +The target conditions are: (a) one flavor and number conservation; (b) overlapping +local support in a two-dimensional nonbipartite geometry; (c) S3/local Hermitian +physics with positive measure; (d) arbitrary fugacity and meaningful finite density; +(e) no commuting, square, total-positive, O(n,n), Kramers, or Majorana reduction. + +| Route | (a-c) | all-z | finite-density ground phase | novelty gate | +|---|---:|---:|---:|---:| +| Local SO rotations plus inverse pairs | yes | weak yes | no: endpoint jump | fails: known compact/Majorana | +| Generic torsion-free SO generators | yes | pointwise strict possible | no | fails; nonrobust and known | +| Global positive dilation times SO | not local | weak yes | only changes fugacity | fails | +| S3 orbit of Hermitian SPD factors | yes | no | unresolved | exact no-go, section 5 | +| Fixed positive flag | only classical | strict yes | classical | fails: commuting/diagonal | +| Original polyhedral contraction | yes | bounded z only | vacuum at mu=0 | novel only at z=1 | +| D4 Perron-compound cells | no itinerancy | bounded window | one per fixed cell | fixed-cell reduction | +| Nonsimplicial compound cones | open | strict if built | potentially | potentially survives, not built | + +## 9. Completion standard and conclusion + +A real finite-density solution still needs, in one construction: + +1. explicit local resolved vertices and a proof that every word has no negative real + eigenvalue; +2. a positive-measure identity producing a Hermitian local Hamiltonian from exactly + those vertices; +3. overlapping charge motion and a proof for every partially covered lattice word; +4. a stable intermediate-density ground phase, or a compelling finite-temperature + finite-density target; +5. exact exclusion of compact/Majorana, split O(n,n), Kramers, fixed flags, total + positivity/Jordan-Wigner, flavor squares, and fixed-cell encodings. + +The compact SO model is a valuable all-z positive control, and the S3-SPD word is a +minimal exact negative control. Neither is the requested discovery. The best next +mathematical target is a nonsimplicial compound-cone semigroup with a non-Hermitian +resolved S3 orbit whose positive Fock twirl is Hermitian, followed immediately by +local-embedding and stable-density tests. + +The honest current conclusion is: **the arbitrary-fugacity, single-flavor, +nonbipartite, genuinely new finite-density problem remains open.** diff --git a/tracks/qmc/solutions/Genshin_Impact-121/finite_fugacity_obstruction.md b/tracks/qmc/solutions/Genshin_Impact-121/finite_fugacity_obstruction.md new file mode 100644 index 000000000..7137420ef --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/finite_fugacity_obstruction.md @@ -0,0 +1,512 @@ +# Finite-fugacity obstruction for positive and Metzler transfer products + +Date: 2026-07-30 + +Status: analytic obstruction note. Statements marked **[Derived]** are proved +directly below. Decimal values marked **[Numerical]** are evaluations of the +displayed exact formulas, not independent numerical experiments. Statements +marked **[Primary]** are taken from the primary sources listed in section 8. + +## Executive result + +Let `T` be the real one-particle transfer matrix of one auxiliary-field +configuration, and let the fugacity be `z>0`. The grand-canonical fermion factor is + + p_T(z) = det(I + z T). + +The exact all-fugacity criterion is spectral: + + p_T(z)>0 for every z>0 + +if and only if `T` has no negative real eigenvalue. Entrywise positivity, +substochasticity, an ordinary `ℓ∞` contraction, or membership in a product +semigroup of Metzler exponentials does not imply this criterion. + +The sharp hierarchy relevant here is: + +1. a general nonnegative strict-substochastic matrix can fail already in `2×2`; +2. one Metzler exponential has `p_T(z)≥0` for every `z>0`, but can have an + even-multiplicity zero, with a minimal `3×3` example; +3. a product of two Metzler exponentials can have `p_T(z)<0`, again minimally + in `3×3`; +4. one symmetric positive-definite (SPD) matrix, or a product of two SPD + matrices, is safe for every `z>0`; three SPD factors already need not be safe. + +Consequently, an ordinary contraction certificate at `z=1` extends only to the +bounded window + + z ||T||_∞ < 1. + +It does not establish sign-freedom at arbitrary chemical potential. + +## 1. Exact fixed-matrix criterion + +### 1.1 Strict positivity + +**Theorem [Derived].** For a real square matrix `T`, + + det(I+zT)>0 for every z>0 + +if and only if `T` has no negative real eigenvalue. + +To see this, list the eigenvalues with algebraic multiplicity. Realness pairs every +nonreal eigenvalue with its conjugate, and + + det(I+zT) + = ∏_{λ real} (1+zλ) + ∏_{Im λ>0} |1+zλ|². + +Every conjugate-pair factor is strictly positive. A nonnegative real eigenvalue +also gives a positive factor. Conversely, every negative real eigenvalue `λ<0` +creates a positive zero at + + z = -1/λ. + +This argument does not assume diagonalizability. + +### 1.2 Weak nonnegativity + +**Corollary [Derived].** + + det(I+zT)≥0 for every z>0 + +if and only if every distinct negative real eigenvalue of `T` has even algebraic +multiplicity. An odd multiplicity gives a sign-changing positive root; an even +multiplicity gives a touching root. + +Thus an all-`z` nonnegative theorem is weaker than the strict sign-free statement +needed to exclude zero-weight configurations and conditioning singularities. + +## 2. General nonnegative and substochastic matrices + +Consider the exact matrix + + T₂ = (1/4) [[1, 2], + [2, 1]]. + +It is entrywise strictly positive and strict substochastic: + + ||T₂||_∞ = 3/4 < 1. + +Its eigenvalues are `3/4` and `-1/4`, so + + det(I+zT₂) = (1+3z/4)(1-z/4). + +Therefore the determinant vanishes at `z=4` and is negative for `z>4`. + +This is the minimal dimension for a general nonnegative counterexample: a +one-dimensional nonnegative matrix has no negative eigenvalue. + +### What the ordinary norm bound does prove + +**Lemma [Derived].** If + + z ||T||_∞ < 1, + +then `det(I+zT)>0`. + +Indeed, every eigenvalue obeys `|zλ|≤zρ(T)≤z||T||_∞<1`, so `-1` is not an +eigenvalue of `zT`. The determinant is nonzero throughout the connected interval +from `z=0`, where it equals one, and hence remains positive. + +The `2×2` example shows that this window cannot be replaced by all `z>0` using +only entrywise positivity plus strict substochasticity. + +## 3. One Metzler exponential: nonnegative, but not strictly positive + +A real matrix `A` is Metzler when every off-diagonal entry is nonnegative. +Choosing a scalar `α` such that `A+αI≥0` entrywise gives + + e^A = e^(-α) e^(A+αI) ≥ 0 + +entrywise. This is an elementary positivity proof. + +More is true for one real exponential. Culver's real-logarithm theorem says that +each Jordan block associated with a negative real eigenvalue of a real matrix +having a real logarithm must occur an even number of times. Since `e^A` has the +real logarithm `A`, every negative eigenvalue of `e^A` has even algebraic +multiplicity. Hence + + det(I+z e^A) ≥ 0 for every z>0. (3.1) + +This implication is **[Derived]** from Culver's **[Primary]** theorem. It does not +give strict positivity. + +### 3.1 Exact minimal `3×3` zero + +Let + + P = [[0, 1, 0], + [0, 0, 1], + [1, 0, 0]], + + a = 2π/√3, + A = a(P-I), + q = exp(-√3 π). + +The matrix `A` is an irreducible Metzler Markov generator: its row sums vanish. +The eigenvalues of `A` are + + 0, -√3 π + iπ, -√3 π - iπ. + +Therefore **[Derived]** + + E = e^A = ((1+q)/3) J - q I, + +where `J` is the all-ones matrix, and + + spectrum(E) = {1, -q, -q}. + +Because `q<1/2`, all entries of `E` are strictly positive. Its row sums are one, +so `E` is a strictly positive stochastic matrix. Nevertheless, + + det(I+zE) = (1+z)(1-qz)², + +which vanishes at + + z₀ = 1/q = exp(√3 π) + ≈ 230.76458831914576. [Numerical] + +The determinant touches zero and does not become negative, in agreement with +(3.1). + +For any `κ>0`, + + A_κ = A - κI, + e^(A_κ) = e^(-κ) E + +is a strictly positive strict-substochastic Metzler exponential. Its all-fugacity +strictness still fails, now at + + z₀(κ) = exp(κ+√3 π). + +### 3.2 Minimality + +For a real `2×2` Metzler matrix + + A = [[a, b], + [c, d]], b,c≥0, + +the eigenvalue discriminant is + + (a-d)² + 4bc ≥ 0. + +Both eigenvalues of `A` are real, so both eigenvalues of `e^A` are positive. +No negative real eigenvalue, and hence no positive fugacity zero, is possible. +The `3×3` construction above is therefore dimension-minimal within the +single-Metzler-exponential class. + +The displayed example is our exact construction, not an example copied from the +embedding literature. Davies and Chen--Chen in section 8 are primary context for +embeddable Markov matrices and coinciding negative eigenvalues. + +## 4. Two Metzler exponentials: the determinant can be negative + +Retain `E` and `q` from section 3 and define + + D = diag(1/2, 1/2, 1/4) = e^B, + B = diag(-ln 2, -ln 2, -ln 4). + +The matrix `B` is Metzler, while `D` is nonnegative and strict substochastic. +Set + + T = D E. + +Then `T` is entrywise strictly positive, strict substochastic, and a product of +two Metzler exponentials. + +### 4.1 Exact spectrum reduction + +The vector `(1,-1,0)^T` is an eigenvector with + + λ₁ = -q/2. + +The subspace `{(x,x,y)^T}` is invariant. In coordinates `(x,y)`, the restriction +of `T` is + + M = (1/3) [[d(2-q), d(1+q)], + [2e(1+q), e(1-2q)]], + +with `d=1/2` and `e=1/4`. Its trace and determinant are + + τ = 5/12 - q/3, + det M = -deq = -q/8. + +Thus the other two eigenvalues are + + λ_± = (τ ± √(τ²+q/2))/2, + +with `λ_+>0` and `λ_-<0`. Their values are + + q ≈ 0.004333420509983131, [Numerical] + λ₁ ≈ -0.0021667102549915655, [Numerical] + λ_+≈ 0.41652266875418265, [Numerical] + λ_-≈ -0.0013004755908437027. [Numerical] + +The two positive roots of `det(I+zT)` are therefore + + z₁ = -1/λ₁ = 2/q + ≈ 461.5291766382915, [Numerical] + + z₂ = -1/λ_- + ≈ 768.9494574452068. [Numerical] + +Consequently **[Derived]** + + det(I+zT) < 0 for z₁0`. Then `B_ε` is irreducible Metzler with negative +row sums, so `e^(B_ε)` is strictly positive and strict substochastic. At a fixed +`z` strictly inside the negative interval, determinant continuity preserves the +strict negative sign for all sufficiently small `ε`. This last perturbative +upgrade is **[Derived by continuity]**; no numerical `ε` threshold is claimed. + +### 4.3 Minimality + +Every `2×2` nonnegative matrix + + X = [[a,b], + [c,d]] + +has real eigenvalues because its discriminant is `(a-d)²+4bc≥0`. If additionally +`det X>0`, its nonnegative trace forces both eigenvalues to be positive. A product +of real exponentials always has + + det(e^(A_m) ... e^(A_1)) = exp(∑_j tr A_j) > 0. + +Hence a `2×2` product of Metzler exponentials cannot have a negative eigenvalue. +The example above proves that dimension three is minimal. + +## 5. SPD factors: the safe and unsafe boundaries + +Here SPD means real symmetric positive definite. It is a spectral/quadratic-form +property and must not be confused with entrywise nonnegativity. + +### 5.1 One or two SPD factors are safe + +If `T` itself is SPD, all its eigenvalues are positive and the criterion in +section 1 applies. + +If + + T = A B + +with `A` and `B` SPD, then `AB` is similar to the SPD matrix + + A^(1/2) B A^(1/2). + +Thus all eigenvalues of `AB` are positive and + + det(I+zAB)>0 for every z>0. [Derived] + +The same conclusion holds for any mutually commuting family of SPD factors, +because their product is again SPD. + +### 5.2 Three SPD and entrywise-nonnegative factors can already fail + +The following exact construction also closes the narrower +"doubly nonnegative factor" loophole. Define + + A_j = U_j U_j^T + (3/100) I, + +with + + U₁ = [[0,1,1], + [0,0,1], + [5,6,0]], + + U₂ = [[0,2,4], + [6,0,4], + [0,1,2]], + + U₃ = [[5,6,4], + [1,3,1], + [1,5,0]]. + +Every `A_j` is exactly SPD because + + x^T A_j x = ||U_j^T x||² + (3/100)||x||² > 0 + +for `x≠0`. Every entry is also nonnegative. Their product is exactly + + A₁A₂A₃ = 10^(-6) + [[14610959127, 5547109600, 7725525900], + [ 5329719600, 2045197627, 2866091600], + [84887685900, 32038821600, 44467152827]]. + +Direct integer arithmetic gives **[Derived, exact]** + + det(I + 34 A₁A₂A₃) + = -2609548711966855069686607368 / 10^18 + < 0. + +Equivalently, the decimal value is + + -2609548711.966855069686607368. [Numerical display] + +Thus three factors suffice for failure even when every factor is both SPD and +entrywise nonnegative. Since one and two SPD factors are safe, three is the +minimal factor count for this `3×3` phenomenon. Adding an arbitrarily small +positive multiple of `J` to each factor makes every entry strictly positive; +the strict negative determinant persists for sufficiently small perturbations. + +These `A_j` are not claimed to be exponentials of symmetric Metzler generators: +an SPD matrix has a symmetric logarithm, but that logarithm need not be Metzler. +This example therefore belongs to the SPD-factor boundary, not to section 4. + +### 5.3 Arbitrary SPD products are broadly unconstrained + +Ballantine proved **[Primary]** that a real `2×2` matrix of positive determinant +which is not a negative scalar matrix is a product of four real SPD matrices. +For example, + + S = diag(-1,-2) + +has positive determinant and is not scalar, so it admits such a four-SPD +factorization. Yet + + det(I+zS) = (1-z)(1-2z) < 0 + +for + + 1/2 < z < 1. + +Ballantine's theorem supplies existence of the factors; the determinant +calculation is **[Derived]**. This shows that "each local factor is SPD" is not +an all-fugacity certificate once noncommuting products of unrestricted length are +allowed. + +## 6. Consequence for chemical potential + +Assume the standard fugacity convention + + z = exp(β μ), + +where `β>0` is inverse temperature. If the current construction proves a +configuration-wise bound + + ||T_C||_∞ ≤ ρ < 1 + +uniformly over all configurations `C`, then section 2 proves only + + 0 < z < 1/ρ, + +or equivalently + + μ < -(1/β) ln ρ. [Derived] + +At `μ=0`, one has `z=1`, which is inside this window. All negative chemical +potentials are also inside it. Positive chemical potential is covered only up to +the displayed finite threshold. At fixed `μ>0`, `z=exp(βμ)` grows without bound +as `β→∞`, so no `β`-independent positive-density conclusion follows from ordinary +contraction. + +If the code or Hamiltonian uses the opposite convention `z=exp(-βμ)`, the +inequality reverses in the obvious way; the spectral obstruction itself is +unchanged. + +To obtain arbitrary-fugacity sign-freedom, one needs an additional invariant +that excludes negative real spectrum for every ordered word. Examples of genuinely +sufficient structures are: + +- the full word `T_C` is SPD; +- the full word is always a product of exactly two SPD matrices; +- all SPD factors commute; +- a flavor-pairing or antiunitary mechanism makes the fermion factor an absolute + square; +- another theorem directly proves that every word has no negative real eigenvalue. + +Entrywise positivity, substochasticity, a single Metzler-exponential +parameterization, or closure under products of Metzler exponentials is not enough +for strict positivity at every fugacity. + +Canonical fixed-particle-number positivity is a separate question. Positivity of +`det(I+zT)` on `z>0` does not by itself make every coefficient of that polynomial +nonnegative. + +## 7. Boundary table + +| Class | `det(I+zT)>0` for all `z>0`? | Sharp obstruction or safe reason | +|---|---:|---| +| General nonnegative strict-substochastic `T` | No | Exact `2×2` counterexample in section 2 | +| One Metzler exponential `e^A` | Not always strict; always `≥0` | Exact `3×3` even-multiplicity zero | +| Product of two Metzler exponentials | No | Exact minimal `3×3` negative interval | +| `T` itself SPD | Yes | Positive spectrum | +| Product of two SPD matrices | Yes | Similar to an SPD matrix | +| Product of three SPD, entrywise-nonnegative matrices | No | Exact `3×3` construction in section 5.2 | +| Arbitrary SPD product | No | Ballantine factorization plus `diag(-1,-2)` | +| Ordinary `ℓ∞` contraction | Only while `z||T||_∞<1` | Neumann/spectral-radius window | + +## 8. Primary literature anchors + +- W. J. Culver, "On the Existence and Uniqueness of the Real Logarithm of + a Matrix," Proceedings of the American Mathematical Society 17, + 1146-1151 (1966). The real-logarithm criterion used in section 3: + https://doi.org/10.1090/S0002-9939-1966-0202740-6 + +- E. B. Davies, "Embeddable Markov Matrices," Electronic Journal of Probability + 15, 1474-1486 (2010). Primary context for Markov matrices that are one + generator exponential: + https://doi.org/10.1214/EJP.v15-733 + and https://arxiv.org/abs/1001.1693 + +- Y. Chen and J. Chen, "On the Imbedding Problem for Three-State Time + Homogeneous Markov Chains with Coinciding Negative Eigenvalues," Journal of + Theoretical Probability 24, 928-938 (2011). Primary context for the + three-state negative-doublet phenomenon: + https://doi.org/10.1007/s10959-010-0316-5 + and https://arxiv.org/abs/1009.2152 + +- A. Davydov, S. Jafarpour, and F. Bullo, "Non-Euclidean Contraction Theory for + Robust Nonlinear Stability," IEEE Transactions on Automatic Control 67 + (2022). Primary source for the `ℓ₁/ℓ∞` matrix-measure contraction framework; + the finite-fugacity implication in section 2 is derived here: + https://doi.org/10.1109/TAC.2022.3183966 + and https://arxiv.org/abs/2103.12263 + +- C. S. Ballantine, "Products of Positive Definite Matrices. I," Pacific Journal + of Mathematics 23, 427-433 (1967). Primary `2×2` real-SPD factorization + theorem used in section 5.3. The journal archive supplies a publisher PDF; + no DOI is asserted here: + https://msp.org/pjm/1967/23-3/pjm-v23-n3-p02-p.pdf + +- C. S. Ballantine, "Products of Positive Definite Matrices. II," Pacific Journal + of Mathematics 24, 7-17 (1968). Primary continuation and general-dimensional + bounds: + https://msp.org/pjm/1968/24-1/pjm-v24-n1-p02-s.pdf + +- C. S. Ballantine, "Products of Positive Definite Matrices. IV," Linear Algebra + and its Applications 3, 79-114 (1970). Primary later characterization: + https://doi.org/10.1016/0024-3795(70)90030-3 + +- M. Abdelgalil and T. T. Georgiou, "The factorization of matrices into products + of positive definite factors" (2025; revised 2026). Modern primary treatment + of factor count and spectral effects: + https://arxiv.org/abs/2507.12560 + +The `2×2` substochastic matrix, the explicit three-cycle exponential, the +two-exponential product, the exact three-factor doubly-nonnegative SPD example, +and all fugacity-window deductions in this note are our derivations. The cited +papers anchor the invoked general theorems and surrounding mathematical context; +they are not claimed as sources of those exact displayed counterexamples. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py index 4df294941..64705380b 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py @@ -29,7 +29,8 @@ implemented and must not be claimed. """ from __future__ import annotations -import argparse, hashlib, itertools, json, math, os, sys, tempfile, time +import argparse, hashlib, importlib.metadata, itertools, json, math, os +import platform, sys, tempfile, time from collections import deque from dataclasses import dataclass from fractions import Fraction @@ -364,6 +365,53 @@ def atomic_write_json(path:Path,payload:Mapping[str,Any])->None: finally: if os.path.exists(tmp):os.unlink(tmp) +def execution_environment() -> Mapping[str,Any]: + return {"python_executable":str(Path(sys.executable).resolve()), + "python_version":platform.python_version(), + "numpy_version":importlib.metadata.version("numpy"), + "scipy_version":importlib.metadata.version("scipy"), + "slurm":{"job_id":os.environ.get("SLURM_JOB_ID"), + "array_job_id":os.environ.get("SLURM_ARRAY_JOB_ID"), + "array_task_id":os.environ.get("SLURM_ARRAY_TASK_ID"), + "cluster_name":os.environ.get("SLURM_CLUSTER_NAME")}} + +def validate_existing_complete(output: Path, manifest_sha256: str, + expected_steps: int) -> Mapping[str,Any]: + result_path=output/"result.json"; done_path=output/"CHAIN_COMPLETE" + if not result_path.is_file() or not done_path.is_file(): + raise ManifestError("incomplete CHAIN_COMPLETE artifact set") + result=json.loads(result_path.read_text()); done=json.loads(done_path.read_text()) + digest=hashlib.sha256(result_path.read_bytes()).hexdigest() + for payload,label in ((result,"result"),(done,"CHAIN_COMPLETE")): + if payload.get("algorithm_id")!=ALGORITHM_ID: + raise ManifestError(f"{label} algorithm mismatch") + if payload.get("status")!="run_complete_unvalidated": + raise ManifestError(f"{label} status mismatch") + if payload.get("scope")!="single_chain_execution_only": + raise ManifestError(f"{label} scope mismatch") + if payload.get("manifest_sha256")!=manifest_sha256: + raise ManifestError(f"{label} manifest mismatch") + if int(payload.get("completed_steps",-1))!=expected_steps: + raise ManifestError(f"{label} step mismatch") + if done.get("result_json_sha256")!=digest: + raise ManifestError("CHAIN_COMPLETE result hash mismatch") + return result + +def archive_recoverable_failure(failed: Path) -> Path: + payload=json.loads(failed.read_text()) + if payload.get("determinant_failure_kind") in ("zero","negative"): + raise ManifestError("scientific determinant failure is immutable") + raw=failed.read_bytes(); digest=hashlib.sha256(raw).hexdigest() + archive=failed.parent/"failures"/f"FAILED.{digest}.json" + archive.parent.mkdir(parents=True,exist_ok=True) + if archive.exists() and archive.read_bytes()!=raw: + raise ManifestError("failure archive hash collision") + if not archive.exists(): + os.replace(failed,archive) + else: + failed.unlink() + return archive + class CTQMC: """Cyclic-word sampler; resume rebuilds dense factors from the word.""" def __init__(self,geometry:TriangularGeometry,catalog:Sequence[LocalVertex], @@ -547,9 +595,25 @@ def save_checkpoint(self,status:str="running")->None: atomic_write_json(self.output_dir/"checkpoint.json",self.checkpoint_payload(status)) def load_checkpoint(self)->None: data=json.loads((self.output_dir/"checkpoint.json").read_text()) + if data.get("schema_version")!=1 or data.get("status") not in { + "running","run_failed","run_complete_unvalidated"}: + raise ManifestError("checkpoint schema/status mismatch") if data.get("algorithm_id")!=ALGORITHM_ID or data.get("manifest_sha256")!=self.manifest_sha256: raise ManifestError("checkpoint protocol mismatch") - self.completed_steps=int(data["completed_steps"]) + completed=data.get("completed_steps") + if isinstance(completed,bool) or not isinstance(completed,int) or not ( + 0<=completed<=self.steps): + raise ManifestError("checkpoint completed_steps invalid") + accumulator=data.get("accumulator") + expected_count=max(0,completed-self.warmup)//self.measure_every + if not isinstance(accumulator,Mapping) or accumulator.get("count")!=expected_count: + raise ManifestError("checkpoint accumulator count mismatch") + traces=accumulator.get("primary_traces") + if not isinstance(traces,Mapping) or set(traces)!=set(ObservableAccumulator.KEYS) or any( + not isinstance(trace,list) or len(trace)!=expected_count + for trace in traces.values()): + raise ManifestError("checkpoint primary trace length mismatch") + self.completed_steps=completed self.word=deque(Event.from_json(e) for e in data["word"]) self.rng.bit_generator.state=data["rng_state"];self.counters=data["counters"] self.counters.setdefault("determinant_failures",{"zero":0,"negative":0}) @@ -596,6 +660,12 @@ def run(self)->Mapping[str,Any]: "rebuild_diagnostics":self.rebuild_diagnostics, "timing":{"wall_seconds":wall_seconds}, "resource_usage":{"max_rss_kb":max_rss_kb}, + "execution_environment":execution_environment(), + "recovered_failure_archives":[ + {"path":str(path.relative_to(self.output_dir)), + "sha256":hashlib.sha256(path.read_bytes()).hexdigest()} + for path in sorted((self.output_dir/"failures").glob("FAILED.*.json")) + ] if (self.output_dir/"failures").is_dir() else [], "observables":self.accumulator.summary(self.beta,self.geometry.n_sites), "implementation":{"fock_space_constructed":False, "local_storage":"12 local 3x3 B/B_inv templates","state":"dense T,Q,logdet", @@ -645,13 +715,19 @@ def main(argv:Optional[Sequence[str]]=None)->int: chain_complete=args.output/"CHAIN_COMPLETE" failed=args.output/"FAILED" if chain_complete.exists(): - raise ManifestError("CHAIN_COMPLETE exists; completed chain output is immutable") + completed=validate_existing_complete( + args.output,digest,int(manifest["monte_carlo"]["steps"])) + print(json.dumps({"status":completed["status"], + "idempotent_existing_complete":True},allow_nan=False),flush=True) + return 0 + if args.resume and not checkpoint.is_file(): + raise ManifestError("--resume needs checkpoint; active FAILED retained") if failed.exists(): - raise ManifestError("FAILED exists; failed chain output is immutable") - if args.resume: - if not checkpoint.is_file(): - raise ManifestError("--resume needs checkpoint") - elif checkpoint.exists() or result.exists(): + if args.resume: + archive_recoverable_failure(failed) + else: + raise ManifestError("FAILED exists; use --resume for recoverable failures") + if not args.resume and (checkpoint.exists() or result.exists()): raise ManifestError("output exists; use --resume or a new directory") sampler:Optional[CTQMC]=None try: diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py index 3ae3a39a8..11aa45068 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ed.py @@ -69,6 +69,7 @@ class OracleInput: model: Mapping[str, float] momenta: Tuple[Tuple[int, int], ...] hermitian_tolerance: float + displacements: Tuple[Tuple[int, int], ...] = () def _as_mapping(value: Any, name: str) -> Mapping[str, Any]: @@ -160,6 +161,27 @@ def load_runner_input(path: Path) -> OracleInput: momenta.append((kx, ky)) if len(set(momenta)) != len(momenta): raise ctqmc.ManifestError("measurements.momenta contains duplicates") + raw_displacements = measurements.get("displacements", []) + if ( + not isinstance(raw_displacements, Sequence) + or isinstance(raw_displacements, (str, bytes)) + ): + raise ctqmc.ManifestError("measurements.displacements must be a sequence") + displacements = [] + for index, raw in enumerate(raw_displacements): + if ( + not isinstance(raw, Sequence) + or isinstance(raw, (str, bytes)) + or len(raw) != 2 + ): + raise ctqmc.ManifestError( + f"measurements.displacements[{index}] must be [dx,dy]" + ) + dx = _signed_integer(raw[0], f"measurements.displacements[{index}][0]") + dy = _signed_integer(raw[1], f"measurements.displacements[{index}][1]") + displacements.append((dx, dy)) + if len(set(displacements)) != len(displacements): + raise ctqmc.ManifestError("measurements.displacements contains duplicates") ed_config = _as_mapping( manifest.get("exact_diagonalization", {}), @@ -179,6 +201,7 @@ def load_runner_input(path: Path) -> OracleInput: model, tuple(momenta), hermitian_tolerance, + tuple(displacements), ) @@ -453,6 +476,26 @@ def momentum_observables( return result +def real_space_green_observables( + geometry: ctqmc.TriangularGeometry, + green: np.ndarray, + displacements: Sequence[Tuple[int, int]], +) -> Mapping[str, Any]: + result = {} + for dx, dy in displacements: + total = 0.0j + for sx in range(geometry.Lx): + for sy in range(geometry.Ly): + i = sx * geometry.Ly + sy + j = ( + ((sx + dx) % geometry.Lx) * geometry.Ly + + (sy + dy) % geometry.Ly + ) + total += complex(green[i, j]) + result[f"{dx},{dy}"] = _complex_pair(total / geometry.n_sites) + return result + + def run_oracle(manifest_path: Path) -> Mapping[str, Any]: oracle = load_runner_input(manifest_path) layout = build_fock_layout(oracle.geometry.n_sites) @@ -557,6 +600,11 @@ def run_oracle(manifest_path: Path) -> Mapping[str, Any]: density_pair, oracle.momenta, ), + "real_space_green": real_space_green_observables( + oracle.geometry, + green, + oracle.displacements, + ), "momentum_definition": { "one_body": "phase^dagger G phase / N", "density_raw": "phase^dagger phase / N", diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py new file mode 100644 index 000000000..3102974ab --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py @@ -0,0 +1,668 @@ +#!/usr/bin/env python3 +"""Deterministic rank-3 versus full-word rebuild kernel benchmark. + +The default grid is intended for a scheduled benchmark job, not a login node. +Every timed reference operation reconstructs T from the complete word with +structured_product and then calls factor_dense. The fast operation applies the +rank-3 formula to the same state and candidate. Insert and its corresponding +endpoint delete are benchmarked separately. + +BLAS thread variables are forced to one before NumPy or the CTQMC module is +imported. +""" +from __future__ import annotations + +import os + +_BLAS_THREAD_ENV = ( + "OPENBLAS_NUM_THREADS", + "OMP_NUM_THREADS", + "MKL_NUM_THREADS", + "NUMEXPR_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "BLIS_NUM_THREADS", +) +for _name in _BLAS_THREAD_ENV: + os.environ[_name] = "1" + +import argparse +import contextlib +import gc +import hashlib +import io +import json +import math +import platform +import statistics +import subprocess +import sys +import tempfile +import time +from pathlib import Path +from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple + +import numpy as np +import scipy + +import large_lattice_ctqmc as ctqmc + + +ALGORITHM_ID = "rank3-vs-full-word-rebuild-v1" +DEFAULT_SIZES = (4, 8, 12, 16) +DEFAULT_BETA = 4.0 +DEFAULT_SEED = 121_730_001 +DEFAULT_REPEATS = 9 +DEFAULT_WARMUP = 2 +DEFAULT_CONDITION_MAX = 1.0e12 +FROZEN_MODEL = { + "epsilon": 0.01, + "kappa": 0.02, + "s": 0.25, + "g_A": 0.25, + "g_B": 0.25, +} +CORRECTNESS_THRESHOLDS = { + "matrix_relative_inf": 1.0e-9, + "logdet_absolute": 1.0e-9, + "det_ratio_relative": 1.0e-9, +} + + +def sha256_file(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def repository_root() -> Path: + return Path(__file__).resolve().parents[4] + + +def source_commit() -> Optional[str]: + try: + completed = subprocess.run( + ["git", "rev-parse", "HEAD"], + cwd=repository_root(), + check=True, + capture_output=True, + text=True, + timeout=10, + ) + except (OSError, subprocess.SubprocessError): + return None + value = completed.stdout.strip() + return value if len(value) == 40 else None + + +def numpy_configuration() -> str: + stream = io.StringIO() + with contextlib.redirect_stdout(stream): + np.__config__.show() + return stream.getvalue() + + +def optional_threadpool_info() -> Optional[List[Mapping[str, Any]]]: + try: + from threadpoolctl import threadpool_info + except ImportError: + return None + result: List[Mapping[str, Any]] = [] + for item in threadpool_info(): + result.append({ + str(key): value + for key, value in item.items() + if isinstance(value, (str, int, float, bool)) or value is None + }) + return result + + +def finite_or_none(value: float) -> Optional[float]: + value = float(value) + return value if math.isfinite(value) else None + + +def assert_finite_json(value: Any, path: str = "root") -> None: + if isinstance(value, float): + if not math.isfinite(value): + raise ValueError(f"non-finite JSON value at {path}") + elif isinstance(value, Mapping): + for key, child in value.items(): + assert_finite_json(child, f"{path}.{key}") + elif isinstance(value, (list, tuple)): + for index, child in enumerate(value): + assert_finite_json(child, f"{path}[{index}]") + + +def atomic_write_json(path: Path, payload: Mapping[str, Any]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + descriptor, temporary = tempfile.mkstemp( + prefix="." + path.name + ".", suffix=".tmp", dir=path.parent + ) + try: + with os.fdopen(descriptor, "w", encoding="utf-8") as handle: + json.dump( + payload, + handle, + indent=2, + sort_keys=True, + allow_nan=False, + ) + handle.write("\n") + handle.flush() + os.fsync(handle.fileno()) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +def relative_inf_error(actual: np.ndarray, reference: np.ndarray) -> float: + return float( + np.linalg.norm(actual - reference, np.inf) + / max(1.0, np.linalg.norm(reference, np.inf)) + ) + + +def word_digest(word: Sequence[ctqmc.Event]) -> str: + raw = json.dumps( + [event.to_json() for event in word], + separators=(",", ":"), + ).encode("ascii") + return hashlib.sha256(raw).hexdigest() + + +def build_catalog() -> List[ctqmc.LocalVertex]: + return ctqmc.build_vertex_catalog( + FROZEN_MODEL["epsilon"], + FROZEN_MODEL["kappa"], + FROZEN_MODEL["s"], + FROZEN_MODEL["g_A"], + FROZEN_MODEL["g_B"], + ) + + +def sample_event( + rng: np.random.Generator, + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], +) -> ctqmc.Event: + triangle_id = int(rng.integers(geometry.n_triangles)) + vertex_id = int(rng.integers(len(catalog))) + return ctqmc.Event(triangle_id, vertex_id) + + +def dense_word_factors( + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], + word: Sequence[ctqmc.Event], +) -> ctqmc.DenseFactors: + product = ctqmc.structured_product( + geometry.n_sites, + geometry.triangles, + catalog, + word, + ) + return ctqmc.factor_dense(product) + + +def timed_call(function: Any) -> Tuple[Any, int]: + started = time.perf_counter_ns() + result = function() + elapsed = time.perf_counter_ns() - started + return result, int(elapsed) + + +def fast_left_update( + factors: ctqmc.DenseFactors, + geometry: ctqmc.TriangularGeometry, + catalog: Sequence[ctqmc.LocalVertex], + event: ctqmc.Event, + block: np.ndarray, + fallback_word: Sequence[ctqmc.Event], + condition_max: float, +) -> Tuple[ctqmc.DenseFactors, float, Mapping[str, Any]]: + triangle = geometry.triangles[event.triangle_id] + proposal = ctqmc.low_rank_left_proposal( + factors, + triangle.sites, + block, + condition_max=condition_max, + ) + metadata: Dict[str, Any] = { + "fallback": False, + "proposal_condition": finite_or_none(proposal.condition), + "local_solve_residual_inf": + finite_or_none(proposal.local_solve_residual_inf), + } + if proposal.needs_rebuild: + rebuilt = dense_word_factors(geometry, catalog, fallback_word) + metadata["fallback"] = True + return rebuilt, float(rebuilt.logdet - factors.logdet), metadata + if proposal.zero_weight: + raise ctqmc.NumericalStabilityError( + "strict-support benchmark encountered zero weight" + ) + updated = ctqmc.apply_low_rank_proposal(factors, proposal) + return updated, float(proposal.log_det_ratio), metadata + + +def update_error( + fast: ctqmc.DenseFactors, + dense: ctqmc.DenseFactors, + fast_log_ratio: float, + dense_log_ratio: float, +) -> Mapping[str, float]: + return { + "T_relative_inf": relative_inf_error(fast.T, dense.T), + "Q_relative_inf": relative_inf_error(fast.Q, dense.Q), + "logdet_absolute": abs(float(fast.logdet - dense.logdet)), + "log_ratio_absolute": abs(float(fast_log_ratio - dense_log_ratio)), + "det_ratio_relative": abs( + math.expm1(float(fast_log_ratio - dense_log_ratio)) + ), + } + + +def max_error(samples: Sequence[Mapping[str, float]]) -> Mapping[str, float]: + names = ( + "T_relative_inf", + "Q_relative_inf", + "logdet_absolute", + "log_ratio_absolute", + "det_ratio_relative", + ) + return { + name: max(float(sample[name]) for sample in samples) + for name in names + } + + +def correctness_pass( + insert_error: Mapping[str, float], + delete_error: Mapping[str, float], +) -> bool: + for error in (insert_error, delete_error): + if error["T_relative_inf"] > CORRECTNESS_THRESHOLDS["matrix_relative_inf"]: + return False + if error["Q_relative_inf"] > CORRECTNESS_THRESHOLDS["matrix_relative_inf"]: + return False + if error["logdet_absolute"] > CORRECTNESS_THRESHOLDS["logdet_absolute"]: + return False + if error["log_ratio_absolute"] > CORRECTNESS_THRESHOLDS["logdet_absolute"]: + return False + if error["det_ratio_relative"] > CORRECTNESS_THRESHOLDS["det_ratio_relative"]: + return False + return True + + +def latency_summary(samples_ns: Sequence[int]) -> Mapping[str, Any]: + values = [int(value) for value in samples_ns] + return { + "median_ns": float(statistics.median(values)), + "minimum_ns": min(values), + "maximum_ns": max(values), + "samples_ns": values, + } + + +def benchmark_size( + L: int, + beta: float, + seed: int, + repeats: int, + warmup: int, + condition_max: float = DEFAULT_CONDITION_MAX, +) -> Mapping[str, Any]: + if L < 2: + raise ValueError("L must be at least 2") + if beta <= 0.0: + raise ValueError("beta must be positive") + if repeats < 1 or warmup < 0: + raise ValueError("repeats must be positive and warmup nonnegative") + geometry = ctqmc.build_triangular_geometry(L, L) + catalog = build_catalog() + order = int(math.ceil(beta * geometry.n_sites)) + local_seed = int(seed + 1_000_003 * L) + rng = np.random.Generator(np.random.PCG64DXSM(local_seed)) + base_word = tuple( + sample_event(rng, geometry, catalog) for _ in range(order) + ) + candidates = tuple( + sample_event(rng, geometry, catalog) + for _ in range(warmup + repeats) + ) + base_factors = dense_word_factors(geometry, catalog, base_word) + + fast_insert_ns: List[int] = [] + dense_insert_ns: List[int] = [] + fast_delete_ns: List[int] = [] + dense_delete_ns: List[int] = [] + insert_errors: List[Mapping[str, float]] = [] + delete_errors: List[Mapping[str, float]] = [] + fallback_counts = {"insert": 0, "delete": 0} + finite_conditions: List[float] = [] + finite_local_residuals: List[float] = [] + nonfinite_condition_count = 0 + nonfinite_local_residual_count = 0 + + def one_iteration( + candidate: ctqmc.Event, + timed: bool, + reverse_order: bool, + ) -> None: + nonlocal nonfinite_condition_count, nonfinite_local_residual_count + vertex = catalog[candidate.vertex_id] + inserted_word = base_word + (candidate,) + + def fast_insert_call() -> Tuple[ctqmc.DenseFactors, float, Mapping[str, Any]]: + return fast_left_update( + base_factors, + geometry, + catalog, + candidate, + vertex.block, + inserted_word, + condition_max, + ) + + def dense_insert_call() -> ctqmc.DenseFactors: + return dense_word_factors(geometry, catalog, inserted_word) + + if reverse_order: + dense_insert, dense_i_ns = timed_call(dense_insert_call) + fast_insert, fast_i_ns = timed_call(fast_insert_call) + else: + fast_insert, fast_i_ns = timed_call(fast_insert_call) + dense_insert, dense_i_ns = timed_call(dense_insert_call) + fast_insert_factors, fast_insert_ratio, insert_metadata = fast_insert + dense_insert_ratio = float(dense_insert.logdet - base_factors.logdet) + + def fast_delete_call() -> Tuple[ctqmc.DenseFactors, float, Mapping[str, Any]]: + return fast_left_update( + fast_insert_factors, + geometry, + catalog, + candidate, + vertex.block_inv, + base_word, + condition_max, + ) + + def dense_delete_call() -> ctqmc.DenseFactors: + return dense_word_factors(geometry, catalog, base_word) + + if reverse_order: + fast_delete, fast_d_ns = timed_call(fast_delete_call) + dense_delete, dense_d_ns = timed_call(dense_delete_call) + else: + dense_delete, dense_d_ns = timed_call(dense_delete_call) + fast_delete, fast_d_ns = timed_call(fast_delete_call) + fast_delete_factors, fast_delete_ratio, delete_metadata = fast_delete + dense_delete_ratio = float( + dense_delete.logdet - dense_insert.logdet + ) + + if not timed: + return + fast_insert_ns.append(fast_i_ns) + dense_insert_ns.append(dense_i_ns) + fast_delete_ns.append(fast_d_ns) + dense_delete_ns.append(dense_d_ns) + insert_errors.append(update_error( + fast_insert_factors, + dense_insert, + fast_insert_ratio, + dense_insert_ratio, + )) + delete_errors.append(update_error( + fast_delete_factors, + dense_delete, + fast_delete_ratio, + dense_delete_ratio, + )) + for move, metadata in ( + ("insert", insert_metadata), + ("delete", delete_metadata), + ): + fallback_counts[move] += int(bool(metadata["fallback"])) + condition = metadata["proposal_condition"] + residual = metadata["local_solve_residual_inf"] + if condition is None: + nonfinite_condition_count += 1 + else: + finite_conditions.append(float(condition)) + if residual is None: + nonfinite_local_residual_count += 1 + else: + finite_local_residuals.append(float(residual)) + + gc_was_enabled = gc.isenabled() + gc.disable() + try: + for index, candidate in enumerate(candidates[:warmup]): + one_iteration(candidate, timed=False, reverse_order=bool(index % 2)) + for index, candidate in enumerate(candidates[warmup:]): + one_iteration(candidate, timed=True, reverse_order=bool(index % 2)) + finally: + if gc_was_enabled: + gc.enable() + + insert_fast = latency_summary(fast_insert_ns) + insert_dense = latency_summary(dense_insert_ns) + delete_fast = latency_summary(fast_delete_ns) + delete_dense = latency_summary(dense_delete_ns) + insert_max_error = max_error(insert_errors) + delete_max_error = max_error(delete_errors) + passed = correctness_pass(insert_max_error, delete_max_error) + return { + "L": L, + "N": geometry.n_sites, + "beta": beta, + "target_order_rule": "ceil(beta*N)", + "order": order, + "seed": local_seed, + "word_sha256": word_digest(base_word), + "candidate_sha256": word_digest(candidates), + "repeats": repeats, + "warmup": warmup, + "latency": { + "insert": { + "rank3": insert_fast, + "full_word_rebuild": insert_dense, + "speedup_dense_over_rank3": + insert_dense["median_ns"] / insert_fast["median_ns"], + }, + "delete": { + "rank3": delete_fast, + "full_word_rebuild": delete_dense, + "speedup_dense_over_rank3": + delete_dense["median_ns"] / delete_fast["median_ns"], + }, + }, + "correctness": { + "pass": passed, + "thresholds": dict(CORRECTNESS_THRESHOLDS), + "insert_max_error": insert_max_error, + "delete_max_error": delete_max_error, + }, + "fallback_count": fallback_counts, + "proposal_diagnostics": { + "maximum_finite_condition": + max(finite_conditions) if finite_conditions else None, + "maximum_finite_local_solve_residual_inf": + max(finite_local_residuals) + if finite_local_residuals else None, + "nonfinite_condition_count": nonfinite_condition_count, + "nonfinite_local_solve_residual_count": + nonfinite_local_residual_count, + }, + } + + +def run_benchmark( + sizes: Sequence[int] = DEFAULT_SIZES, + beta: float = DEFAULT_BETA, + seed: int = DEFAULT_SEED, + repeats: int = DEFAULT_REPEATS, + warmup: int = DEFAULT_WARMUP, + condition_max: float = DEFAULT_CONDITION_MAX, +) -> Mapping[str, Any]: + normalized_sizes = tuple(int(size) for size in sizes) + if not normalized_sizes: + raise ValueError("at least one size is required") + script_path = Path(__file__).resolve() + ctqmc_path = Path(ctqmc.__file__).resolve() + cases = [ + benchmark_size( + L, + beta, + seed, + repeats, + warmup, + condition_max, + ) + for L in normalized_sizes + ] + commit = source_commit() + report: Dict[str, Any] = { + "schema_version": 1, + "algorithm_id": ALGORITHM_ID, + "status": "benchmark_complete_unvalidated", + "claim_boundary": + "Kernel correctness and timing ingredients only; no publication or " + "end-to-end Monte Carlo claim.", + "parameters": { + "sizes": list(normalized_sizes), + "beta": beta, + "order_rule": "ceil(beta*N)", + "seed": seed, + "repeats": repeats, + "warmup": warmup, + "woodbury_condition_max": condition_max, + "model": dict(FROZEN_MODEL), + }, + "timing_protocol": { + "clock": "time.perf_counter_ns", + "paired_same_word_and_candidate": True, + "alternating_method_order": True, + "garbage_collector_disabled_during_timing": True, + "full_reference_definition": + "structured_product(complete word) followed by factor_dense", + "rank3_definition": + "low_rank_left_proposal followed by apply_low_rank_proposal", + }, + "single_thread_blas": { + "set_before_numpy_import": True, + "environment": { + name: os.environ.get(name) for name in _BLAS_THREAD_ENV + }, + "threadpool_info": optional_threadpool_info(), + }, + "environment": { + "python": sys.version, + "python_executable": sys.executable, + "platform": platform.platform(), + "machine": platform.machine(), + "processor": platform.processor(), + "hostname": platform.node(), + "cpu_count": os.cpu_count(), + "numpy_version": np.__version__, + "scipy_version": scipy.__version__, + "numpy_configuration": numpy_configuration(), + "perf_counter_resolution_seconds": + time.get_clock_info("perf_counter").resolution, + }, + "provenance": { + "source_commit": commit, + "source_commit_role": + "repository base commit; benchmark files may be uncommitted", + "benchmark_source": str( + script_path.relative_to(repository_root()) + ), + "benchmark_source_sha256": sha256_file(script_path), + "ctqmc_source": str( + ctqmc_path.relative_to(repository_root()) + ), + "ctqmc_source_sha256": sha256_file(ctqmc_path), + }, + "cases": cases, + "overall_correctness_pass": all( + bool(case["correctness"]["pass"]) for case in cases + ), + "total_fallback_count": { + "insert": sum( + int(case["fallback_count"]["insert"]) for case in cases + ), + "delete": sum( + int(case["fallback_count"]["delete"]) for case in cases + ), + }, + "machine_auditable_pass_ingredients": { + "correctness_thresholds": dict(CORRECTNESS_THRESHOLDS), + "per_case_correctness_boolean": True, + "raw_latency_samples_recorded": True, + "fallback_counts_recorded": True, + "source_and_environment_hashes_recorded": True, + "speedup_is_reported_not_claimed": True, + }, + } + assert_finite_json(report) + return report + + +def parse_sizes(value: str) -> Tuple[int, ...]: + try: + result = tuple(int(item.strip()) for item in value.split(",")) + except ValueError as exc: + raise argparse.ArgumentTypeError("sizes must be comma-separated integers") from exc + if not result or min(result) < 2: + raise argparse.ArgumentTypeError("all sizes must be at least 2") + return result + + +def main(argv: Optional[Sequence[str]] = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "--sizes", + type=parse_sizes, + default=DEFAULT_SIZES, + help="comma-separated L values; default 4,8,12,16", + ) + parser.add_argument("--beta", type=float, default=DEFAULT_BETA) + parser.add_argument("--seed", type=int, default=DEFAULT_SEED) + parser.add_argument("--repeats", type=int, default=DEFAULT_REPEATS) + parser.add_argument("--warmup", type=int, default=DEFAULT_WARMUP) + parser.add_argument( + "--condition-max", + type=float, + default=DEFAULT_CONDITION_MAX, + ) + parser.add_argument("--output", type=Path) + parser.add_argument("--compact", action="store_true") + args = parser.parse_args(argv) + report = run_benchmark( + sizes=args.sizes, + beta=args.beta, + seed=args.seed, + repeats=args.repeats, + warmup=args.warmup, + condition_max=args.condition_max, + ) + if args.output is not None: + atomic_write_json(args.output, report) + print(json.dumps({ + "status": report["status"], + "overall_correctness_pass": + report["overall_correctness_pass"], + "output": str(args.output), + }, allow_nan=False)) + else: + print(json.dumps( + report, + indent=None if args.compact else 2, + sort_keys=True, + allow_nan=False, + )) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py index 7b659c2b1..abddf3892 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py @@ -1,24 +1,41 @@ #!/usr/bin/env python3 """Hash-bound outer protocol for the confirmed issue-121 lattice benchmark. -Chain-local COMPLETE files only prove a runner exited normally. Only this outer +Chain-local CHAIN_COMPLETE files only prove a runner exited normally. Only this outer protocol writes the materialized root COMPLETE, after G0--G4 all have PASS records. JSON is canonical and forbids NaN/Infinity. """ from __future__ import annotations import argparse import hashlib +import importlib.metadata import json import math import os +import platform +import shlex import statistics +import subprocess +import sys import tempfile +from fractions import Fraction from pathlib import Path from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple import numpy as np PROTOCOL_ID = "issue121-triangular-large-lattice-v1" +CORE_ALGORITHM_ID = "triangular-ab-ctqmc-direct-lu-v1" +ED_ALGORITHM_ID = "triangular-ab-full-fock-ed-oracle-v1" +BENCHMARK_ALGORITHM_ID = "rank3-vs-full-word-rebuild-v1" SOLUTION_DIR = Path(__file__).resolve().parent +SOURCE_FILES = ( + "large_lattice_protocol.py", "large_lattice_ctqmc.py", + "large_lattice_ed.py", "local_vertex_physics.py", + "local_vertex_physics_frozen.json", "test_large_lattice_protocol.py", + "test_large_lattice_ctqmc.py", "test_local_vertex_physics.py", + "large_lattice_kernel_benchmark.py", + "test_large_lattice_kernel_benchmark.py", +) SIZES = ((4,16),(6,36),(8,64),(12,144),(16,256)) BETAS = (0.5,1.0,2.0,4.0) BETA_EXACT = ("1/2","1","2","4") @@ -102,7 +119,7 @@ def write_json(path: Path, value: Mapping[str,Any], exclusive: bool=False) -> No def _float_eq(actual: Any, expected: float, name: str) -> None: _need(not isinstance(actual,bool),f"{name} must be numeric") try: - value=float(actual) + value=float(Fraction(actual)) if isinstance(actual,str) else float(actual) except (TypeError,ValueError) as exc: raise ProtocolError(f"{name} must be numeric") from exc _need(math.isfinite(value) and value==expected,f"{name} drift") @@ -270,13 +287,9 @@ def runner_manifest(meta_hash: str, stage: str, L: int, beta_index: int, "exact_diagonalization":{"hermitian_tolerance":1e-10}} def _task_table(path: Path, entries: Sequence[Mapping[str,Any]]) -> None: - lines=["task_id\tstage\tcell_id\tchain_id\tmanifest\toutput"] - for i,x in enumerate(entries): - lines.append("\t".join(map(str,(i,x["stage"],x["cell_id"],x["chain_id"], - x["manifest"],x["output"])))) - write_bytes(path,("\n".join(lines)+"\n").encode()) + write_bytes(path,_task_table_bytes(entries)) -def _array_script(table: str, count: int) -> str: +def _array_script(table: str, count: int, python_bin: str) -> str: return f"""#!/bin/bash #SBATCH --job-name=i121-{table.replace("_tasks.tsv","")} #SBATCH --array=0-{count-1}%8 @@ -285,18 +298,26 @@ def _array_script(table: str, count: int) -> str: #SBATCH --time=04:00:00 set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd -P) -SOLUTION_DIR=${{SOLUTION_DIR:-{SOLUTION_DIR}}} -PYTHON_BIN=${{PYTHON_BIN:-python3}} +SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} +PYTHON_BIN={shlex.quote(python_bin)} +preflight=$("$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT") line=$(sed -n "$((SLURM_ARRAY_TASK_ID+2))p" "$ROOT/{table}") IFS=$'\\t' read -r task stage cell chain manifest_rel output_rel <<< "$line" output="$ROOT/$output_rel"; mkdir -p "$output" -/usr/bin/time -f 'elapsed_seconds\\t%e\\nmax_rss_kb\\t%M' -o "$output/resource.tsv" \\ +printf '%s\\n' "$preflight" >"$output/preflight.log" +resume=() +if [[ -f "$output/CHAIN_COMPLETE" ]]; then + "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_ctqmc.py" \\ + --manifest "$ROOT/$manifest_rel" --output "$output" + exit 0 +fi +if [[ -f "$output/checkpoint.json" ]]; then resume=(--resume); fi +/usr/bin/time -a -f 'elapsed_seconds\\t%e\\nmax_rss_kb\\t%M' -o "$output/resource.tsv" \\ "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_ctqmc.py" \\ - --manifest "$ROOT/$manifest_rel" --output "$output" \\ - >"$output/runner.stdout" 2>"$output/runner.stderr" + --manifest "$ROOT/$manifest_rel" --output "$output" "${{resume[@]}}" \\ + >>"$output/runner.stdout" 2>>"$output/runner.stderr" """.replace("$","$") - -def _audit_script(stage: str) -> str: +def _audit_script(stage: str, python_bin: str) -> str: ed="" if stage=="g1": ed="""while IFS=$'\\t' read -r cell manifest_rel exact_rel; do @@ -305,7 +326,7 @@ def _audit_script(stage: str) -> str: [[ -f "$exact" ]] || "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_ed.py" --manifest "$ROOT/$manifest_rel" --output "$exact" done < "$ROOT/ed_tasks.tsv" """.replace("$","$") - flag=" --write-complete" if stage=="full" else "" + flag=" --write-complete" if stage=="provenance" else "" return f"""#!/bin/bash #SBATCH --job-name=i121-audit-{stage} #SBATCH --cpus-per-task=1 @@ -313,8 +334,10 @@ def _audit_script(stage: str) -> str: #SBATCH --time=04:00:00 set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd -P) -SOLUTION_DIR=${{SOLUTION_DIR:-{SOLUTION_DIR}}} -PYTHON_BIN=${{PYTHON_BIN:-python3}} +SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} +PYTHON_BIN={shlex.quote(python_bin)} +preflight=$("$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT") +printf '%s\n' "$preflight" {ed}"$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" audit --root "$ROOT" --stage {stage}{flag} """.replace("$","$") @@ -327,22 +350,87 @@ def _submit_script() -> str: g1=$(sbatch --parsable --dependency=afterok:$g0 "$H/run_g1_array.sbatch") a1=$(sbatch --parsable --dependency=afterok:$g1 "$H/audit_g1.sbatch") p=$(sbatch --parsable --dependency=afterok:$a1 "$H/run_pilot_array.sbatch") -ap=$(sbatch --parsable --dependency=afterok:$p "$H/audit_pilot.sbatch") +kb=$(sbatch --parsable --dependency=afterok:$a1 "$H/run_kernel_benchmark.sbatch") +ap=$(sbatch --parsable --dependency=afterok:$p:$kb "$H/audit_pilot.sbatch") f=$(sbatch --parsable --dependency=afterok:$ap "$H/run_full_array.sbatch") -af=$(sbatch --parsable --dependency=afterok:$f "$H/audit_full.sbatch") -printf 'G0=%s G1=%s G1audit=%s pilot=%s pilotaudit=%s full=%s final=%s\\n' "$g0" "$g1" "$a1" "$p" "$ap" "$f" "$af" +a3=$(sbatch --parsable --dependency=afterok:$f "$H/audit_full.sbatch") +a4=$(sbatch --parsable --dependency=afterok:$a3 "$H/audit_g4.sbatch") +printf 'G0=%s G1=%s G1audit=%s pilot=%s kernel=%s pilotaudit=%s full=%s G3=%s G4=%s\\n' "$g0" "$g1" "$a1" "$p" "$kb" "$ap" "$f" "$a3" "$a4" """.replace("$","$") +def kernel_benchmark_manifest(sources: Mapping[str,Any]) -> Mapping[str,Any]: + return {"schema_version":1,"algorithm_id":BENCHMARK_ALGORITHM_ID, + "parameters":{"sizes":[4,8,12,16],"beta":4.0, + "order_rule":"ceil(beta*N)","seed":121730001,"repeats":9,"warmup":2, + "woodbury_condition_max":1.0e12, + "model":{"epsilon":0.01,"kappa":0.02,"s":0.25, + "g_A":0.25,"g_B":0.25}}, + "source_snapshot":sources, + "output":"benchmark/kernel_benchmark.json", + "resource_output":"benchmark/resource.tsv", + "stdout":"benchmark/runner.stdout","stderr":"benchmark/runner.stderr"} + +def _benchmark_script(python_bin: str) -> str: + return f"""#!/bin/bash +#SBATCH --job-name=i121-kernel +#SBATCH --cpus-per-task=1 +#SBATCH --mem=8G +#SBATCH --time=04:00:00 +set -euo pipefail +ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} +PYTHON_BIN={shlex.quote(python_bin)} +preflight=$("$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT") +mkdir -p "$ROOT/benchmark" +printf '%s\\n' "$preflight" >"$ROOT/benchmark/preflight.log" +if [[ -f "$ROOT/benchmark/kernel_benchmark.json" ]]; then exit 0; fi +/usr/bin/time -a -f 'elapsed_seconds\\t%e\\nmax_rss_kb\\t%M' \\ + -o "$ROOT/benchmark/resource.tsv" \\ + "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_kernel_benchmark.py" \\ + --sizes 4,8,12,16 --beta 4 --seed 121730001 --repeats 9 --warmup 2 \\ + --condition-max 1e12 --output "$ROOT/benchmark/kernel_benchmark.json" \\ + >>"$ROOT/benchmark/runner.stdout" 2>>"$ROOT/benchmark/runner.stderr" +""".replace("$","$") + +def _generated_scripts(python_bin: str) -> Mapping[str,str]: + return {"run_g1_array.sbatch":_array_script("g1_tasks.tsv",32,python_bin), + "run_pilot_array.sbatch":_array_script("pilot_tasks.tsv",12,python_bin), + "run_full_array.sbatch":_array_script("full_tasks.tsv",68,python_bin), + "audit_g1.sbatch":_audit_script("g1",python_bin), + "audit_pilot.sbatch":_audit_script("pilot",python_bin), + "audit_full.sbatch":_audit_script("full",python_bin), + "audit_g4.sbatch":_audit_script("provenance",python_bin), + "run_kernel_benchmark.sbatch":_benchmark_script(python_bin), + "submit_after_live_cluster_check.sh":_submit_script(), + "run_g0.sbatch":f"""#!/bin/bash +#SBATCH --job-name=i121-g0 +#SBATCH --cpus-per-task=1 +#SBATCH --mem=4G +#SBATCH --time=00:30:00 +set -euo pipefail +ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} +PYTHON_BIN={shlex.quote(python_bin)} +"$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT" +"$PYTHON_BIN" -m pytest -q "$SOLUTION_DIR/test_large_lattice_protocol.py" "$SOLUTION_DIR/test_large_lattice_ctqmc.py" "$SOLUTION_DIR/test_local_vertex_physics.py" "$SOLUTION_DIR/test_large_lattice_kernel_benchmark.py" -m 'not slow' +"$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" record-g0 --root "$ROOT" --tests-exit-code 0 +""".replace("$","$")} + def materialize(meta_path: Path, root: Path, execution: Optional[Mapping[str,Any]]=None) -> Mapping[str,Any]: meta=load_json(meta_path); validate_meta(meta) selected=json.loads(json.dumps(execution or DEFAULT_EXECUTION)) validate_execution(selected) + environment=environment_snapshot(); sources=source_snapshot() + python_bin=environment["python_executable"] root=Path(root) _need(not root.exists() or not any(root.iterdir()),"output must be empty") root.mkdir(parents=True,exist_ok=True) meta_raw=canonical_bytes(meta); meta_hash=sha_bytes(meta_raw) write_bytes(root/"confirmed_meta_manifest.json",meta_raw,True) + benchmark_manifest=kernel_benchmark_manifest(sources) + benchmark_raw=canonical_bytes(benchmark_manifest) + write_bytes(root/"kernel_benchmark_manifest.json",benchmark_raw,True) entries=[] for stage,sizes in (("g1",(2,3)),("production",tuple(x[0] for x in SIZES))): for L in sizes: @@ -362,49 +450,48 @@ def materialize(meta_path: Path, root: Path, "pilot":stage=="production" and (L,bi) in PILOT}) g1=[x for x in entries if x["stage"]=="g1"] prod=[x for x in entries if x["stage"]=="production"] - pilot=[x for x in prod if x["pilot"]]; remaining=[x for x in prod if not x["pilot"]] + pilot=[x for x in prod if x["pilot"]] + remaining=[x for x in prod if not x["pilot"]] _need(tuple(map(len,(g1,prod,pilot,remaining)))==(32,80,12,68), "task cardinality") - _task_table(root/"g1_tasks.tsv",g1); _task_table(root/"pilot_tasks.tsv",pilot) + _task_table(root/"g1_tasks.tsv",g1) + _task_table(root/"pilot_tasks.tsv",pilot) _task_table(root/"full_tasks.tsv",remaining) ed=["cell_id\tmanifest\texact_output"] for x in g1: if x["chain_id"]==0: ed.append(f'{x["cell_id"]}\t{x["manifest"]}\texact/g1/{x["cell_id"]}.json') write_bytes(root/"ed_tasks.tsv",("\n".join(ed)+"\n").encode()) + scripts=_generated_scripts(python_bin) + for name,text in scripts.items(): + write_bytes(root/"slurm"/name,text.encode(),True) + os.chmod(root/"slurm"/name,0o755) + artifact_paths=("g1_tasks.tsv","pilot_tasks.tsv","full_tasks.tsv","ed_tasks.tsv", + "kernel_benchmark_manifest.json", + *(f"slurm/{name}" for name in scripts)) + artifact_hashes={name:sha_file(root/name) for name in artifact_paths} index={"schema_version":1,"protocol_id":PROTOCOL_ID, "status":"materialized_not_run","meta_manifest_sha256":meta_hash, - "execution":selected,"diagnostic_method":DIAGNOSTIC_METHOD, + "execution":selected,"environment":environment,"source_snapshot":sources, + "kernel_benchmark":{"manifest":"kernel_benchmark_manifest.json", + "manifest_sha256":sha_bytes(benchmark_raw), + "output":benchmark_manifest["output"], + "resource_output":benchmark_manifest["resource_output"], + "stdout":benchmark_manifest["stdout"], + "stderr":benchmark_manifest["stderr"]}, + "generated_artifact_sha256":artifact_hashes, + "diagnostic_method":DIAGNOSTIC_METHOD, "counts":{"g1_chains":32,"production_chains":80, "pilot_chains":12,"full_remaining_chains":68}, "entries":entries, - "claim_boundary":"materialization is not compute evidence; no root COMPLETE"} + "claim_boundary":("materialization is not compute evidence; no root COMPLETE; " + "integrity is tamper-evident accidental-drift detection, not " + "cryptographic authentication; trust root is the git commit plus " + "externally recorded result hashes")} raw=canonical_bytes(index); write_bytes(root/"index.json",raw,True) write_bytes(root/"index.sha256",(sha_bytes(raw)+" index.json\n").encode(),True) - scripts={"run_g1_array.sbatch":_array_script("g1_tasks.tsv",32), - "run_pilot_array.sbatch":_array_script("pilot_tasks.tsv",12), - "run_full_array.sbatch":_array_script("full_tasks.tsv",68), - "audit_g1.sbatch":_audit_script("g1"), - "audit_pilot.sbatch":_audit_script("pilot"), - "audit_full.sbatch":_audit_script("full"), - "submit_after_live_cluster_check.sh":_submit_script(), - "run_g0.sbatch":f"""#!/bin/bash -#SBATCH --job-name=i121-g0 -#SBATCH --cpus-per-task=1 -#SBATCH --mem=4G -#SBATCH --time=00:30:00 -set -euo pipefail -ROOT=$(cd "$(dirname "$0")/.." && pwd -P) -SOLUTION_DIR=${{SOLUTION_DIR:-{SOLUTION_DIR}}} -PYTHON_BIN=${{PYTHON_BIN:-python3}} -"$PYTHON_BIN" -m pytest -q "$SOLUTION_DIR/test_large_lattice_protocol.py" "$SOLUTION_DIR/test_large_lattice_ctqmc.py" -m 'not slow' -"$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" record-g0 --root "$ROOT" --tests-exit-code 0 -""".replace("$","$")} - for name,text in scripts.items(): - write_bytes(root/"slurm"/name,text.encode(),True); os.chmod(root/"slurm"/name,0o755) return index - def _rankdata(values: np.ndarray) -> np.ndarray: order=np.argsort(values,kind="mergesort"); ranks=np.empty(len(values),float) start=0 @@ -474,57 +561,176 @@ def multi_chain_diagnostics(chains: Sequence[Sequence[float]]) -> Mapping[str,An "tail_ess":min(_ess(lower),_ess(upper)), "tau_int_by_original_chain":[ips_tau_int(x) for x in chains]} -def verify_materialization(root: Path) -> Mapping[str,Any]: +def verify_materialization(root: Path, + validate_complete: bool=True) -> Mapping[str,Any]: root=Path(root); index=load_json(root/"index.json") _need(index.get("protocol_id")==PROTOCOL_ID,"index protocol") - expected=(root/"index.sha256").read_text(encoding="ascii").split()[0] - _need(expected==sha_file(root/"index.json"),"index hash") + expected_hash=(root/"index.sha256").read_text(encoding="ascii").split()[0] + _need(expected_hash==sha_file(root/"index.json"),"index hash") meta=load_json(root/"confirmed_meta_manifest.json"); validate_meta(meta) - _need(sha_bytes(canonical_bytes(meta))==index["meta_manifest_sha256"], - "meta hash") - for entry in index.get("entries",()): - path=root/entry["manifest"] - _need(path.is_file() and sha_file(path)==entry["manifest_sha256"], - f"manifest hash: {path}") + meta_hash=sha_bytes(canonical_bytes(meta)) + _need(meta_hash==index.get("meta_manifest_sha256"),"meta hash") + execution=index.get("execution"); _need(isinstance(execution,Mapping),"execution missing") + validate_execution(execution) + counts={"g1_chains":32,"production_chains":80, + "pilot_chains":12,"full_remaining_chains":68} + _need(index.get("counts")==counts,"index counts") + environment=index.get("environment") + _need(isinstance(environment,Mapping),"environment missing") + python_path=Path(str(environment.get("python_executable",""))) + _need(python_path.is_absolute() and python_path.is_file(),"environment Python") + sources=index.get("source_snapshot") + _need(isinstance(sources,Mapping) and sources.get("git_commit") and + set(sources.get("tracked_files_sha256",{}))==set(SOURCE_FILES), + "source snapshot") + _need(source_snapshot()==sources,"current source snapshot drift") + expected_entries=[] + for stage,sizes in (("g1",(2,3)),("production",tuple(x[0] for x in SIZES))): + for L in sizes: + for bi,beta in enumerate(BETAS): + for chain in range(4): + manifest=runner_manifest(meta_hash,stage,L,bi,chain,execution) + slug=("%.8g"%beta).replace(".","p") + rel=Path("manifests")/stage/f"L{L}"/f"beta-{slug}"/f"chain-{chain}.json" + raw=canonical_bytes(manifest) + output=Path("chains")/stage/f"L{L}"/f"beta-{slug}"/f"chain-{chain}" + expected_entries.append({"stage":stage,"cell_id":f"L{L}-b{bi}", + "L":L,"N":L*L,"beta":beta,"beta_index":bi, + "chain_id":chain,"seed":seed_for(L,bi,chain), + "initialization":manifest["monte_carlo"]["initialization"], + "manifest":rel.as_posix(),"manifest_sha256":sha_bytes(raw), + "output":output.as_posix(), + "pilot":stage=="production" and (L,bi) in PILOT}) + entries=index.get("entries") + _need(isinstance(entries,list) and entries==expected_entries, + "index entries/cardinality drift") + identities={(x["stage"],x["cell_id"],x["chain_id"]) for x in entries} + _need(len(identities)==112,"index entries are not unique") + for entry in entries: + manifest_path=_safe_relative(root,entry["manifest"],"manifest") + _safe_relative(root,entry["output"],"output") + _need(manifest_path.is_file() and + sha_file(manifest_path)==entry["manifest_sha256"], + f"manifest hash: {manifest_path}") + _need(canonical_bytes(load_json(manifest_path))==manifest_path.read_bytes(), + f"manifest not canonical: {manifest_path}") + g1=[x for x in entries if x["stage"]=="g1"] + prod=[x for x in entries if x["stage"]=="production"] + pilot=[x for x in prod if x["pilot"]] + remaining=[x for x in prod if not x["pilot"]] + expected_tables={"g1_tasks.tsv":_task_table_bytes(g1), + "pilot_tasks.tsv":_task_table_bytes(pilot), + "full_tasks.tsv":_task_table_bytes(remaining)} + ed=["cell_id\tmanifest\texact_output"] + for x in g1: + if x["chain_id"]==0: + ed.append(f'{x["cell_id"]}\t{x["manifest"]}\texact/g1/{x["cell_id"]}.json') + expected_tables["ed_tasks.tsv"]=("\n".join(ed)+"\n").encode() + for name,raw in expected_tables.items(): + _need((root/name).read_bytes()==raw,f"{name} drift") + artifacts=index.get("generated_artifact_sha256") + _need(isinstance(artifacts,Mapping),"generated artifact hashes missing") + expected_benchmark=kernel_benchmark_manifest(sources) + expected_artifacts=dict(expected_tables) + expected_artifacts["kernel_benchmark_manifest.json"]=canonical_bytes( + expected_benchmark) + for name,text in _generated_scripts( + index["environment"]["python_executable"]).items(): + expected_artifacts[f"slurm/{name}"]=text.encode() + _need(set(artifacts)==set(expected_artifacts), + "generated artifact key set drift") + for name,raw in expected_artifacts.items(): + path=_safe_relative(root,name,"generated artifact") + _need(path.is_file() and path.read_bytes()==raw, + f"generated artifact content: {name}") + _need(artifacts[name]==sha_bytes(raw), + f"generated artifact hash: {name}") + benchmark_info=index.get("kernel_benchmark") + _need(isinstance(benchmark_info,Mapping),"kernel benchmark index missing") + benchmark_path=_safe_relative( + root,benchmark_info.get("manifest"),"kernel benchmark manifest") + _need(load_json(benchmark_path)==expected_benchmark, + "kernel benchmark manifest drift") + _need(benchmark_info.get("manifest_sha256")==sha_file(benchmark_path), + "kernel benchmark manifest hash") + for key in ("output","resource_output","stdout","stderr"): + _need(benchmark_info.get(key)==expected_benchmark[key], + f"kernel benchmark {key} drift") + _safe_relative(root,benchmark_info[key],f"kernel benchmark {key}") + if validate_complete and (root/"COMPLETE").exists(): + _validate_protocol_complete(root,index) return index def _load_chain(root: Path, entry: Mapping[str,Any]) -> Mapping[str,Any]: - manifest_path=root/entry["manifest"]; output=root/entry["output"] - result_path=output/"result.json"; done_path=output/"COMPLETE" + manifest_path=_safe_relative(root,entry["manifest"],"manifest") + output=_safe_relative(root,entry["output"],"output") + result_path=output/"result.json"; done_path=output/"CHAIN_COMPLETE" _need(result_path.is_file() and done_path.is_file(), f"missing chain {entry['cell_id']}/c{entry['chain_id']}") manifest=load_json(manifest_path); result=load_json(result_path) done=load_json(done_path); digest=entry["manifest_sha256"] _need(sha_file(manifest_path)==digest,"manifest drift") - _need(result.get("manifest_sha256")==digest and - done.get("manifest_sha256")==digest,"result binding") + for payload,label in ((result,"result"),(done,"CHAIN_COMPLETE")): + _need(payload.get("schema_version")==1,f"{label} schema") + _need(payload.get("algorithm_id")==CORE_ALGORITHM_ID, + f"{label} algorithm") + _need(payload.get("scope")=="single_chain_execution_only", + f"{label} scope") + _need(payload.get("status")=="run_complete_unvalidated", + f"{label} status") + _need(payload.get("manifest_sha256")==digest,f"{label} binding") _need(done.get("result_json_sha256")==sha_file(result_path),"result hash") - _need(result.get("status")=="complete","chain status") - _need(result.get("completed_steps")==manifest["monte_carlo"]["steps"], - "step count") - _need(result.get("geometry",{}).get("n_sites")==entry["N"],"geometry") + steps=manifest["monte_carlo"]["steps"] + _need(result.get("completed_steps")==steps and + done.get("completed_steps")==steps,"step count") + geometry=result.get("geometry",{}) + _need(geometry.get("Lx",entry["L"])==entry["L"] and + geometry.get("Ly",entry["L"])==entry["L"] and + geometry.get("n_sites")==entry["N"],"geometry") _need(result.get("initialization")==entry["initialization"],"initialization") + for key,value in manifest["model"].items(): + _float_eq(result.get("model",{}).get(key),float(Fraction(value)), + f"result model {key}") + measured=result.get("measurements",{}) + _need(measured.get("momenta")==manifest["measurements"]["momenta"] and + measured.get("displacements")==manifest["measurements"]["displacements"], + "measurement binding") _need(result.get("observables",{}).get("count",0)>0,"no measurements") - canonical_bytes(result) + canonical_bytes(result); canonical_bytes(done) return result -def _momentum(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: +def _aggregate_complex(results: Sequence[Mapping[str,Any]], section: str, + names: Sequence[str]) -> Mapping[str,Any]: total=sum(int(x["observables"]["count"]) for x in results); out={} - for momentum in results[0]["observables"].get("momentum",{}): - out[momentum]={} - for name in ("one_body","density_raw","density_mode"): - pairs=[x["observables"]["momentum"][momentum][name]["mean"] - for x in results] - weights=[int(x["observables"]["count"]) for x in results] + first=results[0]["observables"].get(section,{}) + for key in first: + out[key]={} + for name in names: + pairs=[]; naive=[]; weights=[] + for result in results: + raw=result["observables"][section][key][name] + pairs.append(raw["mean"]) + naive.append(float(raw.get("naive_stderr_abs",math.inf))) + weights.append(int(result["observables"]["count"])) mean=[sum(w*float(p[i]) for w,p in zip(weights,pairs))/total for i in (0,1)] - out[momentum][name]={"mean":mean,"chain_means":pairs} + out[key][name]={"mean":mean,"chain_means":pairs, + "chain_naive_stderr_abs":naive} + return out + +def _momentum(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: + out=_aggregate_complex(results,"momentum", + ("one_body","density_raw","density_mode")) + for momentum in out: raw=out[momentum]["density_raw"]["mean"] mode=out[momentum]["density_mode"]["mean"] out[momentum]["density_connected_from_means"]=[ raw[0]-mode[0]**2-mode[1]**2,raw[1]] return out +def _real_space(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: + return _aggregate_complex(results,"real_space_green",("one_body",)) + def summarize_cell(results: Sequence[Mapping[str,Any]], beta: float, n_sites: int, thresholds: Mapping[str,Any], acceptance_range: Sequence[float]) -> Mapping[str,Any]: @@ -547,7 +753,7 @@ def summarize_cell(results: Sequence[Mapping[str,Any]], beta: float, n_sites: in comp_diag=multi_chain_diagnostics(influence) comp_mcse=float(np.std(np.concatenate(influence),ddof=1)/ math.sqrt(max(1,comp_diag["bulk_ess"]))) - attempted=accepted=zeros=0 + attempted=accepted=zeros=det_zeros=negatives=0 keys=("delta_logdet","relative_T_drift_inf","relative_Q_drift_inf", "fast_inverse_residual_inf","rebuilt_inverse_residual_inf") values={key:[] for key in keys} @@ -557,6 +763,9 @@ def summarize_cell(results: Sequence[Mapping[str,Any]], beta: float, n_sites: in attempted+=int(moves[name]["attempted"]) accepted+=int(moves[name]["accepted"]) zeros+=int(result["counters"].get("zero_weight_rejections",0)) + failures=result["counters"].get("determinant_failures",{}) + det_zeros+=int(failures.get("zero",0)) + negatives+=int(failures.get("negative",0)) for record in result.get("rebuild_diagnostics",()): for key in keys: if record.get(key) is not None: @@ -581,19 +790,94 @@ def summarize_cell(results: Sequence[Mapping[str,Any]], beta: float, n_sites: in "compressibility":compressibility,"compressibility_mcse":comp_mcse, "diagnostics":diagnostics,"compressibility_diagnostics":comp_diag, "momentum":_momentum(results), + "real_space_green":_real_space(results), "acceptance":{"attempted":attempted,"accepted":accepted,"rate":acceptance, "required_range":list(acceptance_range),"pass":accept}, "rebuild":{"maxima":maxima,"pass":rebuild}, - "positivity":{"zero_weight_count":zeros,"negative_sign_count":0, - "negative_count_provenance": - "successful strict-support runner; negatives abort before chain COMPLETE", - "pass":zeros==0}, - "pass":convergence and rebuild and accept and zeros==0} + "positivity":{"zero_weight_count":zeros, + "zero_determinant_failure_count":det_zeros, + "negative_sign_count":negatives, + "negative_count_provenance":"sum of chain determinant_failures counters", + "pass":zeros==0 and det_zeros==0 and negatives==0}, + "pass":convergence and rebuild and accept and zeros==0 and + det_zeros==0 and negatives==0} def _mean_se(pairs: Sequence[Sequence[float]], component: int) -> float: values=np.array([float(x[component]) for x in pairs]) return float(np.std(values,ddof=1)/math.sqrt(len(values))) +def _complex_mcse(sampled: Mapping[str,Any]) -> float: + between=max(_mean_se(sampled["chain_means"],i) for i in (0,1)) + naive=[float(x) for x in sampled.get("chain_naive_stderr_abs",()) + if math.isfinite(float(x))] + within=math.sqrt(sum(x*x for x in naive))/len(naive) if naive else 0.0 + return max(between,within) + +def _compare_complex_section(sampled_section: Mapping[str,Any], + exact_section: Mapping[str,Any], + names: Sequence[str],zmax: float) -> Mapping[str,Any]: + comparison={} + for key,reference in exact_section.items(): + if key not in sampled_section: + comparison[key]={"pass":False,"reason":"missing observable"}; continue + item={} + for name in names: + sampled=sampled_section[key][name] + target=reference[name] if isinstance(reference,Mapping) else reference + se=_complex_mcse(sampled); allowance=max(zmax*se,1e-10) + error=max(abs(float(sampled["mean"][i])-float(target[i])) + for i in (0,1)) + item[name]={"max_abs_error":error,"mcse":se, + "allowance":allowance,"pass":error<=allowance} + item["pass"]=all(v["pass"] for k,v in item.items() if k!="pass") + comparison[key]=item + for key in sampled_section: + if key not in exact_section: + comparison[key]={"pass":False,"reason":"unexpected observable"} + return comparison + +def validate_ed_binding(root: Path, entries: Sequence[Mapping[str,Any]], + exact: Mapping[str,Any]) -> None: + _need(len(entries)==4 and {x["chain_id"] for x in entries}==set(range(4)), + "ED cell chain set") + manifests=[load_json(_safe_relative(root,x["manifest"],"ED manifest")) + for x in entries] + physical=("lattice","model","measurements","exact_diagonalization") + reference={key:manifests[0][key] for key in physical} + for manifest in manifests[1:]: + _need(all(manifest[key]==reference[key] for key in physical), + "ED cell physical manifest mismatch") + chain0=next(x for x in entries if x["chain_id"]==0) + manifest0=load_json(root/chain0["manifest"]) + _need(exact.get("schema_version")==1 and exact.get("status")=="complete", + "ED status") + _need(exact.get("algorithm_id")==ED_ALGORITHM_ID,"ED algorithm") + _need(exact.get("runner_manifest_sha256")==chain0["manifest_sha256"], + "ED manifest digest") + geometry=exact.get("geometry",{}) + _need(geometry.get("Lx")==chain0["L"] and + geometry.get("Ly")==chain0["L"] and + geometry.get("n_sites")==chain0["N"],"ED geometry") + for key,value in manifest0["model"].items(): + _float_eq(exact.get("model",{}).get(key),float(Fraction(value)), + f"ED model {key}") + observables=exact.get("observables",{}) + expected_momenta={f"{x},{y}" for x,y in manifest0["measurements"]["momenta"]} + expected_real={f"{x},{y}" for x,y in manifest0["measurements"]["displacements"]} + _need(set(observables.get("momentum",{}))==expected_momenta, + "ED momentum set") + _need(set(observables.get("real_space_green",{}))==expected_real, + "ED displacement set") + diagnostics=exact.get("diagnostics",{}) + for key in ("density_matrix_trace_residual", + "green_hermitian_residual_inf", + "green_trace_minus_particle_number_abs", + "density_pair_diagonal_residual_inf"): + value=float(diagnostics.get(key,math.inf)) + _need(math.isfinite(value) and value<=1e-8,f"ED diagnostic {key}") + canonical_bytes(exact) + + def compare_ed(cell: Mapping[str,Any], exact: Mapping[str,Any], zmax: float) -> Mapping[str,Any]: scalar={} @@ -612,46 +896,404 @@ def compare_ed(cell: Mapping[str,Any], exact: Mapping[str,Any], scalar["compressibility"]={"estimate":estimate,"exact":target, "mcse":cell["compressibility_mcse"],"allowance":allowance, "pass":abs(estimate-target)<=allowance} - momentum={} - for key,reference in exact["observables"].get("momentum",{}).items(): - if key not in cell["momentum"]: - momentum[key]={"pass":False,"reason":"missing momentum"}; continue - item={} - for name in ("one_body","density_raw","density_mode"): - sampled=cell["momentum"][key][name] - se=max(_mean_se(sampled["chain_means"],i) for i in (0,1)) - allowance=max(zmax*se,1e-10) - error=max(abs(float(sampled["mean"][i])-float(reference[name][i])) - for i in (0,1)) - item[name]={"max_abs_error":error, - "mcse_from_four_chain_means":se, - "allowance":allowance,"pass":error<=allowance} - item["pass"]=all(v["pass"] for k,v in item.items() if k!="pass") - momentum[key]=item + momentum=_compare_complex_section( + cell["momentum"],exact["observables"].get("momentum",{}), + ("one_body","density_raw","density_mode"),zmax) + real_space=_compare_complex_section( + cell["real_space_green"], + exact["observables"].get("real_space_green",{}),("one_body",),zmax) return {"scalar":scalar,"momentum":momentum, - "momentum_mcse_note":"SE across four chain means; core stores no momentum traces", + "real_space_green":real_space, + "complex_mcse_note": + "maximum of SE across four chain means and combined per-chain naive SE", "pass":all(x["pass"] for x in scalar.values()) and - all(x["pass"] for x in momentum.values())} + all(x["pass"] for x in momentum.values()) and + all(x["pass"] for x in real_space.values())} def _gate(root: Path, name: str, payload: Mapping[str,Any]) -> Mapping[str,Any]: - record={"schema_version":1,"protocol_id":PROTOCOL_ID,"gate":name,**payload} - write_json(Path(root)/"gates"/f"{name}.json",record); return record + root=Path(root) + _need(not (root/"COMPLETE").exists(), + "root COMPLETE is immutable; refuse gate overwrite") + index=verify_materialization(root) + bindings={"index_sha256":sha_file(root/"index.json"), + "meta_manifest_sha256":index["meta_manifest_sha256"]} + record={"schema_version":1,"protocol_id":PROTOCOL_ID,"gate":name, + **payload,**bindings} + path=root/"gates"/f"{name}.json" + if path.exists(): + raw=path.read_bytes(); digest=sha_bytes(raw) + history=root/"gates"/"history"/f"{name}.{digest}.json" + if not history.exists(): + write_bytes(history,raw,True) + write_json(path,record); return record def record_g0(root: Path, code: int) -> Mapping[str,Any]: verify_materialization(root) return _gate(root,"G0",{"status":"PASS" if code==0 else "FAIL", - "tests_exit_code":code,"index_sha256":sha_file(Path(root)/"index.json")}) + "tests_exit_code":code}) -def _require_gate(root: Path, name: str) -> Mapping[str,Any]: - value=load_json(Path(root)/"gates"/f"{name}.json") - _need(value.get("protocol_id")==PROTOCOL_ID and value.get("gate")==name and - value.get("status")=="PASS",f"required {name} not PASS") +def _validate_gate_record(root: Path, name: str, value: Mapping[str,Any], + index: Mapping[str,Any]) -> None: + _need(isinstance(value,Mapping),f"required {name} record") + _need(value.get("schema_version")==1,f"required {name} schema") + _need(value.get("protocol_id")==PROTOCOL_ID and value.get("gate")==name, + f"required {name} identity") + _need(value.get("status")=="PASS",f"required {name} not PASS") + _need(value.get("index_sha256")==sha_file(root/"index.json"), + f"required {name} index binding") + _need(value.get("meta_manifest_sha256")==index["meta_manifest_sha256"], + f"required {name} meta binding") + if name=="G0": + _need(value.get("tests_exit_code")==0,"required G0 test evidence") + elif name in {"G1","G2","G3"}: + expected={"G1":("g1",8),"G2":("pilot",3), + "G3":("full",20)}[name] + cells=value.get("cells") + _need(value.get("stage")==expected[0],f"required {name} stage") + _need(isinstance(cells,Mapping) and len(cells)==expected[1], + f"required {name} cell cardinality") + _need(value.get("chain_cells_pass") is True and + value.get("all_cells_pass") is True and + all(isinstance(cell,Mapping) and cell.get("pass") is True + for cell in cells.values()),f"required {name} cell evidence") + if name=="G2": + _need(isinstance(value.get("kernel_benchmark"),Mapping) and + value["kernel_benchmark"].get("pass") is True, + "required G2 kernel benchmark evidence") + _need(isinstance(value.get("resource_gate"),Mapping) and + value["resource_gate"].get("pass") is True, + "required G2 resource evidence") + elif name=="G4": + chains=value.get("chains"); checks=value.get("checks") + _need(isinstance(chains,list) and len(chains)==112, + "required G4 chain cardinality") + _need(value.get("distinct_slurm_array_tasks")==112, + "required G4 distinct task evidence") + _need(isinstance(checks,Mapping) and bool(checks) and + all(item is True for item in checks.values()), + "required G4 provenance checks") + else: + raise ProtocolError(f"unknown gate {name}") + canonical_bytes(value) + +def _require_gate(root: Path, name: str, + index: Optional[Mapping[str,Any]]=None) -> Mapping[str,Any]: + root=Path(root) + if index is None: + index=verify_materialization(root,validate_complete=False) + value=load_json(root/"gates"/f"{name}.json") + _validate_gate_record(root,name,value,index) return value +def _validate_complete_evidence(root: Path, index: Mapping[str,Any], + gates: Mapping[str,Mapping[str,Any]]) -> None: + expected={(entry["stage"],entry["cell_id"],entry["chain_id"]):entry + for entry in index["entries"]} + records=gates["G4"].get("chains") + _need(isinstance(records,list),"COMPLETE G4 chain evidence") + by_identity={} + for record in records: + _need(isinstance(record,Mapping),"COMPLETE G4 chain record") + identity=(record.get("stage"),record.get("cell_id"), + record.get("chain_id")) + _need(identity in expected and identity not in by_identity, + "COMPLETE G4 chain identity") + by_identity[identity]=record + _need(set(by_identity)==set(expected),"COMPLETE G4 chain coverage") + hash_fields={"result_sha256":"result.json", + "chain_complete_sha256":"CHAIN_COMPLETE", + "runner_stdout_sha256":"runner.stdout", + "runner_stderr_sha256":"runner.stderr", + "preflight_sha256":"preflight.log"} + for identity,entry in expected.items(): + record=by_identity[identity] + output=_safe_relative(root,entry["output"],"COMPLETE chain output") + for field,filename in hash_fields.items(): + path=output/filename + _need(path.is_file() and record.get(field)==sha_file(path), + f"COMPLETE chain evidence drift: {identity} {filename}") + resource=record.get("resource") + resource_path=output/"resource.tsv" + _need(isinstance(resource,Mapping) and resource_path.is_file() and + resource.get("sha256")==sha_file(resource_path), + f"COMPLETE chain evidence drift: {identity} resource.tsv") + g1_cells=gates["G1"].get("cells") + expected_cells={entry["cell_id"] for entry in index["entries"] + if entry["stage"]=="g1"} + _need(isinstance(g1_cells,Mapping) and set(g1_cells)==expected_cells, + "COMPLETE G1 ED coverage") + for cell_id in expected_cells: + exact=root/"exact"/"g1"/f"{cell_id}.json" + cell=g1_cells[cell_id] + _need(exact.is_file() and isinstance(cell,Mapping) and + cell.get("exact_ed_sha256")==sha_file(exact), + f"COMPLETE G1 ED evidence drift: {cell_id}") + current_benchmark=validate_kernel_benchmark(root,index) + _need(gates["G2"].get("kernel_benchmark")==current_benchmark, + "COMPLETE G2 benchmark evidence drift") + +def _validate_protocol_complete(root: Path, + index: Mapping[str,Any]) -> Mapping[str,Any]: + root=Path(root); path=root/"COMPLETE"; value=load_json(path) + _need(value.get("schema_version")==1,"COMPLETE schema") + _need(value.get("protocol_id")==PROTOCOL_ID,"COMPLETE protocol") + _need(value.get("status")=="complete","COMPLETE status") + _need(value.get("index_sha256")==sha_file(root/"index.json"), + "COMPLETE index binding") + _need(value.get("meta_manifest_sha256")==index["meta_manifest_sha256"], + "COMPLETE meta binding") + hashes=value.get("gate_report_sha256") + _need(isinstance(hashes,Mapping) and + set(hashes)=={"G0","G1","G2","G3","G4"}, + "COMPLETE gate hash set") + gates={} + for name in ("G0","G1","G2","G3","G4"): + gates[name]=_require_gate(root,name,index=index) + _need(hashes[name]==sha_file(root/"gates"/f"{name}.json"), + f"COMPLETE stale {name} gate hash") + _validate_complete_evidence(root,index,gates) + _need(canonical_bytes(value)==path.read_bytes(),"COMPLETE not canonical") + return value + +def _resource_evidence(path: Path) -> Mapping[str,Any]: + _need(path.is_file(),"resource.tsv missing") + elapsed=[]; rss=[] + for line in path.read_text(encoding="utf-8").splitlines(): + fields=line.split("\t") + if len(fields)!=2: + continue + if fields[0]=="elapsed_seconds": + elapsed.append(float(fields[1])) + elif fields[0]=="max_rss_kb": + rss.append(int(fields[1])) + _need(elapsed and rss and all(math.isfinite(x) and x>=0 for x in elapsed) + and all(x>0 for x in rss),"resource.tsv invalid") + return {"attempts":len(elapsed),"elapsed_seconds":elapsed, + "max_rss_kb":rss,"sha256":sha_file(path)} + +def validate_kernel_benchmark(root: Path, + index: Mapping[str,Any]) -> Mapping[str,Any]: + info=index["kernel_benchmark"] + manifest_path=_safe_relative(root,info["manifest"],"benchmark manifest") + manifest=load_json(manifest_path); expected=kernel_benchmark_manifest( + index["source_snapshot"]) + _need(manifest==expected,"benchmark manifest content") + _need(sha_file(manifest_path)==info["manifest_sha256"], + "benchmark manifest digest") + output=_safe_relative(root,info["output"],"benchmark output") + _need(output.is_file(),"benchmark output missing") + report=load_json(output) + _need(report.get("schema_version")==1,"benchmark schema") + _need(report.get("algorithm_id")==BENCHMARK_ALGORITHM_ID, + "benchmark algorithm") + _need(report.get("status")=="benchmark_complete_unvalidated", + "benchmark status") + parameters=report.get("parameters",{}) + _need(parameters==manifest["parameters"],"benchmark parameters/model") + provenance=report.get("provenance",{}) + sources=index["source_snapshot"]["tracked_files_sha256"] + _need(provenance.get("benchmark_source_sha256")== + sources["large_lattice_kernel_benchmark.py"], + "benchmark source hash") + _need(provenance.get("ctqmc_source_sha256")== + sources["large_lattice_ctqmc.py"],"benchmark CTQMC source hash") + _need(provenance.get("source_commit")== + index["source_snapshot"]["git_commit"],"benchmark source commit") + environment=report.get("environment",{}) + _need(Path(str(environment.get("python_executable",""))).resolve()== + Path(index["environment"]["python_executable"]).resolve(), + "benchmark Python environment") + _need(environment.get("numpy_version")==index["environment"]["numpy_version"] + and environment.get("scipy_version")==index["environment"]["scipy_version"], + "benchmark package environment") + blas=report.get("single_thread_blas",{}) + _need(blas.get("set_before_numpy_import") is True and + set(blas.get("environment",{}).values())=={"1"}, + "benchmark BLAS threading") + cases=report.get("cases") + _need(isinstance(cases,list) and + [(x.get("L"),x.get("N")) for x in cases]== + [(4,16),(8,64),(12,144),(16,256)],"benchmark sizes") + correctness=report.get("overall_correctness_pass") is True + fallback=report.get("total_fallback_count")=={"insert":0,"delete":0} + case_checks=True; case_by_n={} + for case in cases: + case_by_n[int(case["N"])]=case + case_checks=case_checks and case.get("correctness",{}).get("pass") is True + case_checks=case_checks and case.get("fallback_count")=={ + "insert":0,"delete":0} + for move in ("insert","delete"): + timing=case.get("latency",{}).get(move,{}) + rank=timing.get("rank3",{}); dense=timing.get("full_word_rebuild",{}) + rank_samples=[int(x) for x in rank.get("samples_ns",())] + dense_samples=[int(x) for x in dense.get("samples_ns",())] + _need(len(rank_samples)==manifest["parameters"]["repeats"] and + len(dense_samples)==manifest["parameters"]["repeats"] and + min(rank_samples+dense_samples)>0,"benchmark timing samples") + _float_eq(rank.get("median_ns"),statistics.median(rank_samples), + "benchmark rank3 median") + _float_eq(dense.get("median_ns"),statistics.median(dense_samples), + "benchmark dense median") + expected_speed=float(dense["median_ns"])/float(rank["median_ns"]) + _float_eq(timing.get("speedup_dense_over_rank3"),expected_speed, + "benchmark speedup") + speedup_n144={move:float(case_by_n[144]["latency"][move][ + "speedup_dense_over_rank3"]) for move in ("insert","delete")} + slopes={} + x=np.log(np.array([64.0,144.0,256.0])) + for move in ("insert","delete"): + y=np.log(np.array([float(case_by_n[n]["latency"][move]["rank3"][ + "median_ns"]) for n in (64,144,256)])) + slopes[move]=float(np.polyfit(x,y,1)[0]) + speedup_pass=all(value>2.0 for value in speedup_n144.values()) + slope_pass=all(math.isfinite(value) and value<=2.7 + for value in slopes.values()) + resource=_resource_evidence(_safe_relative( + root,info["resource_output"],"benchmark resource")) + log_hashes={} + for key in ("stdout","stderr"): + path=_safe_relative(root,info[key],f"benchmark {key}") + _need(path.is_file(),f"benchmark {key} missing") + log_hashes[key]=sha_file(path) + preflight=root/"benchmark"/"preflight.log" + _need(preflight.is_file(),"benchmark preflight log missing") + passed=correctness and fallback and case_checks and speedup_pass and slope_pass + return {"pass":passed,"correctness_pass":correctness and case_checks, + "fallback_pass":fallback,"speedup_N144":speedup_n144, + "speedup_pass":speedup_pass,"rank3_loglog_slopes_N64_144_256":slopes, + "slope_max":2.7,"slope_pass":slope_pass, + "manifest_sha256":sha_file(manifest_path), + "output_sha256":sha_file(output),"resource":resource, + "log_sha256":log_hashes,"preflight_sha256":sha_file(preflight)} + +def _normalize_slurm_id(value: Any) -> Optional[str]: + if isinstance(value,bool): + return None + if isinstance(value,int): + return str(value) if value>=0 else None + if isinstance(value,str) and value and value.isascii() and value.isdecimal(): + return value + return None + +def audit_provenance(root: Path, index: Mapping[str,Any], + write_complete: bool=False) -> Mapping[str,Any]: + _require_gate(root,"G3") + checks={"source_snapshot":source_snapshot()==index["source_snapshot"], + "environment":environment_snapshot()==index["environment"]} + chains=[]; jobs=set() + for entry in index["entries"]: + result=_load_chain(root,entry); output=root/entry["output"] + execution=result.get("execution_environment",{}) + expected=index["environment"] + env_ok=all(execution.get(key)==expected.get(key) for key in ( + "python_executable","python_version","numpy_version","scipy_version")) + slurm=execution.get("slurm",{}) + job_id=_normalize_slurm_id(slurm.get("job_id")) + task_id=_normalize_slurm_id(slurm.get("array_task_id")) + job_ok=job_id is not None and task_id is not None + _need((output/"runner.stdout").is_file() and + (output/"runner.stderr").is_file() and + (output/"preflight.log").is_file(),"runner/preflight logs missing") + resource=_resource_evidence(output/"resource.tsv") + checks[f"{entry['stage']}:{entry['cell_id']}:c{entry['chain_id']}"] = ( + env_ok and job_ok) + if job_ok: + jobs.add((job_id,task_id)) + chains.append({"stage":entry["stage"],"cell_id":entry["cell_id"], + "chain_id":entry["chain_id"],"result_sha256":sha_file(output/"result.json"), + "chain_complete_sha256":sha_file(output/"CHAIN_COMPLETE"), + "runner_stdout_sha256":sha_file(output/"runner.stdout"), + "runner_stderr_sha256":sha_file(output/"runner.stderr"), + "preflight_sha256":sha_file(output/"preflight.log"), + "resource":resource,"slurm_job_id":job_id,"array_task_id":task_id}) + passed=all(checks.values()) and len(chains)==112 and len(jobs)==112 + report=_gate(root,"G4",{"status":"PASS" if passed else "INCONCLUSIVE", + "stage":"provenance","checks":checks,"chains":chains, + "distinct_slurm_array_tasks":len(jobs), + "provenance_reconstruction": + "separate same-implementation provenance audit; does not query sacct or independently recompute scientific observables; checks source, environment, reported Slurm IDs, logs, resources, manifests, and result hashes"}) + if write_complete and passed: + write_protocol_complete(root) + return report + +def pilot_resource_gate(root: Path, entries: Sequence[Mapping[str,Any]], + cells: Mapping[str,Any]) -> Mapping[str,Any]: + grouped={}; records=[]; passed=True + for entry in entries: + output=root/entry["output"] + try: + evidence=_resource_evidence(output/"resource.tsv") + for name in ("runner.stdout","runner.stderr","preflight.log"): + _need((output/name).is_file(),f"pilot {name} missing") + result=load_json(output/"result.json") + result_wall=float(result.get("timing",{}).get("wall_seconds",math.nan)) + result_rss=int(result.get("resource_usage",{}).get("max_rss_kb",0)) + wall=sum(map(float,evidence["elapsed_seconds"])) + rss=max([result_rss,*map(int,evidence["max_rss_kb"])]) + _need(math.isfinite(result_wall) and result_wall>0 and + math.isfinite(wall) and wall>0 and rss>0, + "pilot nonfinite resource") + grouped.setdefault(int(entry["N"]),{"wall":[],"rss":[]}) + grouped[int(entry["N"])]["wall"].append(wall) + grouped[int(entry["N"])]["rss"].append(rss) + records.append({"cell_id":entry["cell_id"],"chain_id":entry["chain_id"], + "wall_seconds_all_attempts":wall,"result_wall_seconds":result_wall, + "max_rss_kb":rss,"resource":evidence}) + except (ProtocolError,OSError,ValueError,TypeError) as exc: + passed=False; records.append({"cell_id":entry["cell_id"], + "chain_id":entry["chain_id"],"error":str(exc)}) + medians={} + for n_sites in (16,64,144): + values=grouped.get(n_sites,{"wall":[],"rss":[]}) + if len(values["wall"])!=4 or len(values["rss"])!=4: + passed=False; continue + medians[str(n_sites)]={"wall_seconds":float(statistics.median(values["wall"])), + "max_rss_kb":float(statistics.median(values["rss"]))} + memory_exponent=wall_exponent=math.inf; projection={} + if all(str(n) in medians for n in (64,144)): + ratio=144.0/64.0 + memory_exponent=math.log(medians["144"]["max_rss_kb"]/ + medians["64"]["max_rss_kb"])/math.log(ratio) + wall_exponent=math.log(medians["144"]["wall_seconds"]/ + medians["64"]["wall_seconds"])/math.log(ratio) + nratio=256.0/144.0 + projected_wall=1.5*medians["144"]["wall_seconds"]*nratio**max(0.0,wall_exponent) + projected_rss=1.5*medians["144"]["max_rss_kb"]*nratio**max(0.0,memory_exponent) + projection={"N":256,"safety_factor":1.5,"wall_seconds":projected_wall, + "max_rss_kb":projected_rss, + "current_4h_sufficient":projected_wall<=14400, + "current_8G_sufficient":projected_rss<=8*1024*1024, + "advisory_only_no_preregistered_wall_or_memory_limit":True} + memory_pass=math.isfinite(memory_exponent) and memory_exponent<=2.5 + warmup={}; warmup_pass=True + by_cell={x["cell_id"]:x for x in entries} + for cell_id,cell in cells.items(): + taus=[float(tau) for diagnostic in cell["diagnostics"].values() + for tau in diagnostic["tau_int_by_original_chain"]] + maximum=max(taus); manifest=load_json(root/by_cell[cell_id]["manifest"]) + warmup_steps=int(manifest["monte_carlo"]["warmup"]) + measure_every=int(manifest["monte_carlo"]["measure_every"]) + required=50.0*maximum*measure_every + cell_pass=math.isfinite(maximum) and warmup_steps>=required + warmup_pass=warmup_pass and cell_pass + warmup[cell_id]={"max_tau_int_measurements":maximum, + "measure_every":measure_every,"warmup_steps":warmup_steps, + "required_warmup_steps":required,"pass":cell_pass} + passed=passed and memory_pass and warmup_pass + return {"pass":passed,"chain_records":records,"median_by_N":medians, + "memory_loglog_exponent_N64_144":memory_exponent, + "memory_exponent_max":2.5,"memory_scaling_pass":memory_pass, + "wall_loglog_exponent_N64_144":wall_exponent, + "warmup_rule":"warmup_steps >= 50*max_tau_int_measurements*measure_every", + "warmup":warmup,"warmup_pass":warmup_pass, + "conservative_L16_projection":projection} + def audit(root: Path, stage: str, write_complete: bool=False) -> Mapping[str,Any]: root=Path(root); index=verify_materialization(root) thresholds=load_json(root/"confirmed_meta_manifest.json")["thresholds"] _require_gate(root,"G0") + if stage=="provenance": + return audit_provenance(root,index,write_complete) if stage in {"pilot","full"}: _require_gate(root,"G1") if stage=="full": _require_gate(root,"G2") if stage=="g1": @@ -665,49 +1307,57 @@ def audit(root: Path, stage: str, write_complete: bool=False) -> Mapping[str,Any name="G3"; arange=thresholds["full_acceptance_hard_range"] else: raise ProtocolError("bad audit stage") - grouped={}; metadata={} + grouped={}; metadata={}; cell_entries={} for entry in entries: grouped.setdefault(entry["cell_id"],[]).append(_load_chain(root,entry)) metadata.setdefault(entry["cell_id"],entry) + cell_entries.setdefault(entry["cell_id"],[]).append(entry) cells={} for cell_id,results in grouped.items(): first=metadata[cell_id] cell=summarize_cell(results,float(first["beta"]),int(first["N"]), thresholds,arange) if stage=="g1": - exact=root/"exact"/"g1"/f"{cell_id}.json" - _need(exact.is_file(),f"missing ED {exact}") - cell["ed"]=compare_ed(cell,load_json(exact), - float(thresholds["ed_z_score_max"])) + exact_path=root/"exact"/"g1"/f"{cell_id}.json" + _need(exact_path.is_file(),f"missing ED {exact_path}") + exact=load_json(exact_path) + validate_ed_binding(root,cell_entries[cell_id],exact) + cell["exact_ed_sha256"]=sha_file(exact_path) + cell["ed"]=compare_ed(cell,exact,float(thresholds["ed_z_score_max"])) cell["pass"]=cell["pass"] and cell["ed"]["pass"] cells[cell_id]=cell - passed=bool(cells) and all(x["pass"] for x in cells.values()) - limits=[] + chain_cells_pass=bool(cells) and all(x["pass"] for x in cells.values()) + passed=chain_cells_pass; limits=[]; benchmark=None; resources=None if stage=="pilot": - limits=["rank3-versus-rebuild kernel speedup unavailable from core v1"] - passed=False - report=_gate(root,name,{"status":"PASS" if passed else "INCONCLUSIVE", - "stage":stage,"cells":cells,"all_cells_pass":passed, - "evidence_limits":limits,"diagnostic_method":DIAGNOSTIC_METHOD, - "index_sha256":sha_file(root/"index.json")}) - if stage=="full": - _gate(root,"G4",{"status":"PASS" if passed else "INCONCLUSIVE", - "provenance_reconstruction": - "canonical manifests and all chain result hashes reverified", - "index_sha256":sha_file(root/"index.json")}) - if write_complete and passed: - write_protocol_complete(root) - return report + try: + benchmark=validate_kernel_benchmark(root,index) + except (ProtocolError,KeyError,TypeError,ValueError) as exc: + benchmark={"pass":False,"validation_error":str(exc)} + resources=pilot_resource_gate(root,entries,cells) + passed=(chain_cells_pass and bool(benchmark.get("pass")) and + bool(resources.get("pass"))) + if not benchmark.get("pass"): + limits.append("kernel benchmark gate did not pass") + if not resources.get("pass"): + limits.append("pilot resource/warmup/scaling gate did not pass") + return _gate(root,name,{"status":"PASS" if passed else "INCONCLUSIVE", + "stage":stage,"cells":cells,"chain_cells_pass":chain_cells_pass, + "all_cells_pass":passed,"kernel_benchmark":benchmark, + "resource_gate":resources,"evidence_limits":limits, + "diagnostic_method":DIAGNOSTIC_METHOD}) def write_protocol_complete(root: Path) -> Mapping[str,Any]: - root=Path(root); index=verify_materialization(root); hashes={} + root=Path(root) + _need(not (root/"COMPLETE").exists(),"refuse COMPLETE overwrite") + index=verify_materialization(root); hashes={} for name in ("G0","G1","G2","G3","G4"): _require_gate(root,name); hashes[name]=sha_file(root/"gates"/f"{name}.json") payload={"schema_version":1,"protocol_id":PROTOCOL_ID,"status":"complete", "index_sha256":sha_file(root/"index.json"), "meta_manifest_sha256":index["meta_manifest_sha256"], "gate_report_sha256":hashes, - "claim_boundary":"mu=0 finite-temperature scaling only; no finite-density ground-state or rapid-mixing claim"} + "claim_boundary":("mu=0 finite-temperature scaling only; no finite-density ground-state or rapid-mixing claim; " + "G4 is a separate same-implementation provenance audit without sacct verification or independent scientific recomputation")} write_json(root/"COMPLETE",payload,True); return payload def _execution(args: argparse.Namespace) -> Mapping[str,Any]: @@ -732,7 +1382,7 @@ def main(argv: Optional[Sequence[str]]=None) -> int: g0=sub.add_parser("record-g0"); g0.add_argument("--root",type=Path,required=True) g0.add_argument("--tests-exit-code",type=int,required=True) inspect=sub.add_parser("audit"); inspect.add_argument("--root",type=Path,required=True) - inspect.add_argument("--stage",choices=("g1","pilot","full"),required=True) + inspect.add_argument("--stage",choices=("g1","pilot","full","provenance"),required=True) inspect.add_argument("--write-complete",action="store_true") args=parser.parse_args(argv) if args.command=="materialize": @@ -748,5 +1398,61 @@ def main(argv: Optional[Sequence[str]]=None) -> int: sort_keys=True,allow_nan=False),flush=True) return 2 if args.command=="audit" and result.get("status")!="PASS" else 0 +def environment_snapshot() -> Mapping[str,Any]: + executable=Path(sys.executable).resolve() + _need(executable.is_absolute() and executable.is_file(), + "validated Python executable is unavailable") + versions={} + for package in ("numpy","scipy","pytest"): + try: + versions[package]=importlib.metadata.version(package) + except importlib.metadata.PackageNotFoundError as exc: + raise ProtocolError(f"validated environment lacks {package}") from exc + return { + "python_executable":str(executable), + "python_version":platform.python_version(), + "python_implementation":platform.python_implementation(), + "numpy_version":versions["numpy"],"scipy_version":versions["scipy"], + "pytest_version":versions["pytest"]} + +def _git_output(*args: str) -> str: + try: + result=subprocess.run( + ("git",*args),cwd=SOLUTION_DIR,check=True,text=True, + stdout=subprocess.PIPE,stderr=subprocess.PIPE) + except (OSError,subprocess.CalledProcessError) as exc: + raise ProtocolError("cannot capture git provenance") from exc + return result.stdout.strip() + +def source_snapshot() -> Mapping[str,Any]: + files={} + for name in SOURCE_FILES: + path=SOLUTION_DIR/name + _need(path.is_file(),f"source artifact missing: {name}") + files[name]=sha_file(path) + status=_git_output("status","--porcelain","--",*[str(SOLUTION_DIR/name) + for name in SOURCE_FILES]) + return {"git_commit":_git_output("rev-parse","HEAD"), + "tracked_files_sha256":files, + "source_files_dirty":bool(status)} + +def _safe_relative(root: Path, raw: Any, label: str) -> Path: + _need(isinstance(raw,str) and raw and not Path(raw).is_absolute(), + f"{label} path invalid") + root_resolved=Path(root).resolve() + candidate=(root_resolved/raw).resolve() + try: + candidate.relative_to(root_resolved) + except ValueError as exc: + raise ProtocolError(f"{label} path escapes root") from exc + return candidate + +def _task_table_bytes(entries: Sequence[Mapping[str,Any]]) -> bytes: + lines=["task_id\tstage\tcell_id\tchain_id\tmanifest\toutput"] + for i,x in enumerate(entries): + lines.append("\t".join(map(str,(i,x["stage"],x["cell_id"],x["chain_id"], + x["manifest"],x["output"])))) + return ("\n".join(lines)+"\n").encode() + if __name__=="__main__": raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics.py b/tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics.py new file mode 100644 index 000000000..2ff8fbd2c --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics.py @@ -0,0 +1,644 @@ +#!/usr/bin/env python3 +"""Independent local three-site Fock analysis for the frozen A/B vertices. + +The script constructs the 8x8 Fock operators directly from the CAR algebra, +forms the complete S3 twirls, analyzes particle-number sectors, and decomposes +h=g(I-M) in the canonical S3-invariant operator basis + + I, N, K, Q2, P_s^dagger P_s, n1 n2 n3. + +It does not import the CTQMC or ED implementation. Every run performs internal +algebra, symmetry, positivity, Fock-lift, and reconstruction checks before +emitting strict finite JSON. +""" +from __future__ import annotations + +import argparse +import hashlib +import itertools +import json +import math +import os +import tempfile +from dataclasses import dataclass +from pathlib import Path +from typing import Any, Dict, List, Mapping, Optional, Sequence, Tuple + +import numpy as np +from scipy.linalg import expm + + +ALGORITHM_ID = "local-three-site-s3-twirl-physics-v1" +SOURCE_COMMIT = "886a082963429f3f62deb9e6090352a58a05b89a" +N_MODES = 3 +FOCK_DIMENSION = 1 << N_MODES +EPSILON = 0.01 +KAPPA = 0.02 +VERTEX_STRENGTH = 0.25 +COUPLING_G = 0.25 +TOLERANCE = 2.0e-11 + + +@dataclass(frozen=True) +class FockAlgebra: + annihilation: Tuple[np.ndarray, ...] + creation: Tuple[np.ndarray, ...] + number: Tuple[np.ndarray, ...] + total_number: np.ndarray + + +def occupied(mask: int) -> Tuple[int, ...]: + return tuple(site for site in range(N_MODES) if mask & (1 << site)) + + +def particle_number(mask: int) -> int: + return int(mask.bit_count()) + + +def annihilation_operator(site: int) -> np.ndarray: + result = np.zeros((FOCK_DIMENSION, FOCK_DIMENSION), dtype=float) + lower_mask = (1 << site) - 1 + for source in range(FOCK_DIMENSION): + if not source & (1 << site): + continue + target = source ^ (1 << site) + sign = -1.0 if (source & lower_mask).bit_count() % 2 else 1.0 + result[target, source] = sign + return result + + +def build_fock_algebra() -> FockAlgebra: + annihilation = tuple(annihilation_operator(i) for i in range(N_MODES)) + creation = tuple(operator.T for operator in annihilation) + number = tuple(creation[i] @ annihilation[i] for i in range(N_MODES)) + total_number = sum(number, np.zeros((FOCK_DIMENSION, FOCK_DIMENSION))) + return FockAlgebra(annihilation, creation, number, total_number) + + +def quadratic_lift(generator: np.ndarray, algebra: FockAlgebra) -> np.ndarray: + result = np.zeros((FOCK_DIMENSION, FOCK_DIMENSION), dtype=float) + for i in range(N_MODES): + for j in range(N_MODES): + result += float(generator[i, j]) * ( + algebra.creation[i] @ algebra.annihilation[j] + ) + return result + + +def fock_lift(one_body: np.ndarray) -> np.ndarray: + """Gamma(U) from exterior minors in the integer-mask Fock basis.""" + result = np.zeros((FOCK_DIMENSION, FOCK_DIMENSION), dtype=float) + for source in range(FOCK_DIMENSION): + columns = occupied(source) + for target in range(FOCK_DIMENSION): + rows = occupied(target) + if len(rows) != len(columns): + continue + if not rows: + result[target, source] = 1.0 + else: + result[target, source] = float( + np.linalg.det(one_body[np.ix_(rows, columns)]) + ) + return result + + +def permutation_matrix(permutation: Sequence[int]) -> np.ndarray: + return np.eye(N_MODES, dtype=float)[list(permutation)] + + +def matrix_inf_norm(matrix: np.ndarray) -> float: + return float(np.linalg.norm(matrix, np.inf)) + + +def relative_inf_residual(actual: np.ndarray, expected: np.ndarray) -> float: + return matrix_inf_norm(actual - expected) / max( + 1.0, matrix_inf_norm(expected) + ) + + +def cluster_values(values: Sequence[float], tolerance: float = 2.0e-10) -> List[Dict[str, Any]]: + clusters: List[List[float]] = [] + for value in sorted(float(item) for item in values): + if not clusters or abs(value - sum(clusters[-1]) / len(clusters[-1])) > tolerance: + clusters.append([value]) + else: + clusters[-1].append(value) + return [ + { + "value": float(sum(cluster) / len(cluster)), + "multiplicity": len(cluster), + } + for cluster in clusters + ] + + +def sector_block(operator: np.ndarray, number: int) -> np.ndarray: + indices = [mask for mask in range(FOCK_DIMENSION) + if particle_number(mask) == number] + return operator[np.ix_(indices, indices)] + + +def sector_report( + hamiltonian: np.ndarray, + twirl: Optional[np.ndarray], +) -> Mapping[str, Any]: + labels = { + 0: "vacuum", + 1: "one_particle", + 2: "two_particle", + 3: "fully_occupied", + } + result: Dict[str, Any] = {} + for number in range(N_MODES + 1): + h_values = np.linalg.eigvalsh(sector_block(hamiltonian, number)) + entry: Dict[str, Any] = { + "label": labels[number], + "dimension": len(h_values), + "hamiltonian_energies": cluster_values(h_values), + } + if twirl is not None: + m_values = np.linalg.eigvalsh(sector_block(twirl, number)) + entry["twirl_eigenvalues"] = cluster_values(m_values) + result[str(number)] = entry + return result + + +def canonical_operators(algebra: FockAlgebra) -> Mapping[str, np.ndarray]: + identity = np.eye(FOCK_DIMENSION) + hopping = np.zeros_like(identity) + for i in range(N_MODES): + for j in range(N_MODES): + if i != j: + hopping += algebra.creation[i] @ algebra.annihilation[j] + pair_density = np.zeros_like(identity) + for i in range(N_MODES): + for j in range(i + 1, N_MODES): + pair_density += algebra.number[i] @ algebra.number[j] + pair_creator = ( + algebra.creation[0] @ algebra.creation[1] + - algebra.creation[0] @ algebra.creation[2] + + algebra.creation[1] @ algebra.creation[2] + ) / math.sqrt(3.0) + sign_pair_projector = pair_creator @ pair_creator.T + triple_density = algebra.number[0] @ algebra.number[1] @ algebra.number[2] + return { + "identity": identity, + "N": algebra.total_number, + "K": hopping, + "Q2": pair_density, + "Ps_dagger_Ps": sign_pair_projector, + "n1_n2_n3": triple_density, + } + + +def canonical_decomposition( + operator: np.ndarray, + basis: Mapping[str, np.ndarray], +) -> Mapping[str, Any]: + names = list(basis) + design = np.column_stack([basis[name].reshape(-1) for name in names]) + coefficients, _, rank, singular_values = np.linalg.lstsq( + design, operator.reshape(-1), rcond=None + ) + reconstructed = sum( + float(coefficient) * basis[name] + for name, coefficient in zip(names, coefficients) + ) + residual = relative_inf_residual(reconstructed, operator) + quadratic_design = np.column_stack( + [basis[name].reshape(-1) for name in ("identity", "N", "K")] + ) + quadratic_coefficients, _, _, _ = np.linalg.lstsq( + quadratic_design, operator.reshape(-1), rcond=None + ) + quadratic_fit = sum( + float(coefficient) * basis[name] + for name, coefficient in zip( + ("identity", "N", "K"), quadratic_coefficients + ) + ) + quadratic_residual = relative_inf_residual(quadratic_fit, operator) + coefficient_map = { + name: float(value) for name, value in zip(names, coefficients) + } + J = coefficient_map["Ps_dagger_Ps"] + pair_signs = np.array([1.0, -1.0, 1.0]) + correlated_pair_matrix = ( + J / 3.0 * np.outer(pair_signs, pair_signs) + ) + return { + "basis_order": names, + "coefficients": coefficient_map, + "rank": int(rank), + "singular_values": [float(value) for value in singular_values], + "relative_reconstruction_residual_inf": residual, + "best_quadratic_relative_residual_inf": quadratic_residual, + "quartic_interpretation": { + "pair_density_coefficient_after_expanding_projector": + coefficient_map["Q2"] + J / 3.0, + "correlated_pair_transition_prefactor": J / 3.0, + "pair_basis": ["|12>", "|13>", "|23>"], + "J_projector_matrix_in_pair_basis": + correlated_pair_matrix.tolist(), + "genuine_three_density_coefficient": + coefficient_map["n1_n2_n3"], + }, + } + + +def irrep_energies(coefficients: Mapping[str, float]) -> Mapping[str, Any]: + C = coefficients["identity"] + e = coefficients["N"] + t = coefficients["K"] + V = coefficients["Q2"] + J = coefficients["Ps_dagger_Ps"] + W = coefficients["n1_n2_n3"] + return { + "vacuum": {"energy": C, "multiplicity": 1}, + "one_particle_symmetric": { + "energy": C + e + 2.0 * t, + "multiplicity": 1, + }, + "one_particle_standard": { + "energy": C + e - t, + "multiplicity": 2, + }, + "two_particle_sign": { + "energy": C + 2.0 * e - 2.0 * t + V + J, + "multiplicity": 1, + }, + "two_particle_standard": { + "energy": C + 2.0 * e + t + V, + "multiplicity": 2, + }, + "fully_occupied": { + "energy": C + 3.0 * e + 3.0 * V + J + W, + "multiplicity": 1, + }, + } + + +def irrep_spectrum_values(irrep: Mapping[str, Any], number: int) -> List[float]: + names = { + 0: ("vacuum",), + 1: ("one_particle_symmetric", "one_particle_standard"), + 2: ("two_particle_sign", "two_particle_standard"), + 3: ("fully_occupied",), + }[number] + result: List[float] = [] + for name in names: + result.extend( + [float(irrep[name]["energy"])] * int(irrep[name]["multiplicity"]) + ) + return sorted(result) + + +def build_twirl( + generator: np.ndarray, + algebra: FockAlgebra, +) -> Tuple[np.ndarray, Mapping[str, Any]]: + resolved: List[np.ndarray] = [] + fock_lift_residuals: List[float] = [] + for permutation in itertools.permutations(range(N_MODES)): + P = permutation_matrix(permutation) + oriented = P @ generator @ P.T + direct = expm(VERTEX_STRENGTH * quadratic_lift(oriented, algebra)) + exterior = fock_lift(expm(VERTEX_STRENGTH * oriented)) + fock_lift_residuals.append(relative_inf_residual(direct, exterior)) + resolved.append(direct) + twirl = sum(resolved, np.zeros_like(resolved[0])) / len(resolved) + return twirl, { + "resolved_orientation_count": len(resolved), + "max_exponential_vs_exterior_residual_inf": + max(fock_lift_residuals), + } + + +def permutation_invariance_residual( + operator: np.ndarray, +) -> float: + residual = 0.0 + for permutation in itertools.permutations(range(N_MODES)): + gamma_p = fock_lift(permutation_matrix(permutation)) + residual = max( + residual, + relative_inf_residual(gamma_p @ operator @ gamma_p.T, operator), + ) + return residual + + +def operator_diagnostics( + operator: np.ndarray, + algebra: FockAlgebra, +) -> Mapping[str, float]: + eigenvalues = np.linalg.eigvalsh((operator + operator.T) / 2.0) + return { + "hermiticity_relative_inf": + relative_inf_residual(operator, operator.T), + "number_commutator_relative_inf": + matrix_inf_norm(operator @ algebra.total_number + - algebra.total_number @ operator) + / max(1.0, matrix_inf_norm(operator)), + "permutation_invariance_relative_inf": + permutation_invariance_residual(operator), + "minimum_eigenvalue": float(eigenvalues.min()), + "maximum_eigenvalue": float(eigenvalues.max()), + } + + +def analyze_operator( + name: str, + hamiltonian: np.ndarray, + twirl: Optional[np.ndarray], + basis: Mapping[str, np.ndarray], + algebra: FockAlgebra, + construction: Mapping[str, Any], +) -> Mapping[str, Any]: + decomposition = canonical_decomposition(hamiltonian, basis) + irreps = irrep_energies(decomposition["coefficients"]) + return { + "name": name, + "construction": dict(construction), + "diagnostics": operator_diagnostics(hamiltonian, algebra), + "particle_number_sectors": sector_report(hamiltonian, twirl), + "canonical_decomposition": decomposition, + "irrep_energies": irreps, + "hamiltonian_matrix_fock_basis": hamiltonian.tolist(), + "twirl_matrix_fock_basis": None if twirl is None else twirl.tolist(), + } + + +def car_residual(algebra: FockAlgebra) -> float: + identity = np.eye(FOCK_DIMENSION) + residual = 0.0 + for i in range(N_MODES): + for j in range(N_MODES): + anti = ( + algebra.annihilation[i] @ algebra.creation[j] + + algebra.creation[j] @ algebra.annihilation[i] + ) + expected = identity if i == j else np.zeros_like(identity) + residual = max(residual, matrix_inf_norm(anti - expected)) + return residual + + +def self_check( + report: Mapping[str, Any], + operators: Mapping[str, np.ndarray], + basis: Mapping[str, np.ndarray], + algebra: FockAlgebra, +) -> Mapping[str, Any]: + checks: Dict[str, float] = {} + checks["car_absolute_inf"] = car_residual(algebra) + checks["total_additivity_relative_inf"] = relative_inf_residual( + operators["A"] + operators["B"], operators["A_plus_B"] + ) + for name, operator in operators.items(): + diagnostics = report["operators"][name]["diagnostics"] + decomposition = report["operators"][name]["canonical_decomposition"] + checks[f"{name}_hermiticity"] = float( + diagnostics["hermiticity_relative_inf"] + ) + checks[f"{name}_number_commutator"] = float( + diagnostics["number_commutator_relative_inf"] + ) + checks[f"{name}_S3_invariance"] = float( + diagnostics["permutation_invariance_relative_inf"] + ) + checks[f"{name}_basis_reconstruction"] = float( + decomposition["relative_reconstruction_residual_inf"] + ) + checks[f"{name}_negative_eigenvalue_violation"] = max( + 0.0, -float(diagnostics["minimum_eigenvalue"]) + ) + irreps = report["operators"][name]["irrep_energies"] + for number in range(N_MODES + 1): + actual = sorted( + float(value) for value in np.linalg.eigvalsh( + sector_block(operator, number) + ) + ) + predicted = irrep_spectrum_values(irreps, number) + checks[f"{name}_sector_{number}_irrep_match"] = max( + (abs(a - b) for a, b in zip(actual, predicted)), + default=0.0, + ) + for family in ("A", "B"): + checks[f"{family}_fock_lift"] = float( + report["operators"][family]["construction"][ + "max_exponential_vs_exterior_residual_inf" + ] + ) + vacuum_energy = report["operators"][family][ + "particle_number_sectors" + ]["0"]["hamiltonian_energies"][0]["value"] + checks[f"{family}_vacuum_energy"] = abs(float(vacuum_energy)) + maximum = max(checks.values()) + if maximum > TOLERANCE: + failing = {name: value for name, value in checks.items() + if value > TOLERANCE} + raise AssertionError(f"self-check failure: {failing}") + return { + "status": "pass", + "tolerance": TOLERANCE, + "maximum_residual_or_violation": maximum, + "checks": checks, + } + + +def assert_finite_json(value: Any, path: str = "root") -> None: + if isinstance(value, float): + if not math.isfinite(value): + raise ValueError(f"non-finite JSON value at {path}") + elif isinstance(value, Mapping): + for key, child in value.items(): + assert_finite_json(child, f"{path}.{key}") + elif isinstance(value, (list, tuple)): + for index, child in enumerate(value): + assert_finite_json(child, f"{path}[{index}]") + + +def build_report() -> Mapping[str, Any]: + algebra = build_fock_algebra() + epsilon = EPSILON + kappa = KAPPA + A = np.array([ + [-1.0 - epsilon - kappa, 1.0, -epsilon], + [0.0, -1.0 - kappa, 1.0], + [2.0, 0.0, -2.0 - kappa], + ]) + S = np.diag([1.0, 1.0, -1.0]) + B = S @ A @ S + twirl_A, construction_A = build_twirl(A, algebra) + twirl_B, construction_B = build_twirl(B, algebra) + identity = np.eye(FOCK_DIMENSION) + h_A = COUPLING_G * (identity - twirl_A) + h_B = COUPLING_G * (identity - twirl_B) + h_total = h_A + h_B + basis = canonical_operators(algebra) + operators = {"A": h_A, "B": h_B, "A_plus_B": h_total} + basis_order = [ + {"mask": mask, "ket": "|" + "".join( + str(int(bool(mask & (1 << site)))) for site in range(N_MODES) + ) + ">", "particle_number": particle_number(mask)} + for mask in range(FOCK_DIMENSION) + ] + report: Dict[str, Any] = { + "schema_version": 1, + "algorithm_id": ALGORITHM_ID, + "status": "analytic_numeric_local_result", + "scope": "one isolated three-site vertex; no lattice phase claim", + "provenance": { + "source_commit": SOURCE_COMMIT, + "source_commit_role": "repository base commit; analysis files are uncommitted working-tree additions", + "source_file": "tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics.py", + "source_file_sha256": hashlib.sha256( + Path(__file__).resolve().read_bytes() + ).hexdigest(), + }, + "frozen_parameters": { + "epsilon": EPSILON, + "kappa": KAPPA, + "s": VERTEX_STRENGTH, + "g_A": COUPLING_G, + "g_B": COUPLING_G, + }, + "generator_matrices": {"A": A.tolist(), "B": B.tolist()}, + "basis_convention": { + "ordering": "integer masks 0,...,7", + "ket_label": "|n1 n2 n3> written without spaces", + "site_bit_order": "site 1 is the least-significant mask bit", + "matrix_indices": "row=destination Fock state, column=source Fock state", + "fermion_sign": "annihilation at site i contributes (-1)^(occupied sites below i)", + }, + "fock_basis": basis_order, + "canonical_basis_definition": { + "N": "sum_i n_i", + "K": "sum_{i!=j} c_i^dagger c_j", + "Q2": "sum_{i TOLERANCE: + raise AssertionError( + "three-density determinant identity failed: " + f"{W_identity_residual}" + ) + report["self_checks"] = checks + interaction_scale = max( + abs(float(coefficients[name])) + for name in ("Q2", "Ps_dagger_Ps", "n1_n2_n3") + ) + report["physical_conclusion"] = { + "is_exactly_quadratic": bool( + total_decomposition["best_quadratic_relative_residual_inf"] + <= TOLERANCE + ), + "has_density_density_interaction": + abs(float(coefficients["Q2"])) > TOLERANCE, + "has_correlated_pair_hopping": + abs(float(coefficients["Ps_dagger_Ps"])) > TOLERANCE, + "has_genuine_three_density_term": + abs(float(coefficients["n1_n2_n3"])) > TOLERANCE, + "largest_interaction_coefficient_abs": interaction_scale, + "three_density_determinant_certificate": { + "identity": "W=(g_A+g_B) det[I-exp(sA)]", + "predicted": expected_W, + "decomposed": observed_W, + "absolute_residual": W_identity_residual, + }, + "interpretation": + "The complete A+B twirl is an S3-symmetric, number-conserving, " + "positive-semidefinite interacting cluster term. Its nonzero " + "Ps_dagger_Ps coefficient is a quartic correlated transition " + "between two-particle configurations, and its residual n1 n2 n3 " + "coefficient is a genuine three-density interaction after all " + "constant, quadratic, and two-body canonical pieces are removed. " + "The vacuum is the local zero-energy state; this local spectrum " + "alone does not identify a macroscopic finite-density phase.", + } + assert_finite_json(report) + return report + + +def atomic_write_json(path: Path, payload: Mapping[str, Any]) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + descriptor, temporary = tempfile.mkstemp( + prefix="." + path.name + ".", suffix=".tmp", dir=path.parent + ) + try: + with os.fdopen(descriptor, "w", encoding="utf-8") as handle: + json.dump( + payload, + handle, + indent=2, + sort_keys=True, + allow_nan=False, + ) + handle.write("\n") + handle.flush() + os.fsync(handle.fileno()) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + +def main(argv: Optional[Sequence[str]] = None) -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--output", type=Path) + parser.add_argument("--compact", action="store_true") + args = parser.parse_args(argv) + report = build_report() + if args.output is not None: + atomic_write_json(args.output, report) + print(json.dumps({ + "status": report["status"], + "self_checks": report["self_checks"]["status"], + "output": str(args.output), + }, allow_nan=False)) + else: + print(json.dumps( + report, + indent=None if args.compact else 2, + sort_keys=True, + allow_nan=False, + )) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics_frozen.json b/tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics_frozen.json new file mode 100644 index 000000000..5febff232 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics_frozen.json @@ -0,0 +1,1080 @@ +{ + "algorithm_id": "local-three-site-s3-twirl-physics-v1", + "basis_convention": { + "fermion_sign": "annihilation at site i contributes (-1)^(occupied sites below i)", + "ket_label": "|n1 n2 n3> written without spaces", + "matrix_indices": "row=destination Fock state, column=source Fock state", + "ordering": "integer masks 0,...,7", + "site_bit_order": "site 1 is the least-significant mask bit" + }, + "canonical_basis_definition": { + "K": "sum_{i!=j} c_i^dagger c_j", + "N": "sum_i n_i", + "Ps_dagger": "(c1^dagger c2^dagger-c1^dagger c3^dagger+c2^dagger c3^dagger)/sqrt(3)", + "Q2": "sum_{i", + "mask": 0, + "particle_number": 0 + }, + { + "ket": "|100>", + "mask": 1, + "particle_number": 1 + }, + { + "ket": "|010>", + "mask": 2, + "particle_number": 1 + }, + { + "ket": "|110>", + "mask": 3, + "particle_number": 2 + }, + { + "ket": "|001>", + "mask": 4, + "particle_number": 1 + }, + { + "ket": "|101>", + "mask": 5, + "particle_number": 2 + }, + { + "ket": "|011>", + "mask": 6, + "particle_number": 2 + }, + { + "ket": "|111>", + "mask": 7, + "particle_number": 3 + } + ], + "frozen_parameters": { + "epsilon": 0.01, + "g_A": 0.25, + "g_B": 0.25, + "kappa": 0.02, + "s": 0.25 + }, + "generator_matrices": { + "A": [ + [ + -1.03, + 1.0, + -0.01 + ], + [ + 0.0, + -1.02, + 1.0 + ], + [ + 2.0, + 0.0, + -2.02 + ] + ], + "B": [ + [ + -1.03, + 1.0, + 0.01 + ], + [ + 0.0, + -1.02, + -1.0 + ], + [ + -2.0, + 0.0, + -2.02 + ] + ] + }, + "operators": { + "A": { + "canonical_decomposition": { + "basis_order": [ + "identity", + "N", + "K", + "Q2", + "Ps_dagger_Ps", + "n1_n2_n3" + ], + "best_quadratic_relative_residual_inf": 0.020223288352321588, + "coefficients": { + "K": -0.03407846250442239, + "N": 0.06985839779916983, + "Ps_dagger_Ps": -0.04809738250726868, + "Q2": -0.000730849230504857, + "identity": 3.4053470543074115e-16, + "n1_n2_n3": 0.0003403479706896714 + }, + "quartic_interpretation": { + "J_projector_matrix_in_pair_basis": [ + [ + -0.016032460835756226, + 0.016032460835756226, + -0.016032460835756226 + ], + [ + 0.016032460835756226, + -0.016032460835756226, + 0.016032460835756226 + ], + [ + -0.016032460835756226, + 0.016032460835756226, + -0.016032460835756226 + ] + ], + "correlated_pair_transition_prefactor": -0.016032460835756226, + "genuine_three_density_coefficient": 0.0003403479706896714, + "pair_basis": [ + "|12>", + "|13>", + "|23>" + ], + "pair_density_coefficient_after_expanding_projector": -0.016763310066261083 + }, + "rank": 6, + "relative_reconstruction_residual_inf": 3.4053470543074115e-16, + "singular_values": [ + 6.430298168345929, + 3.5124540075599207, + 2.0766852177567654, + 0.7835280296784438, + 0.5458288635255479, + 0.2991078329707575 + ] + }, + "construction": { + "max_exponential_vs_exterior_residual_inf": 2.3592239273284576e-16, + "resolved_orientation_count": 6 + }, + "diagnostics": { + "hermiticity_relative_inf": 6.938893903907228e-18, + "maximum_eigenvalue": 0.1596256111694161, + "minimum_eigenvalue": 0.0, + "number_commutator_relative_inf": 0.0, + "permutation_invariance_relative_inf": 5.551115123125783e-17 + }, + "hamiltonian_matrix_fock_basis": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.06985839779917014, + -0.03407846250442242, + 0.0, + -0.034078462504422424, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + -0.03407846250442242, + 0.06985839779917016, + 0.0, + -0.03407846250442242, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.122953485532079, + 0.0, + -0.01804600166866616, + 0.01804600166866616, + 0.0 + ], + [ + 0.0, + -0.034078462504422424, + -0.034078462504422424, + 0.0, + 0.06985839779917016, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + -0.01804600166866616, + 0.0, + 0.12295348553207905, + -0.01804600166866616, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.01804600166866616, + 0.0, + -0.01804600166866616, + 0.12295348553207905, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.1596256111694161 + ] + ], + "irrep_energies": { + "fully_occupied": { + "energy": 0.1596256111694162, + "multiplicity": 1 + }, + "one_particle_standard": { + "energy": 0.10393686030359256, + "multiplicity": 2 + }, + "one_particle_symmetric": { + "energy": 0.0017014727903253979, + "multiplicity": 1 + }, + "two_particle_sign": { + "energy": 0.15904548886941122, + "multiplicity": 1 + }, + "two_particle_standard": { + "energy": 0.10490748386341274, + "multiplicity": 2 + }, + "vacuum": { + "energy": 3.4053470543074115e-16, + "multiplicity": 1 + } + }, + "name": "g(I-M_A)", + "particle_number_sectors": { + "0": { + "dimension": 1, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.0 + } + ], + "label": "vacuum", + "twirl_eigenvalues": [ + { + "multiplicity": 1, + "value": 1.0 + } + ] + }, + "1": { + "dimension": 3, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.0017014727903253077 + }, + { + "multiplicity": 2, + "value": 0.10393686030359257 + } + ], + "label": "one_particle", + "twirl_eigenvalues": [ + { + "multiplicity": 2, + "value": 0.5842525587856295 + }, + { + "multiplicity": 1, + "value": 0.9931941088386984 + } + ] + }, + "2": { + "dimension": 3, + "hamiltonian_energies": [ + { + "multiplicity": 2, + "value": 0.10490748386341286 + }, + { + "multiplicity": 1, + "value": 0.15904548886941136 + } + ], + "label": "two_particle", + "twirl_eigenvalues": [ + { + "multiplicity": 1, + "value": 0.3638180445223546 + }, + { + "multiplicity": 2, + "value": 0.5803700645463485 + } + ] + }, + "3": { + "dimension": 1, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.1596256111694161 + } + ], + "label": "fully_occupied", + "twirl_eigenvalues": [ + { + "multiplicity": 1, + "value": 0.3614975553223356 + } + ] + } + }, + "twirl_matrix_fock_basis": [ + [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.7205664088033195, + 0.13631385001768967, + 0.0, + 0.1363138500176897, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.13631385001768967, + 0.7205664088033193, + 0.0, + 0.13631385001768967, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.508186057871684, + 0.0, + 0.07218400667466464, + -0.07218400667466464, + 0.0 + ], + [ + 0.0, + 0.1363138500176897, + 0.1363138500176897, + 0.0, + 0.7205664088033193, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.07218400667466464, + 0.0, + 0.5081860578716838, + 0.07218400667466464, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + -0.07218400667466464, + 0.0, + 0.07218400667466464, + 0.5081860578716838, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.3614975553223356 + ] + ] + }, + "A_plus_B": { + "canonical_decomposition": { + "basis_order": [ + "identity", + "N", + "K", + "Q2", + "Ps_dagger_Ps", + "n1_n2_n3" + ], + "best_quadratic_relative_residual_inf": 0.02497479111404717, + "coefficients": { + "K": -0.01985885766309159, + "N": 0.13971679559834005, + "Ps_dagger_Ps": -0.038368292854847184, + "Q2": -0.020737189180906668, + "identity": 2.655016347426117e-16, + "n1_n2_n3": 0.0006806959413790479 + }, + "quartic_interpretation": { + "J_projector_matrix_in_pair_basis": [ + [ + -0.012789430951615728, + 0.012789430951615728, + -0.012789430951615728 + ], + [ + 0.012789430951615728, + -0.012789430951615728, + 0.012789430951615728 + ], + [ + -0.012789430951615728, + 0.012789430951615728, + -0.012789430951615728 + ] + ], + "correlated_pair_transition_prefactor": -0.012789430951615728, + "genuine_three_density_coefficient": 0.0006806959413790479, + "pair_basis": [ + "|12>", + "|13>", + "|23>" + ], + "pair_density_coefficient_after_expanding_projector": -0.033526620132522396 + }, + "rank": 6, + "relative_reconstruction_residual_inf": 2.655016347426117e-16, + "singular_values": [ + 6.430298168345929, + 3.5124540075599207, + 2.0766852177567654, + 0.7835280296784438, + 0.5458288635255479, + 0.2991078329707575 + ] + }, + "construction": { + "resolved_orientation_count": 12 + }, + "diagnostics": { + "hermiticity_relative_inf": 6.938893903907228e-18, + "maximum_eigenvalue": 0.3192512223388322, + "minimum_eigenvalue": 0.0, + "number_commutator_relative_inf": 0.0, + "permutation_invariance_relative_inf": 1.1796119636642288e-16 + }, + "hamiltonian_matrix_fock_basis": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.13971679559834027, + -0.019858857663091603, + 0.0, + -0.01985885766309161, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + -0.019858857663091603, + 0.13971679559834033, + 0.0, + -0.019858857663091603, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.245906971064158, + 0.0, + -0.007069426711475863, + 0.007069426711475859, + 0.0 + ], + [ + 0.0, + -0.01985885766309161, + -0.019858857663091603, + 0.0, + 0.13971679559834033, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + -0.007069426711475858, + 0.0, + 0.2459069710641581, + -0.007069426711475858, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.007069426711475858, + 0.0, + -0.007069426711475858, + 0.2459069710641581, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.3192512223388322 + ] + ], + "irrep_energies": { + "fully_occupied": { + "energy": 0.3192512223388323, + "multiplicity": 1 + }, + "one_particle_standard": { + "energy": 0.15957565326143192, + "multiplicity": 2 + }, + "one_particle_symmetric": { + "energy": 0.09999908027215715, + "multiplicity": 1 + }, + "two_particle_sign": { + "energy": 0.2600458244871097, + "multiplicity": 1 + }, + "two_particle_standard": { + "energy": 0.23883754435268212, + "multiplicity": 2 + }, + "vacuum": { + "energy": 2.655016347426117e-16, + "multiplicity": 1 + } + }, + "name": "g(I-M_A)+g(I-M_B)", + "particle_number_sectors": { + "0": { + "dimension": 1, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.0 + } + ], + "label": "vacuum" + }, + "1": { + "dimension": 3, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.09999908027215709 + }, + { + "multiplicity": 2, + "value": 0.15957565326143192 + } + ], + "label": "one_particle" + }, + "2": { + "dimension": 3, + "hamiltonian_energies": [ + { + "multiplicity": 2, + "value": 0.2388375443526822 + }, + { + "multiplicity": 1, + "value": 0.26004582448710983 + } + ], + "label": "two_particle" + }, + "3": { + "dimension": 1, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.3192512223388322 + } + ], + "label": "fully_occupied" + } + }, + "twirl_matrix_fock_basis": null + }, + "B": { + "canonical_decomposition": { + "basis_order": [ + "identity", + "N", + "K", + "Q2", + "Ps_dagger_Ps", + "n1_n2_n3" + ], + "best_quadratic_relative_residual_inf": 0.012487395557023585, + "coefficients": { + "K": 0.014219604841330828, + "N": 0.06985839779917022, + "Ps_dagger_Ps": 0.00972908965242149, + "Q2": -0.020006339950401825, + "identity": -5.483185934901764e-17, + "n1_n2_n3": 0.0003403479706893739 + }, + "quartic_interpretation": { + "J_projector_matrix_in_pair_basis": [ + [ + 0.0032430298841404966, + -0.0032430298841404966, + 0.0032430298841404966 + ], + [ + -0.0032430298841404966, + 0.0032430298841404966, + -0.0032430298841404966 + ], + [ + 0.0032430298841404966, + -0.0032430298841404966, + 0.0032430298841404966 + ] + ], + "correlated_pair_transition_prefactor": 0.0032430298841404966, + "genuine_three_density_coefficient": 0.0003403479706893739, + "pair_basis": [ + "|12>", + "|13>", + "|23>" + ], + "pair_density_coefficient_after_expanding_projector": -0.016763310066261326 + }, + "rank": 6, + "relative_reconstruction_residual_inf": 1.1796119636642288e-16, + "singular_values": [ + 6.430298168345929, + 3.5124540075599207, + 2.0766852177567654, + 0.7835280296784438, + 0.5458288635255479, + 0.2991078329707575 + ] + }, + "construction": { + "max_exponential_vs_exterior_residual_inf": 2.3592239273284576e-16, + "resolved_orientation_count": 6 + }, + "diagnostics": { + "hermiticity_relative_inf": 8.673617379884035e-18, + "maximum_eigenvalue": 0.1596256111694161, + "minimum_eigenvalue": 0.0, + "number_commutator_relative_inf": 0.0, + "permutation_invariance_relative_inf": 6.245004513516506e-17 + }, + "hamiltonian_matrix_fock_basis": [ + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.06985839779917014, + 0.014219604841330814, + 0.0, + 0.014219604841330814, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.014219604841330813, + 0.06985839779917016, + 0.0, + 0.014219604841330813, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.122953485532079, + 0.0, + 0.010976574957190297, + -0.0109765749571903, + 0.0 + ], + [ + 0.0, + 0.014219604841330814, + 0.01421960484133082, + 0.0, + 0.06985839779917016, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.010976574957190302, + 0.0, + 0.12295348553207905, + 0.010976574957190302, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + -0.010976574957190302, + 0.0, + 0.010976574957190302, + 0.12295348553207905, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.1596256111694161 + ] + ], + "irrep_energies": { + "fully_occupied": { + "energy": 0.159625611169416, + "multiplicity": 1 + }, + "one_particle_standard": { + "energy": 0.055638792957839335, + "multiplicity": 2 + }, + "one_particle_symmetric": { + "energy": 0.09829760748183182, + "multiplicity": 1 + }, + "two_particle_sign": { + "energy": 0.10100033561769839, + "multiplicity": 1 + }, + "two_particle_standard": { + "energy": 0.1339300604892694, + "multiplicity": 2 + }, + "vacuum": { + "energy": -5.483185934901764e-17, + "multiplicity": 1 + } + }, + "name": "g(I-M_B)", + "particle_number_sectors": { + "0": { + "dimension": 1, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.0 + } + ], + "label": "vacuum", + "twirl_eigenvalues": [ + { + "multiplicity": 1, + "value": 1.0 + } + ] + }, + "1": { + "dimension": 3, + "hamiltonian_energies": [ + { + "multiplicity": 2, + "value": 0.055638792957839356 + }, + { + "multiplicity": 1, + "value": 0.09829760748183178 + } + ], + "label": "one_particle", + "twirl_eigenvalues": [ + { + "multiplicity": 1, + "value": 0.6068095700726726 + }, + { + "multiplicity": 2, + "value": 0.7774448281686426 + } + ] + }, + "2": { + "dimension": 3, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.10100033561769844 + }, + { + "multiplicity": 2, + "value": 0.1339300604892693 + } + ], + "label": "two_particle", + "twirl_eigenvalues": [ + { + "multiplicity": 2, + "value": 0.4642797580429227 + }, + { + "multiplicity": 1, + "value": 0.5959986575292062 + } + ] + }, + "3": { + "dimension": 1, + "hamiltonian_energies": [ + { + "multiplicity": 1, + "value": 0.1596256111694161 + } + ], + "label": "fully_occupied", + "twirl_eigenvalues": [ + { + "multiplicity": 1, + "value": 0.3614975553223356 + } + ] + } + }, + "twirl_matrix_fock_basis": [ + [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.7205664088033195, + -0.05687841936532326, + 0.0, + -0.05687841936532326, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + -0.05687841936532325, + 0.7205664088033193, + 0.0, + -0.05687841936532325, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.508186057871684, + 0.0, + -0.04390629982876119, + 0.0439062998287612, + 0.0 + ], + [ + 0.0, + -0.05687841936532326, + -0.05687841936532328, + 0.0, + 0.7205664088033193, + 0.0, + 0.0, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + -0.04390629982876121, + 0.0, + 0.5081860578716838, + -0.04390629982876121, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.04390629982876121, + 0.0, + -0.04390629982876121, + 0.5081860578716838, + 0.0 + ], + [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.3614975553223356 + ] + ] + } + }, + "physical_conclusion": { + "has_correlated_pair_hopping": true, + "has_density_density_interaction": true, + "has_genuine_three_density_term": true, + "interpretation": "The complete A+B twirl is an S3-symmetric, number-conserving, positive-semidefinite interacting cluster term. Its nonzero Ps_dagger_Ps coefficient is a quartic correlated transition between two-particle configurations, and its residual n1 n2 n3 coefficient is a genuine three-density interaction after all constant, quadratic, and two-body canonical pieces are removed. The vacuum is the local zero-energy state; this local spectrum alone does not identify a macroscopic finite-density phase.", + "is_exactly_quadratic": false, + "largest_interaction_coefficient_abs": 0.038368292854847184, + "three_density_determinant_certificate": { + "absolute_residual": 1.7889335846010823e-17, + "decomposed": 0.0006806959413790479, + "identity": "W=(g_A+g_B) det[I-exp(sA)]", + "predicted": 0.0006806959413790658 + } + }, + "provenance": { + "source_commit": "886a082963429f3f62deb9e6090352a58a05b89a", + "source_commit_role": "repository base commit; analysis files are uncommitted working-tree additions", + "source_file": "tracks/qmc/solutions/Genshin_Impact-121/local_vertex_physics.py", + "source_file_sha256": "2ff89915d8da50a1840b6262cf1d49ccaa13ff754f8fe9b49bcd710ad5a196e3" + }, + "schema_version": 1, + "scope": "one isolated three-site vertex; no lattice phase claim", + "self_checks": { + "checks": { + "A_S3_invariance": 5.551115123125783e-17, + "A_basis_reconstruction": 3.4053470543074115e-16, + "A_fock_lift": 2.3592239273284576e-16, + "A_hermiticity": 6.938893903907228e-18, + "A_negative_eigenvalue_violation": 0.0, + "A_number_commutator": 0.0, + "A_plus_B_S3_invariance": 1.1796119636642288e-16, + "A_plus_B_basis_reconstruction": 2.655016347426117e-16, + "A_plus_B_hermiticity": 6.938893903907228e-18, + "A_plus_B_negative_eigenvalue_violation": 0.0, + "A_plus_B_number_commutator": 0.0, + "A_plus_B_sector_0_irrep_match": 2.655016347426117e-16, + "A_plus_B_sector_1_irrep_match": 5.551115123125783e-17, + "A_plus_B_sector_2_irrep_match": 1.1102230246251565e-16, + "A_plus_B_sector_3_irrep_match": 1.1102230246251565e-16, + "A_sector_0_irrep_match": 3.4053470543074115e-16, + "A_sector_1_irrep_match": 9.020562075079397e-17, + "A_sector_2_irrep_match": 1.3877787807814457e-16, + "A_sector_3_irrep_match": 1.1102230246251565e-16, + "A_vacuum_energy": 0.0, + "B_S3_invariance": 6.245004513516506e-17, + "B_basis_reconstruction": 1.1796119636642288e-16, + "B_fock_lift": 2.3592239273284576e-16, + "B_hermiticity": 8.673617379884035e-18, + "B_negative_eigenvalue_violation": 0.0, + "B_number_commutator": 0.0, + "B_sector_0_irrep_match": 5.483185934901764e-17, + "B_sector_1_irrep_match": 4.163336342344337e-17, + "B_sector_2_irrep_match": 8.326672684688674e-17, + "B_sector_3_irrep_match": 8.326672684688674e-17, + "B_vacuum_energy": 0.0, + "car_absolute_inf": 0.0, + "three_density_determinant_identity": 1.7889335846010823e-17, + "total_additivity_relative_inf": 0.0 + }, + "maximum_residual_or_violation": 3.4053470543074115e-16, + "status": "pass", + "tolerance": 2e-11 + }, + "status": "analytic_numeric_local_result" +} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py index 773e72ef7..2c78d17df 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py @@ -925,7 +925,7 @@ def test_checkpoint_roundtrip_preserves_word_rng_and_primary_traces( seed=121_2030, ) sampler.moves_since_rebuild = 5 - sampler.completed_steps = 11 + sampler.completed_steps = 3 observation = ctqmc.measure_configuration( sampler.factors, sampler.geometry, @@ -957,7 +957,7 @@ def test_checkpoint_roundtrip_preserves_word_rng_and_primary_traces( restored.load_checkpoint() actual_random = restored.rng.random(8) - assert restored.completed_steps == 11 + assert restored.completed_steps == 3 assert restored.moves_since_rebuild == 5 assert list(restored.word) == list(sampler.word) assert restored.accumulator.state() == sampler.accumulator.state() @@ -1088,3 +1088,91 @@ def test_manifest_helpers_do_not_mutate_input(tmp_path: Path) -> None: original = deepcopy(manifest) ctqmc.CTQMC.from_manifest(manifest, tmp_path) assert manifest == original + +def test_complete_validation_is_hash_bound_and_idempotent(tmp_path: Path) -> None: + manifest = _manifest(steps=8, warmup=1) + manifest_path = tmp_path / "manifest.json" + ctqmc.atomic_write_json(manifest_path, manifest) + digest = hashlib.sha256(manifest_path.read_bytes()).hexdigest() + output = tmp_path / "run" + sampler = ctqmc.CTQMC.from_manifest( + manifest, output, manifest_sha256=digest + ) + result = sampler.run() + assert ctqmc.validate_existing_complete(output, digest, 8) == result + assert ctqmc.main([ + "--manifest", str(manifest_path), "--output", str(output) + ]) == 0 + complete = json.loads((output / "CHAIN_COMPLETE").read_text()) + complete["result_json_sha256"] = "0" * 64 + ctqmc.atomic_write_json(output / "CHAIN_COMPLETE", complete) + with pytest.raises(ctqmc.ManifestError, match="hash"): + ctqmc.validate_existing_complete(output, digest, 8) + + +def test_only_recoverable_failed_marker_is_archived(tmp_path: Path) -> None: + failed = tmp_path / "FAILED" + ctqmc.atomic_write_json( + failed, + {"determinant_failure_kind": None, "error_type": "OSError"}, + ) + archive = ctqmc.archive_recoverable_failure(failed) + assert not failed.exists() + assert archive.is_file() + scientific = tmp_path / "FAILED" + ctqmc.atomic_write_json( + scientific, + {"determinant_failure_kind": "negative"}, + ) + with pytest.raises(ctqmc.ManifestError, match="scientific"): + ctqmc.archive_recoverable_failure(scientific) + assert scientific.is_file() + + +def test_resume_without_checkpoint_preserves_active_failed(tmp_path: Path) -> None: + manifest_path = tmp_path / "manifest.json" + ctqmc.atomic_write_json(manifest_path, _manifest()) + output = tmp_path / "run" + output.mkdir() + failed = output / "FAILED" + ctqmc.atomic_write_json( + failed, + {"determinant_failure_kind": None, "error_type": "OSError"}, + ) + original = failed.read_bytes() + + with pytest.raises(ctqmc.ManifestError, match="needs checkpoint"): + ctqmc.main([ + "--manifest", str(manifest_path), + "--output", str(output), + "--resume", + ]) + + assert failed.read_bytes() == original + assert not (output / "failures").exists() + + +def test_load_checkpoint_rejects_accumulator_count_mismatch( + tmp_path: Path, +) -> None: + sampler = _sampler(tmp_path) + sampler.completed_steps = 3 + observation = ctqmc.measure_configuration( + sampler.factors, + sampler.geometry, + sampler.beta, + sampler.G0, + len(sampler.word), + sampler.momenta, + sampler.displacements, + ) + sampler.accumulator.add(observation) + sampler.save_checkpoint("running") + path = tmp_path / "checkpoint.json" + payload = json.loads(path.read_text(encoding="utf-8")) + payload["accumulator"]["count"] = 0 + ctqmc.atomic_write_json(path, payload) + + restored = _sampler(tmp_path) + with pytest.raises(ctqmc.ManifestError, match="accumulator count"): + restored.load_checkpoint() diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py new file mode 100644 index 000000000..75bb13a91 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py @@ -0,0 +1,151 @@ +from __future__ import annotations + +import os + +_THREAD_ENV = ( + "OPENBLAS_NUM_THREADS", + "OMP_NUM_THREADS", + "MKL_NUM_THREADS", + "NUMEXPR_NUM_THREADS", + "VECLIB_MAXIMUM_THREADS", + "BLIS_NUM_THREADS", +) +for _name in _THREAD_ENV: + os.environ[_name] = "1" + +import json +import math +import unittest + +import large_lattice_kernel_benchmark as benchmark + + +class KernelBenchmarkTests(unittest.TestCase): + def test_default_grid_is_declared_but_not_executed_on_import(self) -> None: + self.assertEqual(benchmark.DEFAULT_SIZES, (4, 8, 12, 16)) + self.assertEqual(benchmark.DEFAULT_BETA, 4.0) + self.assertGreaterEqual(benchmark.DEFAULT_REPEATS, 1) + self.assertGreaterEqual(benchmark.DEFAULT_WARMUP, 0) + self.assertTrue(all(os.environ[name] == "1" for name in _THREAD_ENV)) + + def test_quick_insert_delete_correctness_and_strict_json(self) -> None: + report = benchmark.run_benchmark( + sizes=(2, 3), + beta=0.5, + seed=121_730_001, + repeats=2, + warmup=1, + ) + self.assertIs(report["overall_correctness_pass"], True) + self.assertEqual(report["parameters"]["sizes"], [2, 3]) + self.assertIs( + report["single_thread_blas"]["set_before_numpy_import"], + True, + ) + self.assertEqual( + set( + report["single_thread_blas"]["environment"].values() + ), + {"1"}, + ) + self.assertEqual( + len(report["provenance"]["benchmark_source_sha256"]), + 64, + ) + self.assertEqual( + len(report["provenance"]["ctqmc_source_sha256"]), + 64, + ) + source_commit = report["provenance"]["source_commit"] + self.assertTrue(source_commit is None or len(source_commit) == 40) + + for L, case in zip((2, 3), report["cases"]): + with self.subTest(L=L): + self.assertEqual(case["L"], L) + self.assertEqual(case["N"], L * L) + self.assertEqual( + case["order"], math.ceil(0.5 * L * L) + ) + self.assertEqual( + case["fallback_count"], + {"insert": 0, "delete": 0}, + ) + self.assertIs(case["correctness"]["pass"], True) + for move in ("insert", "delete"): + timing = case["latency"][move] + self.assertGreater( + timing["rank3"]["median_ns"], 0 + ) + self.assertGreater( + timing["full_word_rebuild"]["median_ns"], 0 + ) + self.assertEqual( + len(timing["rank3"]["samples_ns"]), 2 + ) + self.assertEqual( + len( + timing["full_word_rebuild"][ + "samples_ns" + ] + ), + 2, + ) + self.assertGreater( + timing["speedup_dense_over_rank3"], 0.0 + ) + errors = case["correctness"][ + f"{move}_max_error" + ] + self.assertLessEqual( + errors["T_relative_inf"], 1.0e-9 + ) + self.assertLessEqual( + errors["Q_relative_inf"], 1.0e-9 + ) + self.assertLessEqual( + errors["logdet_absolute"], 1.0e-9 + ) + self.assertLessEqual( + errors["log_ratio_absolute"], 1.0e-9 + ) + self.assertLessEqual( + errors["det_ratio_relative"], 1.0e-9 + ) + + encoded = json.dumps( + report, allow_nan=False, sort_keys=True + ) + decoded = json.loads(encoded) + self.assertIs(decoded["overall_correctness_pass"], True) + + def test_fixed_seed_reproduces_word_and_candidate_fixtures(self) -> None: + arguments = { + "L": 2, + "beta": 0.5, + "seed": 121_730_001, + "repeats": 1, + "warmup": 1, + } + first = benchmark.benchmark_size(**arguments) + second = benchmark.benchmark_size(**arguments) + self.assertEqual( + first["word_sha256"], second["word_sha256"] + ) + self.assertEqual( + first["candidate_sha256"], + second["candidate_sha256"], + ) + self.assertEqual(first["order"], 2) + self.assertEqual(second["order"], 2) + self.assertEqual( + first["word_sha256"], + "c82de2ee2effcf61f353e85d315b9a540b560ebec4b8783d0fd433553d0e2b13", + ) + self.assertEqual( + first["candidate_sha256"], + "1a2a7cf21550d83c7f18c6e8c5fb0cb58be3772078cfed18de71b3eb2fae277c", + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py index d9f2237d5..9ebe856cc 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -1,9 +1,13 @@ from __future__ import annotations from copy import deepcopy +import hashlib import json import math +import os from pathlib import Path +import sys +import subprocess import numpy as np import pytest @@ -35,6 +39,46 @@ def write_meta(path: Path, value: dict) -> None: protocol.write_json(path, value) +def passing_gate_payload(name: str) -> dict: + if name == "G0": + return {"status": "PASS", "tests_exit_code": 0} + if name in {"G1", "G2", "G3"}: + stage, count = { + "G1": ("g1", 8), + "G2": ("pilot", 3), + "G3": ("full", 20), + }[name] + payload = { + "status": "PASS", + "stage": stage, + "cells": { + f"cell-{item}": {"pass": True} + for item in range(count) + }, + "chain_cells_pass": True, + "all_cells_pass": True, + } + if name == "G2": + payload["kernel_benchmark"] = {"pass": True} + payload["resource_gate"] = {"pass": True} + return payload + if name == "G4": + return { + "status": "PASS", + "stage": "provenance", + "chains": [ + { + "slurm_job_id": f"job-{item}", + "array_task_id": str(item), + } + for item in range(112) + ], + "distinct_slurm_array_tasks": 112, + "checks": {"source_snapshot": True, "environment": True}, + } + raise AssertionError(name) + + def test_pending_and_physics_drift_are_rejected() -> None: pending = confirmed_meta() pending["document_type"] = "preregistered_large_lattice_run_draft" @@ -164,7 +208,7 @@ def manifest_for(size: int) -> dict: submit = ( root / "slurm" / "submit_after_live_cluster_check.sh" ).read_text(encoding="utf-8") - assert submit.count("afterok:") == 6 + assert submit.count("afterok:") == 8 assert "sinfo" in submit and "squeue" in submit @@ -239,6 +283,7 @@ def fake_result(offset: float) -> dict: }, }, "zero_weight_rejections": 0, + "determinant_failures": {"zero": 0, "negative": 0}, }, "rebuild_diagnostics": [ { @@ -291,10 +336,7 @@ def test_only_outer_all_pass_protocol_writes_complete( protocol.write_protocol_complete(root) for gate in ("G0", "G1", "G2", "G3", "G4"): - protocol._gate( - root, gate, - {"status": "PASS", "test_fixture": True}, - ) + protocol._gate(root, gate, passing_gate_payload(gate)) complete = protocol.write_protocol_complete(root) assert complete["status"] == "complete" assert (root / "COMPLETE").is_file() @@ -317,3 +359,594 @@ def test_only_outer_all_pass_protocol_writes_complete( assert protocol.main([ "audit", "--root", str(root), "--stage", "g1" ]) == 0 + +def test_materialization_freezes_environment_and_restart_wrapper( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize(meta_path, root, small_execution()) + environment = index["environment"] + assert Path(environment["python_executable"]).is_absolute() + assert Path(environment["python_executable"]).resolve() == Path( + sys.executable + ).resolve() + assert environment["python_version"] + assert environment["numpy_version"] + assert environment["scipy_version"] + assert index["source_snapshot"]["git_commit"] + + script = (root / "slurm" / "run_g1_array.sbatch").read_text( + encoding="utf-8" + ) + assert environment["python_executable"] in script + assert "CHAIN_COMPLETE" in script + assert "--resume" in script + assert '>>"$output/runner.stdout"' in script + + +def test_materialization_rejects_cardinality_path_and_tsv_tamper( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + for number, (mutation, match) in enumerate(( + (lambda index: index["entries"].pop(), "entries"), + ( + lambda index: index["entries"][0].__setitem__( + "manifest", "../escape.json" + ), + "entries", + ), + )): + root = tmp_path / f"materialized-{number}" + protocol.materialize(meta_path, root, small_execution()) + index = protocol.load_json(root / "index.json") + mutation(index) + protocol.write_json(root / "index.json", index) + (root / "index.sha256").write_text( + f"{protocol.sha_file(root / 'index.json')} index.json\n", + encoding="ascii", + ) + with pytest.raises(protocol.ProtocolError, match=match): + protocol.verify_materialization(root) + + root = tmp_path / "materialized-tsv" + protocol.materialize(meta_path, root, small_execution()) + (root / "g1_tasks.tsv").write_text("tampered\n", encoding="utf-8") + with pytest.raises(protocol.ProtocolError, match="g1_tasks.tsv"): + protocol.verify_materialization(root) + + +def test_positivity_uses_real_determinant_failure_counters() -> None: + thresholds = { + "r_hat_max": 2.0, + "bulk_ess_min": 1, + "tail_ess_min": 1, + "fast_vs_rebuild_relative_error_max": 1.0e-9, + "inverse_residual_max": 1.0e-8, + } + results = [fake_result(value) for value in (0.0, 0.2, 0.4, 0.6)] + results[2]["counters"]["determinant_failures"]["negative"] = 1 + summary = protocol.summarize_cell( + results, + beta=1.0, + n_sites=4, + thresholds=thresholds, + acceptance_range=(0.2, 0.7), + ) + assert summary["positivity"]["negative_sign_count"] == 1 + assert not summary["positivity"]["pass"] + assert not summary["pass"] + + +def _write_chain_fixture(root: Path, entry: dict) -> dict: + manifest = protocol.load_json(root / entry["manifest"]) + result = { + "schema_version": 1, + "status": "run_complete_unvalidated", + "scope": "single_chain_execution_only", + "algorithm_id": protocol.CORE_ALGORITHM_ID, + "manifest_sha256": entry["manifest_sha256"], + "completed_steps": manifest["monte_carlo"]["steps"], + "geometry": {"n_sites": entry["N"]}, + "model": manifest["model"], + "initialization": entry["initialization"], + "measurements": manifest["measurements"], + "observables": {"count": 1}, + "execution_environment": {}, + } + output = root / entry["output"] + output.mkdir(parents=True, exist_ok=True) + protocol.write_json(output / "result.json", result) + protocol.write_json( + output / "CHAIN_COMPLETE", + { + "schema_version": 1, + "status": "run_complete_unvalidated", + "scope": "single_chain_execution_only", + "algorithm_id": protocol.CORE_ALGORITHM_ID, + "manifest_sha256": entry["manifest_sha256"], + "result_json_sha256": protocol.sha_file(output / "result.json"), + "completed_steps": manifest["monte_carlo"]["steps"], + }, + ) + return result + + +def test_load_chain_accepts_bound_chain_complete_and_rejects_drift( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize(meta_path, root, small_execution()) + entry = index["entries"][0] + expected = _write_chain_fixture(root, entry) + assert protocol._load_chain(root, entry) == expected + + done_path = root / entry["output"] / "CHAIN_COMPLETE" + done = protocol.load_json(done_path) + done["algorithm_id"] = "wrong" + protocol.write_json(done_path, done) + with pytest.raises(protocol.ProtocolError, match="algorithm"): + protocol._load_chain(root, entry) + + +def test_gate_dependency_is_bound_to_current_index_and_meta( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + protocol.materialize(meta_path, root, small_execution()) + protocol._gate(root, "G0", passing_gate_payload("G0")) + gate_path = root / "gates" / "G0.json" + gate = protocol.load_json(gate_path) + gate["index_sha256"] = "0" * 64 + protocol.write_json(gate_path, gate) + with pytest.raises(protocol.ProtocolError, match="index"): + protocol._require_gate(root, "G0") + + +def test_compare_ed_includes_all_real_space_displacements() -> None: + results = [fake_result(value) for value in (0.0, 0.2, 0.4, 0.6)] + for result in results: + result["observables"]["real_space_green"] = { + "0,0": { + "one_body": { + "mean": [0.5, 0.0], + "naive_stderr_abs": 0.01, + } + }, + "1,0": { + "one_body": { + "mean": [0.1, 0.0], + "naive_stderr_abs": 0.01, + } + }, + } + cell = protocol.summarize_cell( + results, + beta=1.0, + n_sites=4, + thresholds={ + "r_hat_max": 2.0, + "bulk_ess_min": 1, + "tail_ess_min": 1, + "fast_vs_rebuild_relative_error_max": 1.0e-9, + "inverse_residual_max": 1.0e-8, + }, + acceptance_range=(0.2, 0.7), + ) + exact = { + "observables": { + "scalar": { + "energy_density": cell["scalar"]["energy_density"]["mean"], + "particle_density": cell["scalar"]["particle_density"]["mean"], + "compressibility": cell["compressibility"], + }, + "momentum": {}, + "real_space_green": { + "0,0": [0.5, 0.0], + "1,0": [0.1, 0.0], + }, + } + } + compared = protocol.compare_ed(cell, exact, 8.0) + assert set(compared["real_space_green"]) == {"0,0", "1,0"} + assert compared["pass"] + +def test_cli_materialize_and_validate_smoke(tmp_path: Path) -> None: + root = tmp_path / "cli-materialized" + script = Path(protocol.__file__).resolve() + command = [ + sys.executable, str(script), "materialize", + "--meta", str(META), "--output", str(root), + "--g1-steps", "20", "--g1-warmup", "4", + "--g1-measure-every", "2", "--g1-checkpoint-every", "10", + "--g1-rebuild-every", "4", + "--production-steps", "24", "--production-warmup", "4", + "--production-measure-every", "2", + "--production-checkpoint-every", "12", + "--production-rebuild-every", "4", + ] + completed = subprocess.run(command, check=False, capture_output=True, text=True) + assert completed.returncode == 0, completed.stderr + validated = subprocess.run( + [sys.executable, str(script), "validate", "--root", str(root)], + check=False, capture_output=True, text=True, + ) + assert validated.returncode == 0, validated.stderr + assert protocol.verify_materialization(root)["protocol_id"] == protocol.PROTOCOL_ID + + +def test_verify_rejects_current_source_snapshot_drift( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize(meta_path, root, small_execution()) + drift = deepcopy(index["source_snapshot"]) + drift["tracked_files_sha256"] = dict(drift["tracked_files_sha256"]) + drift["tracked_files_sha256"]["large_lattice_ctqmc.py"] = "0" * 64 + monkeypatch.setattr(protocol, "source_snapshot", lambda: drift) + with pytest.raises(protocol.ProtocolError, match="current source"): + protocol.verify_materialization(root) + +def _write_benchmark_fixture(root: Path, index: dict) -> dict: + manifest = protocol.load_json(root / index["kernel_benchmark"]["manifest"]) + cases = [] + for size in (4, 8, 12, 16): + n_sites = size * size + latency = {} + for move in ("insert", "delete"): + rank = n_sites * 100 + dense = rank * 3 + latency[move] = { + "rank3": {"median_ns": rank, "minimum_ns": rank, + "maximum_ns": rank, "samples_ns": [rank] * 9}, + "full_word_rebuild": { + "median_ns": dense, "minimum_ns": dense, + "maximum_ns": dense, "samples_ns": [dense] * 9}, + "speedup_dense_over_rank3": 3.0, + } + cases.append({ + "L": size, "N": n_sites, "latency": latency, + "correctness": {"pass": True}, + "fallback_count": {"insert": 0, "delete": 0}, + }) + sources = index["source_snapshot"]["tracked_files_sha256"] + report = { + "schema_version": 1, + "algorithm_id": protocol.BENCHMARK_ALGORITHM_ID, + "status": "benchmark_complete_unvalidated", + "parameters": manifest["parameters"], + "environment": { + "python_executable": index["environment"]["python_executable"], + "numpy_version": index["environment"]["numpy_version"], + "scipy_version": index["environment"]["scipy_version"], + }, + "single_thread_blas": { + "set_before_numpy_import": True, + "environment": {"OPENBLAS_NUM_THREADS": "1"}, + }, + "provenance": { + "source_commit": index["source_snapshot"]["git_commit"], + "benchmark_source_sha256": + sources["large_lattice_kernel_benchmark.py"], + "ctqmc_source_sha256": sources["large_lattice_ctqmc.py"], + }, + "cases": cases, + "overall_correctness_pass": True, + "total_fallback_count": {"insert": 0, "delete": 0}, + } + benchmark_dir = root / "benchmark" + benchmark_dir.mkdir() + protocol.write_json(benchmark_dir / "kernel_benchmark.json", report) + (benchmark_dir / "resource.tsv").write_text( + "elapsed_seconds\t1.0\nmax_rss_kb\t1024\n", encoding="utf-8" + ) + for name in ("runner.stdout", "runner.stderr", "preflight.log"): + (benchmark_dir / name).write_text("ok\n", encoding="utf-8") + return report + + +def test_kernel_benchmark_gate_passes_and_detects_tamper(tmp_path: Path) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize(meta_path, root, small_execution()) + report = _write_benchmark_fixture(root, index) + assert protocol.validate_kernel_benchmark(root, index)["pass"] + + report["provenance"]["benchmark_source_sha256"] = "0" * 64 + protocol.write_json(root / "benchmark" / "kernel_benchmark.json", report) + with pytest.raises(protocol.ProtocolError, match="source hash"): + protocol.validate_kernel_benchmark(root, index) + + report["provenance"]["benchmark_source_sha256"] = index[ + "source_snapshot" + ]["tracked_files_sha256"]["large_lattice_kernel_benchmark.py"] + case = next(item for item in report["cases"] if item["N"] == 144) + timing = case["latency"]["insert"] + timing["full_word_rebuild"]["median_ns"] = ( + timing["rank3"]["median_ns"] * 1.5 + ) + timing["full_word_rebuild"]["samples_ns"] = [ + timing["full_word_rebuild"]["median_ns"] + ] * 9 + timing["speedup_dense_over_rank3"] = 1.5 + protocol.write_json(root / "benchmark" / "kernel_benchmark.json", report) + checked = protocol.validate_kernel_benchmark(root, index) + assert not checked["speedup_pass"] + assert not checked["pass"] + + +def _resign_index(root: Path, index: dict) -> None: + protocol.write_json(root / "index.json", index) + (root / "index.sha256").write_text( + f"{protocol.sha_file(root / 'index.json')} index.json\n", + encoding="ascii", + ) + + +def test_generated_artifact_keyset_and_regeneration_resist_resigning( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + + missing_root = tmp_path / "missing-key" + protocol.materialize(meta_path, missing_root, small_execution()) + missing_index = protocol.load_json(missing_root / "index.json") + del missing_index["generated_artifact_sha256"][ + "slurm/run_g1_array.sbatch" + ] + _resign_index(missing_root, missing_index) + with pytest.raises(protocol.ProtocolError, match="key set"): + protocol.verify_materialization(missing_root) + + changed_root = tmp_path / "changed-script" + protocol.materialize(meta_path, changed_root, small_execution()) + script_path = changed_root / "slurm" / "run_g1_array.sbatch" + script_path.write_text( + script_path.read_text(encoding="utf-8") + "# forged\n", + encoding="utf-8", + ) + changed_index = protocol.load_json(changed_root / "index.json") + changed_index["generated_artifact_sha256"][ + "slurm/run_g1_array.sbatch" + ] = protocol.sha_file(script_path) + _resign_index(changed_root, changed_index) + with pytest.raises(protocol.ProtocolError, match="artifact content"): + protocol.verify_materialization(changed_root) + + +def test_array_preflight_rejects_malicious_tsv_before_side_effect( + tmp_path: Path, +) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + protocol.materialize(meta_path, root, small_execution()) + table = root / "g1_tasks.tsv" + lines = table.read_text(encoding="utf-8").splitlines() + fields = lines[1].split("\t") + fields[-1] = "../escaped-output" + lines[1] = "\t".join(fields) + table.write_text("\n".join(lines) + "\n", encoding="utf-8") + escaped = root.parent / "escaped-output" + + result = subprocess.run( + ["bash", str(root / "slurm" / "run_g1_array.sbatch")], + env={**os.environ, "SLURM_ARRAY_TASK_ID": "0"}, + capture_output=True, + text=True, + check=False, + ) + assert result.returncode != 0 + assert not escaped.exists() + + +def test_forged_gate_and_stale_complete_are_rejected(tmp_path: Path) -> None: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + forged_root = tmp_path / "forged" + protocol.materialize(meta_path, forged_root, small_execution()) + protocol._gate( + forged_root, + "G1", + {"status": "PASS", "stage": "g1", "cells": {}}, + ) + with pytest.raises(protocol.ProtocolError, match="cell cardinality"): + protocol._require_gate(forged_root, "G1") + + complete_root = tmp_path / "complete" + protocol.materialize(meta_path, complete_root, small_execution()) + for gate in ("G0", "G1", "G2", "G3", "G4"): + protocol._gate( + complete_root, gate, passing_gate_payload(gate) + ) + protocol.write_protocol_complete(complete_root) + with pytest.raises(protocol.ProtocolError, match="immutable"): + protocol._gate( + complete_root, "G0", passing_gate_payload("G0") + ) + + gate_path = complete_root / "gates" / "G1.json" + stale_gate = protocol.load_json(gate_path) + stale_gate["cells"]["cell-0"]["pass"] = False + protocol.write_json(gate_path, stale_gate) + with pytest.raises(protocol.ProtocolError, match="cell evidence"): + protocol.verify_materialization(complete_root) + + +@pytest.mark.parametrize("value", [None, "", " ", "none", -1, True]) +def test_slurm_id_normalization_rejects_missing_or_nondecimal(value: object) -> None: + assert protocol._normalize_slurm_id(value) is None + + +@pytest.mark.parametrize( + ("value", "expected"), + [(0, "0"), (121, "121"), ("0", "0"), ("00121", "00121")], +) +def test_slurm_id_normalization_accepts_nonnegative_decimal( + value: object, expected: str, +) -> None: + assert protocol._normalize_slurm_id(value) == expected + + +def _materialized_complete_evidence( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, +) -> tuple[Path, dict]: + meta_path = tmp_path / "confirmed.json" + write_meta(meta_path, confirmed_meta()) + root = tmp_path / "materialized" + index = protocol.materialize(meta_path, root, small_execution()) + + benchmark_output = root / index["kernel_benchmark"]["output"] + benchmark_output.parent.mkdir(parents=True, exist_ok=True) + benchmark_output.write_bytes(b"benchmark-evidence\n") + + def fake_validate_kernel(root_arg: Path, index_arg: dict) -> dict: + output = Path(root_arg) / index_arg["kernel_benchmark"]["output"] + return { + "pass": True, + "output_sha256": protocol.sha_file(output), + } + + monkeypatch.setattr( + protocol, "validate_kernel_benchmark", fake_validate_kernel + ) + benchmark = fake_validate_kernel(root, index) + + protocol._gate(root, "G0", passing_gate_payload("G0")) + g1_ids = sorted({ + entry["cell_id"] for entry in index["entries"] + if entry["stage"] == "g1" + }) + g1_cells = {} + for cell_id in g1_ids: + exact = root / "exact" / "g1" / f"{cell_id}.json" + exact.parent.mkdir(parents=True, exist_ok=True) + exact.write_bytes(f"exact:{cell_id}\n".encode()) + g1_cells[cell_id] = { + "pass": True, + "exact_ed_sha256": protocol.sha_file(exact), + } + protocol._gate(root, "G1", { + "status": "PASS", + "stage": "g1", + "cells": g1_cells, + "chain_cells_pass": True, + "all_cells_pass": True, + }) + + pilot_ids = sorted({ + entry["cell_id"] for entry in index["entries"] + if entry["stage"] == "production" and entry["pilot"] + }) + protocol._gate(root, "G2", { + "status": "PASS", + "stage": "pilot", + "cells": { + cell_id: {"pass": True} for cell_id in pilot_ids + }, + "chain_cells_pass": True, + "all_cells_pass": True, + "kernel_benchmark": benchmark, + "resource_gate": {"pass": True}, + }) + full_ids = sorted({ + entry["cell_id"] for entry in index["entries"] + if entry["stage"] == "production" + }) + protocol._gate(root, "G3", { + "status": "PASS", + "stage": "full", + "cells": { + cell_id: {"pass": True} for cell_id in full_ids + }, + "chain_cells_pass": True, + "all_cells_pass": True, + }) + + chains = [] + for task, entry in enumerate(index["entries"]): + output = root / entry["output"] + output.mkdir(parents=True, exist_ok=True) + for filename in ( + "result.json", "CHAIN_COMPLETE", "runner.stdout", + "runner.stderr", "preflight.log", "resource.tsv", + ): + (output / filename).write_bytes( + f"{entry['stage']}:{entry['cell_id']}:{entry['chain_id']}:{filename}\n".encode() + ) + chains.append({ + "stage": entry["stage"], + "cell_id": entry["cell_id"], + "chain_id": entry["chain_id"], + "result_sha256": protocol.sha_file(output / "result.json"), + "chain_complete_sha256": protocol.sha_file( + output / "CHAIN_COMPLETE" + ), + "runner_stdout_sha256": protocol.sha_file( + output / "runner.stdout" + ), + "runner_stderr_sha256": protocol.sha_file( + output / "runner.stderr" + ), + "preflight_sha256": protocol.sha_file( + output / "preflight.log" + ), + "resource": { + "sha256": protocol.sha_file(output / "resource.tsv") + }, + "slurm_job_id": str(task), + "array_task_id": str(task), + }) + protocol._gate(root, "G4", { + "status": "PASS", + "stage": "provenance", + "checks": {"source_snapshot": True, "environment": True}, + "chains": chains, + "distinct_slurm_array_tasks": 112, + }) + protocol.write_protocol_complete(root) + assert protocol.verify_materialization(root) == index + return root, index + + +def test_complete_revalidation_detects_chain_result_tamper( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, +) -> None: + root, index = _materialized_complete_evidence(tmp_path, monkeypatch) + result = root / index["entries"][0]["output"] / "result.json" + result.write_bytes(result.read_bytes() + b"tampered") + with pytest.raises(protocol.ProtocolError, match="chain evidence drift"): + protocol.verify_materialization(root) + + +def test_complete_revalidation_detects_ed_tamper( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, +) -> None: + root, _ = _materialized_complete_evidence(tmp_path, monkeypatch) + exact = root / "exact" / "g1" / "L2-b0.json" + exact.write_bytes(exact.read_bytes() + b"tampered") + with pytest.raises(protocol.ProtocolError, match="ED evidence drift"): + protocol.verify_materialization(root) + + +def test_complete_revalidation_detects_benchmark_tamper( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch, +) -> None: + root, index = _materialized_complete_evidence(tmp_path, monkeypatch) + output = root / index["kernel_benchmark"]["output"] + output.write_bytes(output.read_bytes() + b"tampered") + with pytest.raises( + protocol.ProtocolError, match="benchmark evidence drift" + ): + protocol.verify_materialization(root) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_local_vertex_physics.py b/tracks/qmc/solutions/Genshin_Impact-121/test_local_vertex_physics.py new file mode 100644 index 000000000..6ce028a73 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_local_vertex_physics.py @@ -0,0 +1,36 @@ +from __future__ import annotations + +import json +import math +from pathlib import Path +from typing import Any + +import local_vertex_physics as local + + +def assert_report_close(actual: Any, expected: Any, path: str = "root") -> None: + assert type(actual) is type(expected), path + if isinstance(actual, dict): + assert set(actual) == set(expected), path + for key in actual: + assert_report_close(actual[key], expected[key], f"{path}.{key}") + elif isinstance(actual, list): + assert len(actual) == len(expected), path + for index, (left, right) in enumerate(zip(actual, expected)): + assert_report_close(left, right, f"{path}[{index}]") + elif isinstance(actual, float): + assert math.isclose(actual, expected, rel_tol=0.0, abs_tol=1.0e-13), path + else: + assert actual == expected, path + + +def test_frozen_local_vertex_report_matches_independent_rebuild() -> None: + frozen = json.loads( + Path(__file__).with_name("local_vertex_physics_frozen.json").read_text( + encoding="utf-8" + ) + ) + rebuilt = local.build_report() + assert rebuilt["status"] == "analytic_numeric_local_result" + assert rebuilt["self_checks"]["status"] == "pass" + assert_report_close(rebuilt, frozen) From f247ec707bb00a022b9768bd8e4a1762a5f67ffe Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 14:30:28 +0800 Subject: [PATCH 08/13] qmc: preserve virtualenv interpreter in Slurm jobs --- .../solutions/Genshin_Impact-121/large_lattice_protocol.py | 3 ++- .../Genshin_Impact-121/test_large_lattice_protocol.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py index abddf3892..df734cebb 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py @@ -1399,7 +1399,8 @@ def main(argv: Optional[Sequence[str]]=None) -> int: return 2 if args.command=="audit" and result.get("status")!="PASS" else 0 def environment_snapshot() -> Mapping[str,Any]: - executable=Path(sys.executable).resolve() + # Preserve the invoked venv entry point; resolving it drops venv site-packages. + executable=Path(os.path.abspath(sys.executable)) _need(executable.is_absolute() and executable.is_file(), "validated Python executable is unavailable") versions={} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py index 9ebe856cc..9b7da73b9 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -369,9 +369,9 @@ def test_materialization_freezes_environment_and_restart_wrapper( index = protocol.materialize(meta_path, root, small_execution()) environment = index["environment"] assert Path(environment["python_executable"]).is_absolute() - assert Path(environment["python_executable"]).resolve() == Path( + assert Path(environment["python_executable"]) == Path( sys.executable - ).resolve() + ) assert environment["python_version"] assert environment["numpy_version"] assert environment["scipy_version"] From 5d874f2ebe4eb6df18d6d5af8e53c8ac48be55d3 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 14:47:43 +0800 Subject: [PATCH 09/13] qmc: freeze result root into Slurm scripts --- .../large_lattice_protocol.py | 36 +++++++++---------- .../test_large_lattice_protocol.py | 1 + 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py index df734cebb..9e96205da 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py @@ -289,7 +289,7 @@ def runner_manifest(meta_hash: str, stage: str, L: int, beta_index: int, def _task_table(path: Path, entries: Sequence[Mapping[str,Any]]) -> None: write_bytes(path,_task_table_bytes(entries)) -def _array_script(table: str, count: int, python_bin: str) -> str: +def _array_script(table: str, count: int, python_bin: str, result_root: str) -> str: return f"""#!/bin/bash #SBATCH --job-name=i121-{table.replace("_tasks.tsv","")} #SBATCH --array=0-{count-1}%8 @@ -297,7 +297,7 @@ def _array_script(table: str, count: int, python_bin: str) -> str: #SBATCH --mem=8G #SBATCH --time=04:00:00 set -euo pipefail -ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} PYTHON_BIN={shlex.quote(python_bin)} preflight=$("$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT") @@ -317,7 +317,7 @@ def _array_script(table: str, count: int, python_bin: str) -> str: --manifest "$ROOT/$manifest_rel" --output "$output" "${{resume[@]}}" \\ >>"$output/runner.stdout" 2>>"$output/runner.stderr" """.replace("$","$") -def _audit_script(stage: str, python_bin: str) -> str: +def _audit_script(stage: str, python_bin: str, result_root: str) -> str: ed="" if stage=="g1": ed="""while IFS=$'\\t' read -r cell manifest_rel exact_rel; do @@ -333,7 +333,7 @@ def _audit_script(stage: str, python_bin: str) -> str: #SBATCH --mem=8G #SBATCH --time=04:00:00 set -euo pipefail -ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} PYTHON_BIN={shlex.quote(python_bin)} preflight=$("$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT") @@ -370,14 +370,14 @@ def kernel_benchmark_manifest(sources: Mapping[str,Any]) -> Mapping[str,Any]: "resource_output":"benchmark/resource.tsv", "stdout":"benchmark/runner.stdout","stderr":"benchmark/runner.stderr"} -def _benchmark_script(python_bin: str) -> str: +def _benchmark_script(python_bin: str, result_root: str) -> str: return f"""#!/bin/bash #SBATCH --job-name=i121-kernel #SBATCH --cpus-per-task=1 #SBATCH --mem=8G #SBATCH --time=04:00:00 set -euo pipefail -ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} PYTHON_BIN={shlex.quote(python_bin)} preflight=$("$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT") @@ -392,15 +392,15 @@ def _benchmark_script(python_bin: str) -> str: >>"$ROOT/benchmark/runner.stdout" 2>>"$ROOT/benchmark/runner.stderr" """.replace("$","$") -def _generated_scripts(python_bin: str) -> Mapping[str,str]: - return {"run_g1_array.sbatch":_array_script("g1_tasks.tsv",32,python_bin), - "run_pilot_array.sbatch":_array_script("pilot_tasks.tsv",12,python_bin), - "run_full_array.sbatch":_array_script("full_tasks.tsv",68,python_bin), - "audit_g1.sbatch":_audit_script("g1",python_bin), - "audit_pilot.sbatch":_audit_script("pilot",python_bin), - "audit_full.sbatch":_audit_script("full",python_bin), - "audit_g4.sbatch":_audit_script("provenance",python_bin), - "run_kernel_benchmark.sbatch":_benchmark_script(python_bin), +def _generated_scripts(python_bin: str, result_root: str) -> Mapping[str,str]: + return {"run_g1_array.sbatch":_array_script("g1_tasks.tsv",32,python_bin,result_root), + "run_pilot_array.sbatch":_array_script("pilot_tasks.tsv",12,python_bin,result_root), + "run_full_array.sbatch":_array_script("full_tasks.tsv",68,python_bin,result_root), + "audit_g1.sbatch":_audit_script("g1",python_bin,result_root), + "audit_pilot.sbatch":_audit_script("pilot",python_bin,result_root), + "audit_full.sbatch":_audit_script("full",python_bin,result_root), + "audit_g4.sbatch":_audit_script("provenance",python_bin,result_root), + "run_kernel_benchmark.sbatch":_benchmark_script(python_bin,result_root), "submit_after_live_cluster_check.sh":_submit_script(), "run_g0.sbatch":f"""#!/bin/bash #SBATCH --job-name=i121-g0 @@ -408,7 +408,7 @@ def _generated_scripts(python_bin: str) -> Mapping[str,str]: #SBATCH --mem=4G #SBATCH --time=00:30:00 set -euo pipefail -ROOT=$(cd "$(dirname "$0")/.." && pwd -P) +ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} PYTHON_BIN={shlex.quote(python_bin)} "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_protocol.py" validate --root "$ROOT" @@ -462,7 +462,7 @@ def materialize(meta_path: Path, root: Path, if x["chain_id"]==0: ed.append(f'{x["cell_id"]}\t{x["manifest"]}\texact/g1/{x["cell_id"]}.json') write_bytes(root/"ed_tasks.tsv",("\n".join(ed)+"\n").encode()) - scripts=_generated_scripts(python_bin) + scripts=_generated_scripts(python_bin,str(root.resolve())) for name,text in scripts.items(): write_bytes(root/"slurm"/name,text.encode(),True) os.chmod(root/"slurm"/name,0o755) @@ -635,7 +635,7 @@ def verify_materialization(root: Path, expected_artifacts["kernel_benchmark_manifest.json"]=canonical_bytes( expected_benchmark) for name,text in _generated_scripts( - index["environment"]["python_executable"]).items(): + index["environment"]["python_executable"],str(root.resolve())).items(): expected_artifacts[f"slurm/{name}"]=text.encode() _need(set(artifacts)==set(expected_artifacts), "generated artifact key set drift") diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py index 9b7da73b9..bcfb7542f 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -381,6 +381,7 @@ def test_materialization_freezes_environment_and_restart_wrapper( encoding="utf-8" ) assert environment["python_executable"] in script + assert str(root.resolve()) in script assert "CHAIN_COMPLETE" in script assert "--resume" in script assert '>>"$output/runner.stdout"' in script From 382e64e03798d3a629ee369c2f6a28e6f7605564 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 15:51:21 +0800 Subject: [PATCH 10/13] qmc: make Slurm resource capture node portable --- .../Genshin_Impact-121/large_lattice_ctqmc.py | 14 ++++++++ .../large_lattice_kernel_benchmark.py | 33 +++++++++++++++++++ .../large_lattice_protocol.py | 8 +++-- .../test_large_lattice_ctqmc.py | 7 ++++ .../test_large_lattice_kernel_benchmark.py | 24 ++++++++++++++ .../test_large_lattice_protocol.py | 13 ++++++++ 6 files changed, 96 insertions(+), 3 deletions(-) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py index 64705380b..8821fbb5c 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py @@ -375,6 +375,18 @@ def execution_environment() -> Mapping[str,Any]: "array_task_id":os.environ.get("SLURM_ARRAY_TASK_ID"), "cluster_name":os.environ.get("SLURM_CLUSTER_NAME")}} +def append_resource_tsv(path:Path,wall_seconds:float, + max_rss_kb:Optional[int])->None: + path.parent.mkdir(parents=True,exist_ok=True) + rss=0 if max_rss_kb is None else int(max_rss_kb) + if not math.isfinite(wall_seconds) or wall_seconds<0 or rss<=0: + raise ManifestError("invalid resource measurement") + with path.open("a",encoding="utf-8") as handle: + handle.write(f"elapsed_seconds\t{wall_seconds:.17g}\n") + handle.write(f"max_rss_kb\t{rss}\n") + handle.flush() + os.fsync(handle.fileno()) + def validate_existing_complete(output: Path, manifest_sha256: str, expected_steps: int) -> Mapping[str,Any]: result_path=output/"result.json"; done_path=output/"CHAIN_COMPLETE" @@ -678,6 +690,8 @@ def run(self)->Mapping[str,Any]: result_path=self.output_dir/"result.json" atomic_write_json(result_path,result) self.save_checkpoint("run_complete_unvalidated") + append_resource_tsv( + self.output_dir/"resource.tsv",wall_seconds,max_rss_kb) result_sha256=hashlib.sha256(result_path.read_bytes()).hexdigest() atomic_write_json(self.output_dir/"CHAIN_COMPLETE",{ "schema_version":1,"status":"run_complete_unvalidated", diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py index 3102974ab..bb7498901 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_kernel_benchmark.py @@ -154,6 +154,31 @@ def atomic_write_json(path: Path, payload: Mapping[str, Any]) -> None: os.unlink(temporary) +def atomic_write_resource_tsv( + path: Path, wall_seconds: float, max_rss_kb: Optional[int] +) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + rss = 0 if max_rss_kb is None else int(max_rss_kb) + if not math.isfinite(wall_seconds) or wall_seconds < 0 or rss <= 0: + raise ValueError("invalid resource measurement") + raw = ( + f"elapsed_seconds\t{wall_seconds:.17g}\n" + f"max_rss_kb\t{rss}\n" + ) + descriptor, temporary = tempfile.mkstemp( + prefix="." + path.name + ".", suffix=".tmp", dir=path.parent + ) + try: + with os.fdopen(descriptor, "w", encoding="utf-8") as handle: + handle.write(raw) + handle.flush() + os.fsync(handle.fileno()) + os.replace(temporary, path) + finally: + if os.path.exists(temporary): + os.unlink(temporary) + + def relative_inf_error(actual: np.ndarray, reference: np.ndarray) -> float: return float( np.linalg.norm(actual - reference, np.inf) @@ -636,8 +661,10 @@ def main(argv: Optional[Sequence[str]] = None) -> int: default=DEFAULT_CONDITION_MAX, ) parser.add_argument("--output", type=Path) + parser.add_argument("--resource-output", type=Path) parser.add_argument("--compact", action="store_true") args = parser.parse_args(argv) + started = time.perf_counter() report = run_benchmark( sizes=args.sizes, beta=args.beta, @@ -646,6 +673,12 @@ def main(argv: Optional[Sequence[str]] = None) -> int: warmup=args.warmup, condition_max=args.condition_max, ) + if args.resource_output is not None: + atomic_write_resource_tsv( + args.resource_output, + float(time.perf_counter() - started), + ctqmc.linux_max_rss_kb(), + ) if args.output is not None: atomic_write_json(args.output, report) print(json.dumps({ diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py index 9e96205da..cb61a9e57 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py @@ -296,6 +296,7 @@ def _array_script(table: str, count: int, python_bin: str, result_root: str) -> #SBATCH --cpus-per-task=1 #SBATCH --mem=8G #SBATCH --time=04:00:00 +#SBATCH --chdir={result_root} set -euo pipefail ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} @@ -312,7 +313,6 @@ def _array_script(table: str, count: int, python_bin: str, result_root: str) -> exit 0 fi if [[ -f "$output/checkpoint.json" ]]; then resume=(--resume); fi -/usr/bin/time -a -f 'elapsed_seconds\\t%e\\nmax_rss_kb\\t%M' -o "$output/resource.tsv" \\ "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_ctqmc.py" \\ --manifest "$ROOT/$manifest_rel" --output "$output" "${{resume[@]}}" \\ >>"$output/runner.stdout" 2>>"$output/runner.stderr" @@ -332,6 +332,7 @@ def _audit_script(stage: str, python_bin: str, result_root: str) -> str: #SBATCH --cpus-per-task=1 #SBATCH --mem=8G #SBATCH --time=04:00:00 +#SBATCH --chdir={result_root} set -euo pipefail ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} @@ -376,6 +377,7 @@ def _benchmark_script(python_bin: str, result_root: str) -> str: #SBATCH --cpus-per-task=1 #SBATCH --mem=8G #SBATCH --time=04:00:00 +#SBATCH --chdir={result_root} set -euo pipefail ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} @@ -384,11 +386,10 @@ def _benchmark_script(python_bin: str, result_root: str) -> str: mkdir -p "$ROOT/benchmark" printf '%s\\n' "$preflight" >"$ROOT/benchmark/preflight.log" if [[ -f "$ROOT/benchmark/kernel_benchmark.json" ]]; then exit 0; fi -/usr/bin/time -a -f 'elapsed_seconds\\t%e\\nmax_rss_kb\\t%M' \\ - -o "$ROOT/benchmark/resource.tsv" \\ "$PYTHON_BIN" "$SOLUTION_DIR/large_lattice_kernel_benchmark.py" \\ --sizes 4,8,12,16 --beta 4 --seed 121730001 --repeats 9 --warmup 2 \\ --condition-max 1e12 --output "$ROOT/benchmark/kernel_benchmark.json" \\ + --resource-output "$ROOT/benchmark/resource.tsv" \\ >>"$ROOT/benchmark/runner.stdout" 2>>"$ROOT/benchmark/runner.stderr" """.replace("$","$") @@ -407,6 +408,7 @@ def _generated_scripts(python_bin: str, result_root: str) -> Mapping[str,str]: #SBATCH --cpus-per-task=1 #SBATCH --mem=4G #SBATCH --time=00:30:00 +#SBATCH --chdir={result_root} set -euo pipefail ROOT={shlex.quote(result_root)} SOLUTION_DIR={shlex.quote(str(SOLUTION_DIR))} diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py index 2c78d17df..626d561fe 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py @@ -1099,6 +1099,13 @@ def test_complete_validation_is_hash_bound_and_idempotent(tmp_path: Path) -> Non manifest, output, manifest_sha256=digest ) result = sampler.run() + resource_lines = (output / "resource.tsv").read_text( + encoding="utf-8" + ).splitlines() + assert resource_lines[0].startswith("elapsed_seconds\t") + assert float(resource_lines[0].split("\t")[1]) >= 0 + assert resource_lines[1].startswith("max_rss_kb\t") + assert int(resource_lines[1].split("\t")[1]) > 0 assert ctqmc.validate_existing_complete(output, digest, 8) == result assert ctqmc.main([ "--manifest", str(manifest_path), "--output", str(output) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py index 75bb13a91..8fb626e2c 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_kernel_benchmark.py @@ -15,6 +15,8 @@ import json import math +from pathlib import Path +import tempfile import unittest import large_lattice_kernel_benchmark as benchmark @@ -118,6 +120,28 @@ def test_quick_insert_delete_correctness_and_strict_json(self) -> None: decoded = json.loads(encoded) self.assertIs(decoded["overall_correctness_pass"], True) + def test_cli_writes_atomic_resource_tsv(self) -> None: + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + output = root / "benchmark.json" + resource = root / "resource.tsv" + code = benchmark.main([ + "--sizes", "2", + "--beta", "0.5", + "--repeats", "1", + "--warmup", "0", + "--output", str(output), + "--resource-output", str(resource), + ]) + self.assertEqual(code, 0) + self.assertTrue(output.is_file()) + lines = resource.read_text(encoding="utf-8").splitlines() + self.assertEqual(len(lines), 2) + self.assertEqual(lines[0].split("\t")[0], "elapsed_seconds") + self.assertGreaterEqual(float(lines[0].split("\t")[1]), 0.0) + self.assertEqual(lines[1].split("\t")[0], "max_rss_kb") + self.assertGreater(int(lines[1].split("\t")[1]), 0) + def test_fixed_seed_reproduces_word_and_candidate_fixtures(self) -> None: arguments = { "L": 2, diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py index bcfb7542f..50eeac166 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -385,6 +385,19 @@ def test_materialization_freezes_environment_and_restart_wrapper( assert "CHAIN_COMPLETE" in script assert "--resume" in script assert '>>"$output/runner.stdout"' in script + assert "/usr/bin/time" not in script + benchmark_script = ( + root / "slurm" / "run_kernel_benchmark.sbatch" + ).read_text(encoding="utf-8") + assert "/usr/bin/time" not in benchmark_script + assert "--resource-output" in benchmark_script + sbatch_files = list((root / "slurm").glob("*.sbatch")) + assert len(sbatch_files) == 9 + expected_chdir = f"#SBATCH --chdir={root.resolve()}" + assert all( + expected_chdir in path.read_text(encoding="utf-8") + for path in sbatch_files + ) def test_materialization_rejects_cardinality_path_and_tsv_tamper( From 5bf5905f6a08361cef2fba354dd2cc1be5b6b280 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 18:03:09 +0800 Subject: [PATCH 11/13] qmc: preregister autocorrelation-aware G1 v2 --- .../g1_v2_preregistration.md | 201 ++++++++++++++++++ .../Genshin_Impact-121/large_lattice_ctqmc.py | 45 +++- .../large_lattice_protocol.py | 78 ++++++- .../Genshin_Impact-121/large_lattice_run.json | 9 +- .../test_large_lattice_ctqmc.py | 39 ++++ .../test_large_lattice_protocol.py | 77 ++++++- 6 files changed, 425 insertions(+), 24 deletions(-) create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/g1_v2_preregistration.md diff --git a/tracks/qmc/solutions/Genshin_Impact-121/g1_v2_preregistration.md b/tracks/qmc/solutions/Genshin_Impact-121/g1_v2_preregistration.md new file mode 100644 index 000000000..8dcdfa508 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/g1_v2_preregistration.md @@ -0,0 +1,201 @@ +# Prospective G1 v2 preregistration for issue #121 + +- Team: `Genshin_Impact` +- Issue: `QuantumBFS/quantum.harness#121` +- Amendment scope: the large-lattice CTQMC G1 validation protocol only +- New protocol ID: `issue121-triangular-large-lattice-v2` +- Status: frozen prospectively after the terminal v1 audit and before any v2 result is generated + +The repository commit that first adds this document is the v2 freeze commit. +No v2 chain, exact-diagonalization output, pilot output, or gate may be generated +before that commit exists. After that commit, every choice below is immutable. +Any later change requires a separately named prospective protocol; it may not be +silently folded into v2. + +## 1. Frozen v1 evidence + +The v1 executable and result identity are: + +- executable commit: `382e64e03798d3a629ee369c2f6a28e6f7605564` + (short form `382e64e`); +- result root: + `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/`; +- `index.json` SHA256: + `48e4105356bcac107994d8a7b96a95bcc6070525a16d38d76edb7cf87d7b39e0`; +- `gates/G1.json` SHA256: + `8d110898750476dde97f5ecfb605c16b9f301b4642e7e76e0c11063827e4e3ff`. + +The terminal v1 workflow facts are: + +- G0 Slurm job `43389`: `PASS`; +- G1 probe job `43391` and remaining-array job `43394`: all 32 of 32 + chains produced `CHAIN_COMPLETE`; +- independent G1 audit job `43434`: `INCONCLUSIVE`; +- the v1 protocol ID was `issue121-triangular-large-lattice-v1`. + +The authoritative files are: + +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/gates/G0.json`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/gates/G1.json`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/index.sha256`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/slurm/audit-g1.43434.out`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/exact/g1/L3-b0.json`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/manifests/g1/L3/beta-0p5/chain-0.json`. + +### Exact v1 false leaf tests + +There were exactly four false leaf tests in the v1 G1 gate. Parent `pass=false` +objects are aggregates of these leaves and are not additional failures. + +| Kind | Cell and observable | Frozen v1 numbers | Why false in v1 | +|---|---|---|---| +| ED | `L3-b0`, `real_space_green["1,0"].one_body` | QMC = `[0.0032190527258243243, 0.0]`; ED = `[0.003530271749985057, 0.0]`; max absolute error = `0.0003112190241607326`; MCSE = `3.4617482465412555e-05`; allowance = `5×MCSE = 0.00017308741232706278` | `0.0003112190241607326 > 0.00017308741232706278` | +| acceptance | `L2-b3` | accepted/attempted = `75767/84003`; rate = `0.901955882528005` | outside v1 range `[0.1, 0.9]` | +| acceptance | `L3-b2` | accepted/attempted = `76215/83994`; rate = `0.9073862418744196` | outside v1 range `[0.1, 0.9]` | +| acceptance | `L3-b3` | accepted/attempted = `78601/84037`; rate = `0.9353142068374645` | outside v1 range `[0.1, 0.9]` | + +The v1 ED discrepancy is not reinterpreted here as a pass. The v1 record lacked +a stored per-measurement trace for every real-space Green-function component, +so its reported MCSE did not include a component-specific autocorrelation term. +This motivates a new prospective measurement and uncertainty protocol; it does +not prove in advance that the v1 discrepancy was only an error-bar artifact. + +Likewise, an upper acceptance-rate cutoff is not a correctness or mixing +criterion. High acceptance can be valid, but it also cannot establish +independence. v2 therefore uses acceptance only to detect a completely frozen +sampler and leaves convergence to R-hat and ESS. + +## 2. Frozen v2 protocol + +### 2.1 Protocol identity and independent randomness + +- `protocol_id = "issue121-triangular-large-lattice-v2"`. +- `seed_base = 221000000`. +- The chain rule is + `seed = 221000000 + 10000×L + 10×beta_index + chain_id`. +- `beta_index` remains `{1/2: 0, 1: 1, 2: 2, 4: 3}`. +- Each cell still has four chains: chain 0 and 1 cold, chain 2 and 3 hot, + with the same v1 initialization rule. +- No v1 RNG state, checkpoint, or chain output may be reused in v2. + +The new base is deliberately independent of the v1 base `121000000`. Seeds may +not be replaced after inspecting a chain. + +### 2.2 G1 cells and fixed run length + +The G1 fixtures remain the periodic triangular tori `L=2, N=4` and +`L=3, N=9` at `beta ∈ {1/2, 1, 2, 4}`. Physics parameters, boundary +conditions, measured displacements, momentum labels, and ED oracle are unchanged. + +For every one of the 32 G1 chains, freeze: + +| Parameter | v2 value | +|---|---:| +| total CTQMC steps | `300000` | +| warmup steps included in the total | `30000` | +| post-warmup measurements per chain | `270000` | +| measurement interval | `1` | +| checkpoint interval | `30000` | +| rebuild interval | `128` | +| chains per cell | `4` | +| post-warmup measurements per cell | `1080000` | + +A checkpoint must bind the v2 protocol ID, seed, trace-storage mode, trace keys, +and trace lengths. Resume is allowed only from a valid v2 checkpoint for the +same chain. Missing, malformed, non-finite, or length-mismatched traces are a +hard validation failure. The fixed 300000-step result is terminal for v2; any +extension after seeing v2 output requires a new prospective protocol. + +### 2.3 Real-space traces and autocorrelation-aware MCSE + +For every `N≤9` chain and every preregistered displacement `(dx,dy)`, store +the complete post-warmup measurement trace of both real and imaginary components +of `real_space_green[dx,dy].one_body`. These traces must be present in the +checkpoint, serialized state, and final result without thinning or component +selection. + +For each component `a ∈ {Re, Im}`, compute the same rank-normalized split-chain +diagnostics used by v1: split R-hat, bulk ESS, tail ESS, and the per-original-chain +integrated autocorrelation estimates. Let `s_pooled,a` be the ordinary sample +standard deviation of all four post-warmup component traces pooled together. +Define + +`MCSE_corr,a = s_pooled,a / √max(1, ESS_bulk,a)`. + +For each complex real-space observable, define the three error estimates as: + +- `MCSE_correlated = max_a MCSE_corr,a`; +- `MCSE_between-chain = max_a [sd(chain means for a) / √4]`; +- `MCSE_naive = √(∑_c se_naive,c²) / 4`, retaining the v1 combined + per-chain naive estimator; +- `MCSE_final = max(MCSE_correlated, MCSE_between-chain, MCSE_naive)`. + +The ED comparison remains conservative and unchanged in form: + +- `error = max_a |QMC_a - ED_a|`; +- `allowance = max(5×MCSE_final, 1e-10)`; +- the observable passes exactly when `error ≤ allowance`. + +The gate output must record the real and imaginary component diagnostics and all +three MCSE candidates, so the selected maximum can be independently audited. +No trace, component, chain, or displacement may be excluded after inspection. + +### 2.4 Acceptance is only a non-freezing gate + +For G1, the G2 pilot, and G3 production, freeze the operational acceptance range +to `[0.05, 1.0]`, inclusive. The rate is `accepted / attempted`. A missing, +non-finite, or undefined rate, including `attempted = 0`, fails this operational +check. A rate below `0.05` means the sampler is operationally too frozen. + +There is no high-acceptance failure: any finite rate up to and including `1.0` +passes this check. In particular, high acceptance is not evidence of a bug and +is not evidence of independent samples. The pilot uses this same pass range; +there is no separate upper pass/fail target. + +The convergence gates remain hard and keep the v1 thresholds: + +- rank-normalized split `R-hat ≤ 1.01`; +- bulk ESS `≥ 1000`; +- tail ESS `≥ 400`. + +Acceptance cannot override an R-hat or ESS failure. The zero-weight, +negative-sign, fast-update residual, rebuild, provenance, and ED correctness +conditions also remain hard and unchanged. + +### 2.5 Downstream production schedule is unchanged + +Only the v2 clauses above change. The prospective production design remains: + +- G2 pilot cells: `(L,beta) = (4,1/2), (8,2), (12,4)`; +- G3 full grid: `L ∈ {4,6,8,12,16}` crossed with + `beta ∈ {1/2,1,2,4}`; +- four immutable-seed chains per cell, two cold and two hot; +- pilot-based resource capture and run-length freezing; +- equal extension of all four production chains under the existing + preregistered rule; +- gate order `G0 → G1 → G2 → G3 → G4` and all existing dependency rules. + +The Hamiltonian, local matrices, couplings, lattice geometry, boundary +conditions, `mu=0` interpretation limits, observables, full-grid cells, +positivity claim, and production resource policy are unchanged. + +## 3. Prospective decision rule and non-retroactivity + +v2 must write to a new result root and must never overwrite or edit the frozen +v1 root. Its index, executable commit, manifests, Slurm job IDs, completion +sentinels, gate files, and audit output must be recorded independently. + +This amendment is prospective and post-v1: + +1. It does not retroactively change any v1 threshold. +2. It does not delete or relabel any of the four v1 false leaf tests. +3. It does not reclassify the v1 `INCONCLUSIVE` audit as `PASS`. +4. It does not guarantee that v2 will pass. +5. If the longer independent run still violates ED, R-hat, ESS, positivity, + residual, provenance, or operational acceptance gates, that v2 outcome is + reported as observed. Thresholds, seeds, traces, and chain lengths may not be + retuned after inspection. + +A v2 pass would be new evidence under this frozen protocol only. It would not +make the v1 run a pass and would not by itself establish claims outside the +original fixed-`mu=0` benchmark scope. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py index 8821fbb5c..c88020d04 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py @@ -271,12 +271,14 @@ def measure_configuration(factors:DenseFactors,geometry:TriangularGeometry,beta: class ObservableAccumulator: KEYS=("order","energy_density","particle_number","particle_number_squared", "particle_density","particle_density_squared") - def __init__(self)->None: + def __init__(self,store_real_space_traces:bool=False)->None: self.count=0 + self.store_real_space_traces=bool(store_real_space_traces) self.scalar={k:{"sum":0.0,"sum_sq":0.0} for k in self.KEYS} self.primary_traces={k:[] for k in self.KEYS} self.momentum:Dict[str,Any]={} self.real_space:Dict[str,Any]={} + self.real_space_traces:Dict[str,Any]={} @staticmethod def _add_complex(target:Dict[str,Any],key:str,name:str,pair:Sequence[float])->None: slot=target.setdefault(key,{}).setdefault( @@ -295,17 +297,26 @@ def add(self,obs:Mapping[str,Any])->None: self._add_complex(self.momentum,momentum,name,pair) for displacement,pair in obs.get("real_space_green",{}).items(): self._add_complex(self.real_space,displacement,"one_body",pair) + if self.store_real_space_traces: + trace=self.real_space_traces.setdefault( + displacement,{"real":[],"imag":[]}) + trace["real"].append(float(pair[0])) + trace["imag"].append(float(pair[1])) def state(self)->Mapping[str,Any]: return {"count":self.count,"scalar":self.scalar, "primary_traces":self.primary_traces, - "momentum":self.momentum,"real_space_green":self.real_space} + "momentum":self.momentum,"real_space_green":self.real_space, + "store_real_space_traces":self.store_real_space_traces, + "real_space_traces":self.real_space_traces} @classmethod - def from_state(cls,state:Mapping[str,Any])->"ObservableAccumulator": - obj=cls();obj.count=int(state.get("count",0)) + def from_state(cls,state:Mapping[str,Any], + store_real_space_traces:bool=False)->"ObservableAccumulator": + obj=cls(store_real_space_traces);obj.count=int(state.get("count",0)) obj.scalar=state.get("scalar",obj.scalar) obj.primary_traces=state.get("primary_traces",obj.primary_traces) obj.momentum=state.get("momentum",{}) obj.real_space=state.get("real_space_green",{}) + obj.real_space_traces=state.get("real_space_traces",{}) return obj @staticmethod def _complex_summary(values:Mapping[str,Any],count:int)->Mapping[str,Any]: @@ -342,6 +353,8 @@ def summary(self,beta:float,n_sites:int)->Mapping[str,Any]: "compressibility":compressibility, "primary_traces":self.primary_traces, "momentum":momentum,"real_space_green":real_space, + "store_real_space_traces":self.store_real_space_traces, + "real_space_traces":self.real_space_traces, "error_note":"naive iid errors; use primary_traces for tau_int/ESS/R-hat"} def linux_max_rss_kb()->Optional[int]: @@ -442,7 +455,7 @@ def __init__(self,geometry:TriangularGeometry,catalog:Sequence[LocalVertex], self.initialization=dict(mc["initialization"]) self.rng=np.random.Generator(np.random.PCG64DXSM(int(mc["seed"]))) self.word:Deque[Event]=deque();self.completed_steps=0 - self.accumulator=ObservableAccumulator() + self.accumulator=ObservableAccumulator(geometry.n_sites<=9) self.G0=geometry.n_triangles*(model["g_A"]+model["g_B"]) self.active=[v.vertex_id for v in catalog if v.activity>0] weights=np.array([catalog[i].activity for i in self.active]) @@ -625,12 +638,28 @@ def load_checkpoint(self)->None: not isinstance(trace,list) or len(trace)!=expected_count for trace in traces.values()): raise ManifestError("checkpoint primary trace length mismatch") + expected_real={f"{dx},{dy}" for dx,dy in self.displacements} + real_traces=accumulator.get("real_space_traces") + store_real=self.geometry.n_sites<=9 + if accumulator.get("store_real_space_traces") is not store_real or not isinstance( + real_traces,Mapping): + raise ManifestError("checkpoint real-space trace mode mismatch") + if store_real: + if set(real_traces)!=expected_real or any( + not isinstance(item,Mapping) or set(item)!={"real","imag"} or + any(not isinstance(values,list) or len(values)!=expected_count + for values in item.values()) + for item in real_traces.values()): + raise ManifestError("checkpoint real-space trace length mismatch") + elif real_traces: + raise ManifestError("unexpected checkpoint real-space traces") self.completed_steps=completed self.word=deque(Event.from_json(e) for e in data["word"]) self.rng.bit_generator.state=data["rng_state"];self.counters=data["counters"] self.counters.setdefault("determinant_failures",{"zero":0,"negative":0}) saved_moves_since_rebuild=int(data.get("moves_since_rebuild",0)) - self.accumulator=ObservableAccumulator.from_state(data["accumulator"]) + self.accumulator=ObservableAccumulator.from_state( + data["accumulator"],store_real) self.rebuild_diagnostics=list(data.get("rebuild_diagnostics",[])) self.rebuild("resume",False) self.moves_since_rebuild=saved_moves_since_rebuild @@ -682,9 +711,9 @@ def run(self)->Mapping[str,Any]: "implementation":{"fock_space_constructed":False, "local_storage":"12 local 3x3 B/B_inv templates","state":"dense T,Q,logdet", "stabilization":"direct O(mN) rebuild + dense O(N^3) LU", - "trace_storage":"pilot-only in-memory/checkpoint JSON; O(n_measurements)", + "trace_storage":"primary plus N<=9 real-space traces in memory/checkpoint JSON; O(n_measurements)", "not_implemented":["QR/UDT","chunked production trace storage", - "autocorrelation-aware errors"]}, + "autocorrelation-aware errors outside stored traces"]}, "validation_status":"single chain ran; correctness and science gates remain unvalidated", "claim_boundary":"mu is not implemented; no finite-density ground-state or mixing claim"} result_path=self.output_dir/"result.json" diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py index cb61a9e57..877629c4e 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py @@ -23,7 +23,7 @@ from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple import numpy as np -PROTOCOL_ID = "issue121-triangular-large-lattice-v1" +PROTOCOL_ID = "issue121-triangular-large-lattice-v2" CORE_ALGORITHM_ID = "triangular-ab-ctqmc-direct-lu-v1" ED_ALGORITHM_ID = "triangular-ab-full-fock-ed-oracle-v1" BENCHMARK_ALGORITHM_ID = "rank3-vs-full-word-rebuild-v1" @@ -35,6 +35,7 @@ "test_large_lattice_ctqmc.py", "test_local_vertex_physics.py", "large_lattice_kernel_benchmark.py", "test_large_lattice_kernel_benchmark.py", + "g1_v2_preregistration.md", ) SIZES = ((4,16),(6,36),(8,64),(12,144),(16,256)) BETAS = (0.5,1.0,2.0,4.0) @@ -56,8 +57,8 @@ "Geyer initial-positive-sequence ESS; pooled tail cutoffs 5%/95%" ) DEFAULT_EXECUTION = { - "g1":{"steps":30000,"warmup":3000,"measure_every":1, - "checkpoint_every":3000,"rebuild_every":128}, + "g1":{"steps":300000,"warmup":30000,"measure_every":1, + "checkpoint_every":30000,"rebuild_every":128}, "production":{"steps":100000,"warmup":10000,"measure_every":10, "checkpoint_every":5000,"rebuild_every":256}, "woodbury_condition_max":1.0e12, @@ -130,6 +131,8 @@ def validate_meta(meta: Mapping[str,Any]) -> None: "document_type drift") _need(meta.get("issue")==121 and meta.get("team")=="Genshin_Impact", "issue/team drift") + _need(meta.get('amendment_document')=='g1_v2_preregistration.md', + 'amendment document drift') rat=meta.get("ratification") _need(isinstance(rat,Mapping) and rat.get("required_before_any_compute") is True, "ratification guard absent") @@ -168,7 +171,7 @@ def validate_meta(meta: Mapping[str,Any]) -> None: _need(isinstance(random,Mapping) and random.get("chains_per_cell")==4, "chain count drift") _need(random.get("seed_rule")== - "121000000 + 10000*L + 10*beta_index + chain_id","seed rule drift") + "221000000 + 10000*L + 10*beta_index + chain_id","seed rule drift") _need(random.get("beta_index")=={"1/2":0,"1":1,"2":2,"4":3}, "beta index drift") seen=tuple((x.get("chain_id"),x.get("start"),x.get("initial_order")) @@ -208,6 +211,9 @@ def validate_meta(meta: Mapping[str,Any]) -> None: "full_acceptance_hard_range","pilot_acceptance_target", "r_hat_max","bulk_ess_min","tail_ess_min","ed_z_score_max"): _need(key in thresholds,f"threshold missing: {key}") + _need(thresholds.get('pilot_acceptance_target')==[0.05,1.0] and + thresholds.get('full_acceptance_hard_range')==[0.05,1.0], + 'acceptance protocol drift') def validate_execution(execution: Mapping[str,Any]) -> None: for stage in ("g1","production"): @@ -229,7 +235,7 @@ def validate_execution(execution: Mapping[str,Any]) -> None: "rotation asymmetry") def seed_for(L: int, beta_index: int, chain_id: int) -> int: - return 121000000+10000*L+10*beta_index+chain_id + return 221000000+10000*L+10*beta_index+chain_id def _unique(points: Iterable[Tuple[int,int]], L: int) -> List[List[int]]: out=[]; seen=set() @@ -697,7 +703,25 @@ def _load_chain(root: Path, entry: Mapping[str,Any]) -> Mapping[str,Any]: _need(measured.get("momenta")==manifest["measurements"]["momenta"] and measured.get("displacements")==manifest["measurements"]["displacements"], "measurement binding") - _need(result.get("observables",{}).get("count",0)>0,"no measurements") + observables=result.get("observables",{}) + count=observables.get("count",0) + _need(isinstance(count,int) and count>0,"no measurements") + store_real=entry["N"]<=9 + real_traces=observables.get("real_space_traces") + expected_real={f"{x},{y}" for x,y in manifest["measurements"]["displacements"]} + _need(observables.get("store_real_space_traces") is store_real and + isinstance(real_traces,Mapping),"result real-space trace mode") + if store_real: + _need(set(real_traces)==expected_real,"result real-space trace set") + for key,item in real_traces.items(): + _need(isinstance(item,Mapping) and set(item)=={"real","imag"}, + f"result real-space trace components: {key}") + for component,values in item.items(): + _need(isinstance(values,list) and len(values)==count and + all(math.isfinite(float(value)) for value in values), + f"result real-space trace length: {key}/{component}") + else: + _need(not real_traces,"unexpected result real-space traces") canonical_bytes(result); canonical_bytes(done) return result @@ -730,8 +754,33 @@ def _momentum(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: raw[0]-mode[0]**2-mode[1]**2,raw[1]] return out +def _correlated_trace_diagnostics( + chains: Sequence[Sequence[float]]) -> Mapping[str,Any]: + diagnostic=dict(multi_chain_diagnostics(chains)) + pooled=np.concatenate([np.asarray(chain,float) for chain in chains]) + sample_std=float(np.std(pooled,ddof=1)) + diagnostic["pooled_sample_std"]=sample_std + diagnostic["mcse"]=sample_std/math.sqrt(max(1.0,float( + diagnostic["bulk_ess"]))) + return diagnostic + def _real_space(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: - return _aggregate_complex(results,"real_space_green",("one_body",)) + out=_aggregate_complex(results,"real_space_green",("one_body",)) + if not bool(results[0]["observables"]["store_real_space_traces"]): + return out + for displacement,item in out.items(): + diagnostics={} + for component in ("real","imag"): + chains=[] + for result in results: + traces=result["observables"]["real_space_traces"] + _need(displacement in traces and component in traces[displacement], + f"missing real-space trace: {displacement}/{component}") + chains.append([float(value) for value in + traces[displacement][component]]) + diagnostics[component]=_correlated_trace_diagnostics(chains) + item["one_body"]["correlated_diagnostics"]=diagnostics + return out def summarize_cell(results: Sequence[Mapping[str,Any]], beta: float, n_sites: int, thresholds: Mapping[str,Any], @@ -808,12 +857,19 @@ def _mean_se(pairs: Sequence[Sequence[float]], component: int) -> float: values=np.array([float(x[component]) for x in pairs]) return float(np.std(values,ddof=1)/math.sqrt(len(values))) -def _complex_mcse(sampled: Mapping[str,Any]) -> float: +def _complex_mcse_components(sampled: Mapping[str,Any]) -> Mapping[str,float]: between=max(_mean_se(sampled["chain_means"],i) for i in (0,1)) naive=[float(x) for x in sampled.get("chain_naive_stderr_abs",()) if math.isfinite(float(x))] within=math.sqrt(sum(x*x for x in naive))/len(naive) if naive else 0.0 - return max(between,within) + diagnostics=sampled.get("correlated_diagnostics",{}) + correlated=max((float(item.get("mcse",0.0)) + for item in diagnostics.values() + if isinstance(item,Mapping)),default=0.0) + return {"correlated":correlated,"between_chain":between,"naive":within} + +def _complex_mcse(sampled: Mapping[str,Any]) -> float: + return max(_complex_mcse_components(sampled).values()) def _compare_complex_section(sampled_section: Mapping[str,Any], exact_section: Mapping[str,Any], @@ -826,10 +882,12 @@ def _compare_complex_section(sampled_section: Mapping[str,Any], for name in names: sampled=sampled_section[key][name] target=reference[name] if isinstance(reference,Mapping) else reference - se=_complex_mcse(sampled); allowance=max(zmax*se,1e-10) + components=_complex_mcse_components(sampled) + se=max(components.values()); allowance=max(zmax*se,1e-10) error=max(abs(float(sampled["mean"][i])-float(target[i])) for i in (0,1)) item[name]={"max_abs_error":error,"mcse":se, + "mcse_components":components, "allowance":allowance,"pass":error<=allowance} item["pass"]=all(v["pass"] for k,v in item.items() if k!="pass") comparison[key]=item diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json index 630e8b76f..345809115 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json @@ -3,6 +3,7 @@ "document_type": "preregistered_large_lattice_run", "issue": 121, "team": "Genshin_Impact", + "amendment_document": "g1_v2_preregistration.md", "status": "ratified_setup_frozen_pending_gates", "ratification": { "required_before_any_compute": true, @@ -61,7 +62,7 @@ "randomness": { "engine": "NumPy PCG64DXSM; exact package version frozen in run snapshot", "chains_per_cell": 4, - "seed_rule": "121000000 + 10000*L + 10*beta_index + chain_id", + "seed_rule": "221000000 + 10000*L + 10*beta_index + chain_id", "beta_index": {"1/2": 0, "1": 1, "2": 2, "4": 3}, "chains": [ {"chain_id": 0, "start": "cold", "initial_order": 0}, @@ -199,8 +200,8 @@ "negative_sign_count_required": 0, "zero_weight_count_required": 0, "analytic_condition_number_upper_approx": 400, - "pilot_acceptance_target": [0.2, 0.7], - "full_acceptance_hard_range": [0.1, 0.9], + "pilot_acceptance_target": [0.05, 1.0], + "full_acceptance_hard_range": [0.05, 1.0], "r_hat_max": 1.01, "bulk_ess_min": 1000, "tail_ess_min": 400, @@ -233,7 +234,7 @@ "No compute before setup ratification and no gate skipping.", "Any computed zero or negative weight is a hard failure, never a discarded sample.", "Persistent fast-vs-rebuild mismatch or residual above threshold stops the run.", - "Acceptance outside the full hard range after pilot-frozen tuning fails or makes the cell inconclusive.", + "Acceptance below 0.05, above 1.0, missing, non-finite, or undefined fails the operational non-freezing gate; high acceptance alone is not a correctness or mixing failure.", "R-hat or ESS failure after equal extension to the pilot-frozen cap makes the cell inconclusive.", "OOM, timeout, missing durable checkpoint, or missing completion sentinel is failure.", "Do not start L greater than 12 before a stable, faster rank-3 update passes the pilot.", diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py index 626d561fe..1e3dab061 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_ctqmc.py @@ -946,6 +946,13 @@ def test_checkpoint_roundtrip_preserves_word_rng_and_primary_traces( assert saved["accumulator"]["primary_traces"] == ( sampler.accumulator.primary_traces ) + real_traces = saved["accumulator"]["real_space_traces"] + assert set(real_traces) == {"0,0", "1,0", "0,1"} + assert all( + len(component) == 1 + for trace in real_traces.values() + for component in trace.values() + ) expected_random = sampler.rng.random(8) restored = _sampler( @@ -1099,6 +1106,14 @@ def test_complete_validation_is_hash_bound_and_idempotent(tmp_path: Path) -> Non manifest, output, manifest_sha256=digest ) result = sampler.run() + real_traces = result["observables"]["real_space_traces"] + assert result["observables"]["store_real_space_traces"] is True + assert set(real_traces) == {"0,0", "1,0", "0,1"} + assert all( + len(component) == result["observables"]["count"] + for trace in real_traces.values() + for component in trace.values() + ) resource_lines = (output / "resource.tsv").read_text( encoding="utf-8" ).splitlines() @@ -1183,3 +1198,27 @@ def test_load_checkpoint_rejects_accumulator_count_mismatch( restored = _sampler(tmp_path) with pytest.raises(ctqmc.ManifestError, match="accumulator count"): restored.load_checkpoint() + + +def test_load_checkpoint_rejects_real_space_trace_length_mismatch( + tmp_path: Path, +) -> None: + sampler = _sampler(tmp_path) + sampler.completed_steps = 3 + sampler.accumulator.add(ctqmc.measure_configuration( + sampler.factors, + sampler.geometry, + sampler.beta, + sampler.G0, + len(sampler.word), + sampler.momenta, + sampler.displacements, + )) + sampler.save_checkpoint("running") + path = tmp_path / "checkpoint.json" + payload = json.loads(path.read_text(encoding="utf-8")) + payload["accumulator"]["real_space_traces"]["1,0"]["real"] = [] + ctqmc.atomic_write_json(path, payload) + + with pytest.raises(ctqmc.ManifestError, match="real-space trace length"): + _sampler(tmp_path).load_checkpoint() diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py index 50eeac166..83c5fe9d6 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -132,7 +132,7 @@ def test_materialization_cardinality_hashes_and_frozen_manifests( ] assert len(production) == 4 assert [entry["seed"] for entry in production] == [ - 121060020, 121060021, 121060022, 121060023 + 221060020, 221060021, 221060022, 221060023 ] manifests = [ protocol.load_json(root / entry["manifest"]) @@ -270,6 +270,8 @@ def fake_result(offset: float) -> dict: "count": length, "primary_traces": traces, "momentum": {}, + "store_real_space_traces": True, + "real_space_traces": {}, }, "counters": { "moves": { @@ -468,7 +470,14 @@ def _write_chain_fixture(root: Path, entry: dict) -> dict: "model": manifest["model"], "initialization": entry["initialization"], "measurements": manifest["measurements"], - "observables": {"count": 1}, + "observables": { + "count": 1, + "store_real_space_traces": entry["N"] <= 9, + "real_space_traces": { + f"{dx},{dy}": {"real": [0.0], "imag": [0.0]} + for dx, dy in manifest["measurements"]["displacements"] + } if entry["N"] <= 9 else {}, + }, "execution_environment": {}, } output = root / entry["output"] @@ -527,6 +536,10 @@ def test_gate_dependency_is_bound_to_current_index_and_meta( def test_compare_ed_includes_all_real_space_displacements() -> None: results = [fake_result(value) for value in (0.0, 0.2, 0.4, 0.6)] for result in results: + result["observables"]["real_space_traces"] = { + "0,0": {"real": [0.5] * 64, "imag": [0.0] * 64}, + "1,0": {"real": [0.1] * 64, "imag": [0.0] * 64}, + } result["observables"]["real_space_green"] = { "0,0": { "one_body": { @@ -964,3 +977,63 @@ def test_complete_revalidation_detects_benchmark_tamper( protocol.ProtocolError, match="benchmark evidence drift" ): protocol.verify_materialization(root) + + +def test_autocorrelated_real_space_trace_inflates_mcse_and_allowance() -> None: + block_trace = np.tile(np.repeat([-1.0, 1.0], 16), 8) + results = [fake_result(offset) for offset in (0.0, 0.2, 0.4, 0.6)] + for result in results: + result["observables"]["real_space_green"] = { + "1,0": { + "one_body": { + "mean": [0.0, 0.0], + "naive_stderr_abs": float( + np.std(block_trace, ddof=1) + / math.sqrt(len(block_trace)) + ), + } + } + } + result["observables"]["real_space_traces"] = { + "1,0": { + "real": block_trace.tolist(), + "imag": [0.0] * len(block_trace), + } + } + result["observables"]["count"] = len(block_trace) + + sampled = protocol._real_space(results)["1,0"]["one_body"] + components = protocol._complex_mcse_components(sampled) + assert components["correlated"] > components["naive"] + assert components["correlated"] > components["between_chain"] + + target_error = components["naive"] + components["correlated"] + assert target_error > 2.0 * components["naive"] + assert target_error < 2.0 * components["correlated"] + comparison = protocol._compare_complex_section( + {"1,0": {"one_body": sampled}}, + {"1,0": [target_error, 0.0]}, + ("one_body",), + 2.0, + )["1,0"]["one_body"] + assert comparison["mcse"] == pytest.approx(components["correlated"]) + assert comparison["allowance"] == pytest.approx( + 2.0 * components["correlated"] + ) + assert comparison["pass"] + + +def test_real_space_without_trace_storage_keeps_production_summary() -> None: + results = [fake_result(offset) for offset in (0.0, 0.2, 0.4, 0.6)] + for result in results: + result["observables"]["store_real_space_traces"] = False + result["observables"]["real_space_traces"] = {} + result["observables"]["real_space_green"] = { + "1,0": {"one_body": { + "mean": [0.25, 0.0], + "naive_stderr_abs": 0.01, + }} + } + sampled = protocol._real_space(results) + assert sampled["1,0"]["one_body"]["mean"] == pytest.approx([0.25, 0.0]) + assert "correlated_diagnostics" not in sampled["1,0"]["one_body"] From a6b091c718eea82227316e738a80db5a0f1d1170 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 19:30:40 +0800 Subject: [PATCH 12/13] qmc: preregister universal-observable G1 v3 --- .../g1_v3_preregistration.md | 209 ++++++++++++++++++ .../Genshin_Impact-121/large_lattice_ctqmc.py | 35 ++- .../large_lattice_protocol.py | 63 ++++-- .../Genshin_Impact-121/large_lattice_run.json | 4 +- .../system_introduction_zh.html | 102 +++++++++ .../test_large_lattice_protocol.py | 40 +++- 6 files changed, 435 insertions(+), 18 deletions(-) create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/g1_v3_preregistration.md create mode 100644 tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html diff --git a/tracks/qmc/solutions/Genshin_Impact-121/g1_v3_preregistration.md b/tracks/qmc/solutions/Genshin_Impact-121/g1_v3_preregistration.md new file mode 100644 index 000000000..71b263b91 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/g1_v3_preregistration.md @@ -0,0 +1,209 @@ +# Prospective G1 v3 preregistration for issue #121 + +- Team: `Genshin_Impact` +- Issue: `QuantumBFS/quantum.harness#121` +- Amendment scope: the large-lattice CTQMC G1 validation protocol only +- New protocol ID: `issue121-triangular-large-lattice-v3` +- Status: frozen prospectively after the terminal v2 audit and before any v3 result is generated + +The repository commit that first adds this document is the v3 freeze commit. +No v3 chain, exact-diagonalization output, pilot output, or gate may be generated +before that commit exists. After that commit, every v3 choice below is immutable. +Any later change requires a separately named prospective protocol; it may not be +silently folded into v3. + +## 1. Frozen v1 evidence + +The v1 executable and result identity are: + +- executable commit: `382e64e03798d3a629ee369c2f6a28e6f7605564` + (short form `382e64e`); +- result root: + `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/`; +- `index.json` SHA256: + `48e4105356bcac107994d8a7b96a95bcc6070525a16d38d76edb7cf87d7b39e0`; +- `gates/G1.json` SHA256: + `8d110898750476dde97f5ecfb605c16b9f301b4642e7e76e0c11063827e4e3ff`. + +The terminal v1 workflow facts are: + +- G0 Slurm job `43389`: `PASS`; +- G1 probe job `43391` and remaining-array job `43394`: all 32 of 32 + chains produced `CHAIN_COMPLETE`; +- independent G1 audit job `43434`: `INCONCLUSIVE`; +- the v1 protocol ID was `issue121-triangular-large-lattice-v1`. + +The authoritative files are: + +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/gates/G0.json`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/gates/G1.json`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/index.sha256`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/slurm/audit-g1.43434.out`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/exact/g1/L3-b0.json`; +- `tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-382e64e/manifests/g1/L3/beta-0p5/chain-0.json`. + +### Exact v1 false leaf tests + +There were exactly four false leaf tests in the v1 G1 gate. Parent `pass=false` +objects are aggregates of these leaves and are not additional failures. + +| Kind | Cell and observable | Frozen v1 numbers | Why false in v1 | +|---|---|---|---| +| ED | `L3-b0`, `real_space_green["1,0"].one_body` | QMC = `[0.0032190527258243243, 0.0]`; ED = `[0.003530271749985057, 0.0]`; max absolute error = `0.0003112190241607326`; MCSE = `3.4617482465412555e-05`; allowance = `5×MCSE = 0.00017308741232706278` | `0.0003112190241607326 > 0.00017308741232706278` | +| acceptance | `L2-b3` | accepted/attempted = `75767/84003`; rate = `0.901955882528005` | outside v1 range `[0.1, 0.9]` | +| acceptance | `L3-b2` | accepted/attempted = `76215/83994`; rate = `0.9073862418744196` | outside v1 range `[0.1, 0.9]` | +| acceptance | `L3-b3` | accepted/attempted = `78601/84037`; rate = `0.9353142068374645` | outside v1 range `[0.1, 0.9]` | + +The v1 ED discrepancy is not reinterpreted here as a pass. The v1 record lacked +a stored per-measurement trace for every real-space Green-function component, +so its reported MCSE did not include a component-specific autocorrelation term. +This motivates a new prospective measurement and uncertainty protocol; it does +not prove in advance that the v1 discrepancy was only an error-bar artifact. + +Likewise, an upper acceptance-rate cutoff is not a correctness or mixing +criterion. High acceptance can be valid, but it also cannot establish +independence. v3 therefore uses acceptance only to detect a completely frozen +sampler and leaves convergence to R-hat and ESS. + +### Terminal v2 evidence motivating v3 + +The v2 executable commit is 5bf5905f6a08361cef2fba354dd2cc1be5b6b280. Its result root is tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-5bf5905/; gates/G1.json SHA256 is d865048b10a88b51d9caefff158c80961c19bce9b5b453c86074a20084c7db73. All 32 of 32 chains, all 8 ED fixtures, and all positivity checks completed; every cell had zero negative determinants and zero zero-weight failures. The frozen v2 verdict remains INCONCLUSIVE because exactly one ED leaf failed: L2-b3, momentum 1,0, one_body, with error 0.00018844035057746789, recorded MCSE 0.00003608558929286638, and allowance 0.00018042794646433192. + +A post-hoc Fourier reconstruction from the already stored real-space traces exactly reproduced the four momentum chain means and found tau_int=42.49--46.32, bulk ESS 10625.98, split R-hat 1.000223, and correlated MCSE 0.00036379896767951657. This diagnostic does not regrade v2. It prospectively motivates one universal v3 change: every complex ED-compared observable, in real and momentum space, receives stored traces and the same autocorrelation-aware MCSE rule. + +## 2. Frozen v3 protocol + +### 2.1 Protocol identity and independent randomness + +- `protocol_id = "issue121-triangular-large-lattice-v3"`. +- `seed_base = 321000000`. +- The chain rule is + `seed = 321000000 + 10000×L + 10×beta_index + chain_id`. +- `beta_index` remains `{1/2: 0, 1: 1, 2: 2, 4: 3}`. +- Each cell still has four chains: chain 0 and 1 cold, chain 2 and 3 hot, + with the same v1 initialization rule. +- No v1 or v2 RNG state, checkpoint, or chain output may be reused in v3. + +The new base is deliberately independent of the v1 base 121000000 and v2 base 221000000. Seeds may +not be replaced after inspecting a chain. + +### 2.2 G1 cells and fixed run length + +The G1 fixtures remain the periodic triangular tori `L=2, N=4` and +`L=3, N=9` at `beta ∈ {1/2, 1, 2, 4}`. Physics parameters, boundary +conditions, measured displacements, momentum labels, and ED oracle are unchanged. + +For every one of the 32 G1 chains, freeze: + +| Parameter | v3 value | +|---|---:| +| total CTQMC steps | `300000` | +| warmup steps included in the total | `30000` | +| post-warmup measurements per chain | `270000` | +| measurement interval | `1` | +| checkpoint interval | `30000` | +| rebuild interval | `128` | +| chains per cell | `4` | +| post-warmup measurements per cell | `1080000` | + +A checkpoint must bind the v3 protocol ID, seed, trace-storage mode, trace keys, +and trace lengths. Resume is allowed only from a valid v3 checkpoint for the +same chain. Missing, malformed, non-finite, or length-mismatched traces are a +hard validation failure. The fixed 300000-step result is terminal for v3; any +extension after seeing v3 output requires a new prospective protocol. + +### 2.3 Universal complex-observable traces and autocorrelation-aware MCSE + +For every `N≤9` chain and every preregistered displacement `(dx,dy)`, store +the complete post-warmup measurement trace of both real and imaginary components +of `real_space_green[dx,dy].one_body`. These traces must be present in the +checkpoint, serialized state, and final result without thinning or component +selection. + +For every preregistered momentum and each of one_body, density_raw, and density_mode, also store complete real and imaginary post-warmup traces under the same checkpoint and result binding. No complex ED comparison may fall back to a naive-only error merely because it is represented in momentum rather than real space. Scalar observables retain their already stored primary traces and existing autocorrelation-aware diagnostic path. + +For each component `a ∈ {Re, Im}`, compute the same rank-normalized split-chain +diagnostics used by v1: split R-hat, bulk ESS, tail ESS, and the per-original-chain +integrated autocorrelation estimates. Let `s_pooled,a` be the ordinary sample +standard deviation of all four post-warmup component traces pooled together. +Define + +`MCSE_corr,a = s_pooled,a / √max(1, ESS_bulk,a)`. + +For every complex ED-compared observable, define the three error estimates as: + +- `MCSE_correlated = max_a MCSE_corr,a`; +- `MCSE_between-chain = max_a [sd(chain means for a) / √4]`; +- `MCSE_naive = √(∑_c se_naive,c²) / 4`, retaining the v1 combined + per-chain naive estimator; +- `MCSE_final = max(MCSE_correlated, MCSE_between-chain, MCSE_naive)`. + +The ED comparison remains conservative and unchanged in form: + +- `error = max_a |QMC_a - ED_a|`; +- `allowance = max(5×MCSE_final, 1e-10)`; +- the observable passes exactly when `error ≤ allowance`. + +The gate output must record the real and imaginary component diagnostics and all +three MCSE candidates, so the selected maximum can be independently audited. +No trace, component, chain, or displacement may be excluded after inspection. + +### 2.4 Acceptance is only a non-freezing gate + +For G1, the G2 pilot, and G3 production, freeze the operational acceptance range +to `[0.05, 1.0]`, inclusive. The rate is `accepted / attempted`. A missing, +non-finite, or undefined rate, including `attempted = 0`, fails this operational +check. A rate below `0.05` means the sampler is operationally too frozen. + +There is no high-acceptance failure: any finite rate up to and including `1.0` +passes this check. In particular, high acceptance is not evidence of a bug and +is not evidence of independent samples. The pilot uses this same pass range; +there is no separate upper pass/fail target. + +The convergence gates remain hard and keep the v1 thresholds: + +- rank-normalized split `R-hat ≤ 1.01`; +- bulk ESS `≥ 1000`; +- tail ESS `≥ 400`. + +Acceptance cannot override an R-hat or ESS failure. The zero-weight, +negative-sign, fast-update residual, rebuild, provenance, and ED correctness +conditions also remain hard and unchanged. + +### 2.5 Downstream production schedule is unchanged + +Only the v3 clauses above change. The prospective production design remains: + +- G2 pilot cells: `(L,beta) = (4,1/2), (8,2), (12,4)`; +- G3 full grid: `L ∈ {4,6,8,12,16}` crossed with + `beta ∈ {1/2,1,2,4}`; +- four immutable-seed chains per cell, two cold and two hot; +- pilot-based resource capture and run-length freezing; +- equal extension of all four production chains under the existing + preregistered rule; +- gate order `G0 → G1 → G2 → G3 → G4` and all existing dependency rules. + +The Hamiltonian, local matrices, couplings, lattice geometry, boundary +conditions, `mu=0` interpretation limits, observables, full-grid cells, +positivity claim, and production resource policy are unchanged. + +## 3. Prospective decision rule and non-retroactivity + +v3 must write to a new result root and must never overwrite or edit the frozen +v1 root. Its index, executable commit, manifests, Slurm job IDs, completion +sentinels, gate files, and audit output must be recorded independently. + +This amendment is prospective and post-v1: + +1. It does not retroactively change any v1 threshold. +2. It does not delete or relabel any of the four v1 false leaf tests. +3. It does not reclassify the v1 `INCONCLUSIVE` audit as `PASS`. +4. It does not guarantee that v3 will pass. +5. If the longer independent run still violates ED, R-hat, ESS, positivity, + residual, provenance, or operational acceptance gates, that v3 outcome is + reported as observed. Thresholds, seeds, traces, and chain lengths may not be + retuned after inspection. + +A v3 pass would be new evidence under this frozen protocol only. It would not +make the v1 run a pass and would not by itself establish claims outside the +original fixed-`mu=0` benchmark scope. diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py index c88020d04..1f76cc640 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_ctqmc.py @@ -277,6 +277,8 @@ def __init__(self,store_real_space_traces:bool=False)->None: self.scalar={k:{"sum":0.0,"sum_sq":0.0} for k in self.KEYS} self.primary_traces={k:[] for k in self.KEYS} self.momentum:Dict[str,Any]={} + self.store_momentum_traces=self.store_real_space_traces + self.momentum_traces:Dict[str,Any]={} self.real_space:Dict[str,Any]={} self.real_space_traces:Dict[str,Any]={} @staticmethod @@ -295,6 +297,11 @@ def add(self,obs:Mapping[str,Any])->None: for momentum,values in obs["momenta"].items(): for name,pair in values.items(): self._add_complex(self.momentum,momentum,name,pair) + if self.store_momentum_traces: + trace=self.momentum_traces.setdefault(momentum,{}).setdefault( + name,{"real":[],"imag":[]}) + trace["real"].append(float(pair[0])) + trace["imag"].append(float(pair[1])) for displacement,pair in obs.get("real_space_green",{}).items(): self._add_complex(self.real_space,displacement,"one_body",pair) if self.store_real_space_traces: @@ -305,7 +312,9 @@ def add(self,obs:Mapping[str,Any])->None: def state(self)->Mapping[str,Any]: return {"count":self.count,"scalar":self.scalar, "primary_traces":self.primary_traces, - "momentum":self.momentum,"real_space_green":self.real_space, + "momentum":self.momentum,"momentum_traces":self.momentum_traces, + "store_momentum_traces":self.store_momentum_traces, + "real_space_green":self.real_space, "store_real_space_traces":self.store_real_space_traces, "real_space_traces":self.real_space_traces} @classmethod @@ -315,6 +324,8 @@ def from_state(cls,state:Mapping[str,Any], obj.scalar=state.get("scalar",obj.scalar) obj.primary_traces=state.get("primary_traces",obj.primary_traces) obj.momentum=state.get("momentum",{}) + obj.momentum_traces=state.get("momentum_traces",{}) + obj.store_momentum_traces=store_real_space_traces obj.real_space=state.get("real_space_green",{}) obj.real_space_traces=state.get("real_space_traces",{}) return obj @@ -352,7 +363,9 @@ def summary(self,beta:float,n_sites:int)->Mapping[str,Any]: return {"count":self.count,"scalar":scalar, "compressibility":compressibility, "primary_traces":self.primary_traces, - "momentum":momentum,"real_space_green":real_space, + "momentum":momentum,"momentum_traces":self.momentum_traces, + "store_momentum_traces":self.store_momentum_traces, + "real_space_green":real_space, "store_real_space_traces":self.store_real_space_traces, "real_space_traces":self.real_space_traces, "error_note":"naive iid errors; use primary_traces for tau_int/ESS/R-hat"} @@ -638,6 +651,24 @@ def load_checkpoint(self)->None: not isinstance(trace,list) or len(trace)!=expected_count for trace in traces.values()): raise ManifestError("checkpoint primary trace length mismatch") + expected_momentum={f"{kx},{ky}" for kx,ky in self.momenta} + momentum_traces=accumulator.get("momentum_traces") + store_momentum=self.geometry.n_sites<=9 + expected_names={"one_body","density_raw","density_mode"} + if accumulator.get("store_momentum_traces") is not store_momentum or not isinstance( + momentum_traces,Mapping): + raise ManifestError("checkpoint momentum trace mode mismatch") + if store_momentum: + if set(momentum_traces)!=expected_momentum or any( + not isinstance(item,Mapping) or set(item)!=expected_names or any( + not isinstance(trace,Mapping) or set(trace)!={"real","imag"} or any( + not isinstance(values,list) or len(values)!=expected_count + for values in trace.values()) + for trace in item.values()) + for item in momentum_traces.values()): + raise ManifestError("checkpoint momentum trace length mismatch") + elif momentum_traces: + raise ManifestError("unexpected checkpoint momentum traces") expected_real={f"{dx},{dy}" for dx,dy in self.displacements} real_traces=accumulator.get("real_space_traces") store_real=self.geometry.n_sites<=9 diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py index 877629c4e..56e6d5f2d 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_protocol.py @@ -23,7 +23,7 @@ from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple import numpy as np -PROTOCOL_ID = "issue121-triangular-large-lattice-v2" +PROTOCOL_ID = "issue121-triangular-large-lattice-v3" CORE_ALGORITHM_ID = "triangular-ab-ctqmc-direct-lu-v1" ED_ALGORITHM_ID = "triangular-ab-full-fock-ed-oracle-v1" BENCHMARK_ALGORITHM_ID = "rank3-vs-full-word-rebuild-v1" @@ -36,6 +36,7 @@ "large_lattice_kernel_benchmark.py", "test_large_lattice_kernel_benchmark.py", "g1_v2_preregistration.md", + "g1_v3_preregistration.md", ) SIZES = ((4,16),(6,36),(8,64),(12,144),(16,256)) BETAS = (0.5,1.0,2.0,4.0) @@ -131,7 +132,7 @@ def validate_meta(meta: Mapping[str,Any]) -> None: "document_type drift") _need(meta.get("issue")==121 and meta.get("team")=="Genshin_Impact", "issue/team drift") - _need(meta.get('amendment_document')=='g1_v2_preregistration.md', + _need(meta.get('amendment_document')=='g1_v3_preregistration.md', 'amendment document drift') rat=meta.get("ratification") _need(isinstance(rat,Mapping) and rat.get("required_before_any_compute") is True, @@ -171,7 +172,7 @@ def validate_meta(meta: Mapping[str,Any]) -> None: _need(isinstance(random,Mapping) and random.get("chains_per_cell")==4, "chain count drift") _need(random.get("seed_rule")== - "221000000 + 10000*L + 10*beta_index + chain_id","seed rule drift") + "321000000 + 10000*L + 10*beta_index + chain_id","seed rule drift") _need(random.get("beta_index")=={"1/2":0,"1":1,"2":2,"4":3}, "beta index drift") seen=tuple((x.get("chain_id"),x.get("start"),x.get("initial_order")) @@ -235,7 +236,7 @@ def validate_execution(execution: Mapping[str,Any]) -> None: "rotation asymmetry") def seed_for(L: int, beta_index: int, chain_id: int) -> int: - return 221000000+10000*L+10*beta_index+chain_id + return 321000000+10000*L+10*beta_index+chain_id def _unique(points: Iterable[Tuple[int,int]], L: int) -> List[List[int]]: out=[]; seen=set() @@ -706,6 +707,26 @@ def _load_chain(root: Path, entry: Mapping[str,Any]) -> Mapping[str,Any]: observables=result.get("observables",{}) count=observables.get("count",0) _need(isinstance(count,int) and count>0,"no measurements") + store_momentum=entry["N"]<=9 + momentum_traces=observables.get("momentum_traces") + expected_momentum={f"{x},{y}" for x,y in manifest["measurements"]["momenta"]} + expected_names={"one_body","density_raw","density_mode"} + _need(observables.get("store_momentum_traces") is store_momentum and + isinstance(momentum_traces,Mapping),"result momentum trace mode") + if store_momentum: + _need(set(momentum_traces)==expected_momentum,"result momentum trace set") + for key,item in momentum_traces.items(): + _need(isinstance(item,Mapping) and set(item)==expected_names, + f"result momentum trace names: {key}") + for name,trace in item.items(): + _need(isinstance(trace,Mapping) and set(trace)=={"real","imag"}, + f"result momentum trace components: {key}/{name}") + for component,values in trace.items(): + _need(isinstance(values,list) and len(values)==count and + all(math.isfinite(float(value)) for value in values), + f"result momentum trace length: {key}/{name}/{component}") + else: + _need(not momentum_traces,"unexpected result momentum traces") store_real=entry["N"]<=9 real_traces=observables.get("real_space_traces") expected_real={f"{x},{y}" for x,y in manifest["measurements"]["displacements"]} @@ -745,13 +766,29 @@ def _aggregate_complex(results: Sequence[Mapping[str,Any]], section: str, return out def _momentum(results: Sequence[Mapping[str,Any]]) -> Mapping[str,Any]: - out=_aggregate_complex(results,"momentum", - ("one_body","density_raw","density_mode")) + names=("one_body","density_raw","density_mode") + out=_aggregate_complex(results,"momentum",names) for momentum in out: raw=out[momentum]["density_raw"]["mean"] mode=out[momentum]["density_mode"]["mean"] out[momentum]["density_connected_from_means"]=[ raw[0]-mode[0]**2-mode[1]**2,raw[1]] + if not bool(results[0]["observables"]["store_momentum_traces"]): + return out + for momentum,item in out.items(): + for name in names: + diagnostics={} + for component in ("real","imag"): + chains=[] + for result in results: + traces=result["observables"]["momentum_traces"] + _need(momentum in traces and name in traces[momentum] and + component in traces[momentum][name], + f"missing momentum trace: {momentum}/{name}/{component}") + chains.append([float(value) for value in + traces[momentum][name][component]]) + diagnostics[component]=_correlated_trace_diagnostics(chains) + item[name]["correlated_diagnostics"]=diagnostics return out def _correlated_trace_diagnostics( @@ -1367,25 +1404,25 @@ def audit(root: Path, stage: str, write_complete: bool=False) -> Mapping[str,Any name="G3"; arange=thresholds["full_acceptance_hard_range"] else: raise ProtocolError("bad audit stage") - grouped={}; metadata={}; cell_entries={} + grouped_entries={} for entry in entries: - grouped.setdefault(entry["cell_id"],[]).append(_load_chain(root,entry)) - metadata.setdefault(entry["cell_id"],entry) - cell_entries.setdefault(entry["cell_id"],[]).append(entry) + grouped_entries.setdefault(entry["cell_id"],[]).append(entry) cells={} - for cell_id,results in grouped.items(): - first=metadata[cell_id] + for cell_id,entries_for_cell in grouped_entries.items(): + first=entries_for_cell[0] + results=[_load_chain(root,entry) for entry in entries_for_cell] cell=summarize_cell(results,float(first["beta"]),int(first["N"]), thresholds,arange) if stage=="g1": exact_path=root/"exact"/"g1"/f"{cell_id}.json" _need(exact_path.is_file(),f"missing ED {exact_path}") exact=load_json(exact_path) - validate_ed_binding(root,cell_entries[cell_id],exact) + validate_ed_binding(root,entries_for_cell,exact) cell["exact_ed_sha256"]=sha_file(exact_path) cell["ed"]=compare_ed(cell,exact,float(thresholds["ed_z_score_max"])) cell["pass"]=cell["pass"] and cell["ed"]["pass"] cells[cell_id]=cell + del results chain_cells_pass=bool(cells) and all(x["pass"] for x in cells.values()) passed=chain_cells_pass; limits=[]; benchmark=None; resources=None if stage=="pilot": diff --git a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json index 345809115..25d4da95a 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json +++ b/tracks/qmc/solutions/Genshin_Impact-121/large_lattice_run.json @@ -3,7 +3,7 @@ "document_type": "preregistered_large_lattice_run", "issue": 121, "team": "Genshin_Impact", - "amendment_document": "g1_v2_preregistration.md", + "amendment_document": "g1_v3_preregistration.md", "status": "ratified_setup_frozen_pending_gates", "ratification": { "required_before_any_compute": true, @@ -62,7 +62,7 @@ "randomness": { "engine": "NumPy PCG64DXSM; exact package version frozen in run snapshot", "chains_per_cell": 4, - "seed_rule": "221000000 + 10000*L + 10*beta_index + chain_id", + "seed_rule": "321000000 + 10000*L + 10*beta_index + chain_id", "beta_index": {"1/2": 0, "1": 1, "2": 2, "4": 3}, "chains": [ {"chain_id": 0, "start": "cold", "initial_order": 0}, diff --git a/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html b/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html new file mode 100644 index 000000000..01ba45ba5 --- /dev/null +++ b/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html @@ -0,0 +1,102 @@ + + + + + +二维多面体无符号费米子系统|Genshin_Impact + + +
+
+
QuantumBFS issue 121 · Team Genshin_Impact
+

从一个 3×3 李代数生成元,到二维无符号费米子多体系统

+

这是一个把多面体收缩、费米子 Fock 空间、S₃ 群平均和连续时间行列式蒙特卡洛连接起来的模型。它已经不再是孤立三体玩具:局域相互作用铺满周期三角晶格,并在任意系统尺度上保留严格正的配置权重。

+二维三角晶格无自旋费米子粒子数守恒相互作用det(I+T)>0 +
+
+

一眼看懂:我们构造了什么?

+

每个格点只有一个费米子轨道。每个向上、向下的基本三角形都承载 A/B 两类局域顶点;不同三角形共享格点,因此体系是一个真正的二维、重叠、广延多体系统。

+
+
+ + + + +橙色:A 型三角形顶点绿色:B 型三角形顶点 + +

示意图只画出一条条带;实际体系在两个原胞方向周期延拓。L×L 晶格有 N=L² 个格点和 2N 个相互重叠的三角形顶点。

+
+
+

局域自由度

1 orbital / site

无自旋、粒子数守恒费米子。Fock 空间维数随 N 变为 2ᴺ。

+
+
+

二维广延性

2N triangle vertices

每个格点同时属于多个局域项,不能分解成互不相干的三体块。

+
+
+

验证尺度

N=256

预注册完整网格到 L=16;小尺度 ED 使用 N=4、9。

+
+
+
+
+

数学核心:为什么每个蒙特卡洛权重都为正?

+
+

生成元家族

A(ε,κ) = [[−1−ε−κ, 1, −ε],
          [0, −1−κ, 1],
          [2, 0, −2−κ]]

B = S A S, S = diag(1,1,−1)
再取 A、B 的全部 S₃ 置换轨道。
+

开放参数区域

ε > 0, κ > 0,
40ε + 59κ < 2

μ∞(X) = −κ < 0
∥exp(sX)∥∞ ≤ exp(−κs) < 1

这不是某一组偶然数值,而是一个非零体积的连续参数区域。

+

从李代数到任意深度行列式

X₁,…,Xₘ 属于生成元集合Bₜ=exp(sXₜ)T=Bₘ⋯B₁ρ(T)<1det(I+T)>0

实特征值满足 1+λ>0;复特征值成共轭对,贡献 |1+λ|²。局域顶点任意重叠时,最后触碰每一行的因子仍给出同一个 ∞-范数收缩界,因此证明不依赖格点数和展开阶数。

+

条件数也被控制

q = exp(−κs) = exp(−1/200)
∥(I+T)⁻¹∥∞ ≤ 1/(1−q)
cond∞(I+T) ≤ (1+q)/(1−q) ≈ 400
+

它不属于什么

精确证书排除了共同二次型收缩度量;生成元张成 M₃(ℝ),并与所比较的固定、同维复 CAR/Wei 类分离。新意不是发明收缩半群,而是把普通 ℓ∞ 多面体证书、真实单味费米子、S₃ 厄米化与任意重叠组合起来。

+
+
+
+

物理哈密顿量:为什么它确实有相互作用?

+

单个高斯顶点 exp[s c†Xc] 可以不是厄米的;对 S₃ 的六个置换做等权平均后,局域算符 Mₓ 变成厄米。把 I−Mₓ 铺到所有三角形得到 H̄。

+
+
Mₓ(s) = (1/6) ∑σ∈S₃ exp[s c†(Pσ X Pσᵀ)c]

H̄ = ∑Δ,X gΔ,X [ I − MΔ,X ]

TrFock ∏ₜ exp(c†Aₜc) = det(I + ∏ₜ exp(Aₜ))
+

单体部分

包含数密度 N 与对称跃迁 K,描述粒子在三角形内部传播。

−0.0199 K coefficient
+

二体部分

包含 Q₂ 与 Pₛ†Pₛ 等四费米子项;它们不能被任何最佳二次哈密顿量完全吸收。

2.50% quadratic residual
+

三体部分

还存在 n₁n₂n₃ 项,但整个二维模型不是孤立三体系统:这些局域项在共享格点上广泛重叠。

6.81×10⁻⁴
+
+
+
+

数值证据:哪些已经通过,哪些还没有?

+
+

v2 独立链

32/32

每条 300000 步,四链冷热启动,全部产生哈希绑定完成哨兵。

+

权重正性

8/8

负行列式 0;零权重 0。

+

严格门状态

INCONCLUSIVE

仅一个动量 one-body 叶节点略超旧式误差阈值。

+

误差条为何必须包含自相关?

v2 naive MCSE由轨迹重构的相关 MCSE观测误差 1.884×10⁻⁴3.609×10⁻⁵3.638×10⁻⁴

唯一失败:L=2、β=4、q=(1,0) 的 one-body。v2 冻结规则只给实空间量使用相关 MCSE,所以不能事后改判;但完整实空间轨迹可精确傅里叶重构该动量轨迹,得到 τint≈42.5–46.3。这直接促成 v3 的统一误差协议。

+

旧偏差已消失

v1 的 L=3、β=1/2、G(1,0):

2.97×10⁻⁶

v2 绝对误差,远小于允许值 2.83×10⁻⁴。

+

严格状态表

协议数据正性ED/统计结论
v1 · commit 382e64e32×30000 steps8/8 PASS1 个实空间偏差;3 个高接受率门INCONCLUSIVE
v2 · commit 5bf590532×300000 steps8/8 PASS旧偏差通过;1 个动量量漏计相关误差INCONCLUSIVE
v3 · 全观测量相关误差全新种子 321000000+待运行所有复观测量统一 R̂/ESS/τint前瞻验证
+
+
+
+

从小体系走向大体系

+
+
L=4L=6L=8L=12L=16N=16N=36N=64N=144N=256

完整生产网格还交叉 β∈{1/2,1,2,4},每格点四条固定种子链。必须依次通过 G1 小体系正确性、G2 资源与自相关 pilot、G3 全网格、G4 provenance 审计。

+

为什么 QMC 有意义?

ED 的 Hilbert 空间维数是 2ᴺ,N=256 不可能直接对角化;行列式 QMC 只操作 N×N 单粒子矩阵,才有机会研究有限温度大系统。

+
G0 代数与代码G1 N=4,9 对 EDG2 N=16,64,144 pilotG3 N≤256 全网格G4 独立 provenance
+
+
+
+

物理解释与诚实边界

+
+

已经成立

  • 一个开放参数区域,而非孤立 A 数值。
  • 任意深度、任意局域重叠下 det(I+T)>0。
  • 二维三角晶格上的广延、相互作用、粒子数守恒模型。
  • 连续时间高斯顶点展开可直接用于行列式 QMC。
  • N=4、9 上所有配置均无负权重。
+

尚未成立

  • μ=0 的零温基态是真空;非平凡有限密度仍未解决。
  • 尚无快速混合证明。
  • v2 G1 严格状态仍为 INCONCLUSIVE。
  • N=256 的完整生产数据尚未完成。
  • 没有证明文献优先权或达到论文接收标准。
+
最准确的一句话:我们已经找到并实现了一个数学上严格无符号、物理上真正二维且相互作用的有限温度费米子系统;当前最后障碍不是符号问题,而是把所有观测量的蒙特卡洛自相关误差统一纳入前瞻验证,并通过大尺度性能门。
+
+
+
+

研究时间线

+

解析构造

找到 A/B 两轨道多面体收缩类、开放参数锥、任意重叠最后触碰引理与条件数界。

+

物理化

通过 S₃ 群平均恢复厄米性,Fock 展开出现不可约四费米子和三体局域项。

+

v1:发现误差条缺口

正性完全通过,但实空间 G(1,0) 的 naive MCSE 低估且高接受率被误当成失败。

+

v2:实空间修复成功

旧偏差消失;一个傅里叶后的动量观测量暴露同一统计缺口。

+

v3:统一全观测量协议

全新随机种子;所有 ED 复观测量保存逐测量实/虚轨迹,并统一采用相关、链间、naive 三者最大 MCSE。

+
+
+
+

复现入口

  • main_theorem.md:开放 A/B 家族、任意深度证明与分离证书。
  • physical_realization.md:S₃ twirl、局域相互作用与连续时间展开。
  • g1_v2_preregistration.md:v1→v2 的不可追溯修正规则。
  • g1_v3_preregistration.md:v2→v3 的全观测量相关误差规则。
  • large_lattice_ctqmc.py:密集矩阵 CTQMC 参考实现。
  • large_lattice_protocol.py:哈希绑定、R̂/ESS/τint、ED 和 Slurm gates。
  • tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-5bf5905/gates/G1.json:v2 不可变审计记录。
+
Genshin_Impact · QuantumBFS issue #121
报告生成于 2026-07-30,证据截至 commit 5bf5905 与 v2 G1 SHA256 d865048b10a88b51d9caefff158c80961c19bce9b5b453c86074a20084c7db73。本文区分解析定理、已完成数值证据、事后诊断与尚未完成的前瞻验证。
+
diff --git a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py index 83c5fe9d6..104cf4896 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py +++ b/tracks/qmc/solutions/Genshin_Impact-121/test_large_lattice_protocol.py @@ -132,7 +132,7 @@ def test_materialization_cardinality_hashes_and_frozen_manifests( ] assert len(production) == 4 assert [entry["seed"] for entry in production] == [ - 221060020, 221060021, 221060022, 221060023 + 321060020, 321060021, 321060022, 321060023 ] manifests = [ protocol.load_json(root / entry["manifest"]) @@ -270,6 +270,8 @@ def fake_result(offset: float) -> dict: "count": length, "primary_traces": traces, "momentum": {}, + "store_momentum_traces": True, + "momentum_traces": {}, "store_real_space_traces": True, "real_space_traces": {}, }, @@ -472,6 +474,14 @@ def _write_chain_fixture(root: Path, entry: dict) -> dict: "measurements": manifest["measurements"], "observables": { "count": 1, + "store_momentum_traces": entry["N"] <= 9, + "momentum_traces": { + f"{kx},{ky}": { + name: {"real": [0.0], "imag": [0.0]} + for name in ("one_body", "density_raw", "density_mode") + } + for kx, ky in manifest["measurements"]["momenta"] + } if entry["N"] <= 9 else {}, "store_real_space_traces": entry["N"] <= 9, "real_space_traces": { f"{dx},{dy}": {"real": [0.0], "imag": [0.0]} @@ -1037,3 +1047,31 @@ def test_real_space_without_trace_storage_keeps_production_summary() -> None: sampled = protocol._real_space(results) assert sampled["1,0"]["one_body"]["mean"] == pytest.approx([0.25, 0.0]) assert "correlated_diagnostics" not in sampled["1,0"]["one_body"] + + +def test_autocorrelated_momentum_trace_inflates_mcse() -> None: + block_trace = np.tile(np.repeat([-1.0, 1.0], 16), 8) + results = [fake_result(offset) for offset in (0.0, 0.2, 0.4, 0.6)] + for result in results: + summary = { + name: { + "mean": [0.0, 0.0], + "naive_stderr_abs": float( + np.std(block_trace, ddof=1) / math.sqrt(len(block_trace)) + ), + } + for name in ("one_body", "density_raw", "density_mode") + } + result["observables"]["momentum"] = {"1,0": summary} + result["observables"]["momentum_traces"] = { + "1,0": { + name: {"real": block_trace.tolist(), + "imag": [0.0] * len(block_trace)} + for name in ("one_body", "density_raw", "density_mode") + } + } + result["observables"]["count"] = len(block_trace) + sampled = protocol._momentum(results)["1,0"]["one_body"] + components = protocol._complex_mcse_components(sampled) + assert components["correlated"] > components["naive"] + assert sampled["correlated_diagnostics"]["real"]["bulk_ess"] > 0 From ec62842f83575b7af6700e7cf7a32fe1c0e88075 Mon Sep 17 00:00:00 2001 From: Kexiang Mao Date: Thu, 30 Jul 2026 20:44:52 +0800 Subject: [PATCH 13/13] qmc: report v3 G1 pass and G2 mixing limit --- .../system_introduction_zh.html | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html b/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html index 01ba45ba5..0f5cbdd5c 100644 --- a/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html +++ b/tracks/qmc/solutions/Genshin_Impact-121/system_introduction_zh.html @@ -61,30 +61,30 @@

物理哈密顿量:为什么它确实有相互作用?

-

数值证据:哪些已经通过,哪些还没有?

+

最终数值证据:正性通过,混合仍是瓶颈

-

v2 独立链

32/32

每条 300000 步,四链冷热启动,全部产生哈希绑定完成哨兵。

-

权重正性

8/8

负行列式 0;零权重 0。

-

严格门状态

INCONCLUSIVE

仅一个动量 one-body 叶节点略超旧式误差阈值。

+

v3 独立链

32/32

每条 300000 步,四链冷热启动;所有 ED 复观测量保存逐测量实/虚轨迹。

+

G1 权重正性

8/8

负行列式 0;零权重 0;零行列式失败 0。

+

严格门状态

G1 PASS

160/160 个 ED 比较全部通过;下游 G2 因大尺度慢混合为 INCONCLUSIVE。

误差条为何必须包含自相关?

v2 naive MCSE由轨迹重构的相关 MCSE观测误差 1.884×10⁻⁴3.609×10⁻⁵3.638×10⁻⁴

唯一失败:L=2、β=4、q=(1,0) 的 one-body。v2 冻结规则只给实空间量使用相关 MCSE,所以不能事后改判;但完整实空间轨迹可精确傅里叶重构该动量轨迹,得到 τint≈42.5–46.3。这直接促成 v3 的统一误差协议。

-

旧偏差已消失

v1 的 L=3、β=1/2、G(1,0):

2.97×10⁻⁶

v2 绝对误差,远小于允许值 2.83×10⁻⁴。

-

严格状态表

协议数据正性ED/统计结论
v1 · commit 382e64e32×30000 steps8/8 PASS1 个实空间偏差;3 个高接受率门INCONCLUSIVE
v2 · commit 5bf590532×300000 steps8/8 PASS旧偏差通过;1 个动量量漏计相关误差INCONCLUSIVE
v3 · 全观测量相关误差全新种子 321000000+待运行所有复观测量统一 R̂/ESS/τint前瞻验证
+

v3 最坏统计量

跨全部 G1 观测量:

R̂=1.0064

min bulk ESS=1127.7;min tail ESS=3351.0,均越过冻结门槛。

+

严格状态表

阶段数据正性ED/统计结论
v1 · 382e64e32×30000 steps8/8 PASS1 个实空间偏差;3 个高接受率门INCONCLUSIVE
v2 · 5bf590532×300000 steps8/8 PASS旧偏差通过;1 个动量量漏计相关误差INCONCLUSIVE
v3 G1 · a6b091c32×300000 steps8/8 PASS160/160 ED;R̂/ESS 全通过PASS
v3 G2 pilotN=16,64,144;12×100000 steps3/3 PASSL=8,12 冻结长度下混合不足INCONCLUSIVE

从小体系走向大体系

-
L=4L=6L=8L=12L=16N=16N=36N=64N=144N=256

完整生产网格还交叉 β∈{1/2,1,2,4},每格点四条固定种子链。必须依次通过 G1 小体系正确性、G2 资源与自相关 pilot、G3 全网格、G4 provenance 审计。

-

为什么 QMC 有意义?

ED 的 Hilbert 空间维数是 2ᴺ,N=256 不可能直接对角化;行列式 QMC 只操作 N×N 单粒子矩阵,才有机会研究有限温度大系统。

-
G0 代数与代码G1 N=4,9 对 EDG2 N=16,64,144 pilotG3 N≤256 全网格G4 独立 provenance
+
L=4L=6L=8L=12L=16N=16N=36N=64N=144N=256

G2 已实际运行 N=16、64、144:三格正性全部通过;N=16 收敛通过,N=64、144 暴露长自相关。完整 N≤256 网格被依赖门正确阻断,没有把未收敛数据包装成结果。

+

N=256 内核

34.1×

秩 3 插入相对完整重构的中位加速;删除为 31.2×,误差小于 7.8×10⁻¹⁵,fallback 为 0。

N=256 资源投影

396 s

每条 100000 步链约 104 MiB;这是 pilot 外推,不是完整生产结果。

真正的瓶颈

L=12、β=4 的最坏 τint≈408 次测量;冻结 warmup=10000 步,而 50τ 规则要求约 204045 步。最坏 R̂=1.103、bulk ESS=130.8,所以 G2 必须保持 INCONCLUSIVE。

+
G0 PASSG1 PASS · N=4,9G2 INCONCLUSIVE · N=16,64,144G3/G4 正确阻断

物理解释与诚实边界

-

已经成立

  • 一个开放参数区域,而非孤立 A 数值。
  • 任意深度、任意局域重叠下 det(I+T)>0。
  • 二维三角晶格上的广延、相互作用、粒子数守恒模型。
  • 连续时间高斯顶点展开可直接用于行列式 QMC。
  • N=4、9 上所有配置均无负权重。
-

尚未成立

  • μ=0 的零温基态是真空;非平凡有限密度仍未解决。
  • 尚无快速混合证明。
  • v2 G1 严格状态仍为 INCONCLUSIVE。
  • N=256 的完整生产数据尚未完成。
  • 没有证明文献优先权或达到论文接收标准。
-
最准确的一句话:我们已经找到并实现了一个数学上严格无符号、物理上真正二维且相互作用的有限温度费米子系统;当前最后障碍不是符号问题,而是把所有观测量的蒙特卡洛自相关误差统一纳入前瞻验证,并通过大尺度性能门。
+

已经成立

  • 一个开放参数区域,而非孤立 A 数值。
  • 任意深度、任意局域重叠下 det(I+T)>0。
  • 二维三角晶格上的广延、相互作用、粒子数守恒模型。
  • v3 G1:32 条长链、160 个 ED 比较严格通过。
  • 大系统 pilot 到 N=144 仍无负权重;N=256 更新内核正确且有 31–34× 加速。
+

尚未成立

  • μ=0 的零温基态是真空;非平凡有限密度仍未解决。
  • 没有快速混合证明;L=8、12 pilot 已观测到长自相关。
  • G2 严格状态为 INCONCLUSIVE,G3/G4 未运行。
  • N=256 目前只有内核与资源外推,没有完整生产观测量。
  • 没有证明文献优先权或达到论文接收标准。
+
最准确的一句话:解析上,我们得到一个严格无符号、真正二维且相互作用的有限温度费米子系统;数值上,小体系 ED 门已完整通过且正性扩展到 N=144 pilot,N=256 内核可行,但大尺度慢混合仍阻止完整生产结论。
@@ -93,10 +93,10 @@

研究时间线

物理化

通过 S₃ 群平均恢复厄米性,Fock 展开出现不可约四费米子和三体局域项。

v1:发现误差条缺口

正性完全通过,但实空间 G(1,0) 的 naive MCSE 低估且高接受率被误当成失败。

v2:实空间修复成功

旧偏差消失;一个傅里叶后的动量观测量暴露同一统计缺口。

-

v3:统一全观测量协议

全新随机种子;所有 ED 复观测量保存逐测量实/虚轨迹,并统一采用相关、链间、naive 三者最大 MCSE。

+

v3:G1 全观测量严格通过

全新随机种子;160 个 ED 复观测量采用相关、链间、naive 三者最大 MCSE,false 叶节点为 0。

G2:大系统暴露慢混合

N=16、64、144 权重正性继续通过;L=8、12 的 R̂/ESS 与 50τ warmup 门未通过,因此生产网格被阻断。

-

复现入口

  • main_theorem.md:开放 A/B 家族、任意深度证明与分离证书。
  • physical_realization.md:S₃ twirl、局域相互作用与连续时间展开。
  • g1_v2_preregistration.md:v1→v2 的不可追溯修正规则。
  • g1_v3_preregistration.md:v2→v3 的全观测量相关误差规则。
  • large_lattice_ctqmc.py:密集矩阵 CTQMC 参考实现。
  • large_lattice_protocol.py:哈希绑定、R̂/ESS/τint、ED 和 Slurm gates。
  • tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-5bf5905/gates/G1.json:v2 不可变审计记录。
-
Genshin_Impact · QuantumBFS issue #121
报告生成于 2026-07-30,证据截至 commit 5bf5905 与 v2 G1 SHA256 d865048b10a88b51d9caefff158c80961c19bce9b5b453c86074a20084c7db73。本文区分解析定理、已完成数值证据、事后诊断与尚未完成的前瞻验证。
+

复现入口

  • main_theorem.md:开放 A/B 家族、任意深度证明与分离证书。
  • physical_realization.md:S₃ twirl、局域相互作用与连续时间展开。
  • g1_v3_preregistration.md:v2→v3 的全观测量相关误差规则。
  • large_lattice_ctqmc.py:密集矩阵 CTQMC 参考实现。
  • large_lattice_protocol.py:哈希绑定、R̂/ESS/τint、ED 和 Slurm gates。
  • tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-a6b091c/gates/G1.json:v3 G1 PASS 不可变审计。
  • tracks/qmc/results/Genshin_Impact-121/20260730-large-lattice-a6b091c/gates/G2.json:G2 INCONCLUSIVE 与资源/混合证据。
+