========================================
Crystallization of the Relativistic Hamiltonian in Neural Networks: A Middle State Between the Strassen Diamond and the Hamiltonian Topological Insulator
I present the experimental demonstration that a neural network can crystallize a relativistic quantum structure. Specifically, I trained a spectral network to learn the Dirac equation dynamics for a 4‑component spinor, and through a five‑phase crystallization protocol, I induced a polycrystalline state that is neither a perfect algorithmic crystal nor a topological insulator. This chapter documents what lies between.
The Strassen work (Chapter 1) demonstrated perfect crystallization: discrete integer weights, zero discretization margin, and a structure that expands to arbitrary dimensions. The Hamiltonian HPU‑Core work demonstrated topological crystallization: non‑zero Berry phases, winding numbers, and robustness without discretization. Here, I show what happens in the middle ground. The Dirac crystal is polycrystalline: it has high purity (α = 12.61) but non‑zero discretization margin (δ = 3.33 × 10⁻⁶), and the Berry phase is trivial (γ ≈ 0).
This intermediate state is not a failure of either protocol. It is a distinct phase in the algorithmic phase diagram, one that I hypothesize represents the natural endpoint when learning continuous dynamics rather than discrete algorithms or topological invariants.
- Introduction: The Phase Diagram Revisited
In the introduction to this book, I presented a phase diagram with four identified phases: cold glass, discrete glass, topological glass, and tempered glass. After completing the Dirac experiments, I now see that this classification was incomplete. The experiments reveal at least two additional phases:
- Perfect Crystal (Optical Crystal): The Strassen case. Zero discretization margin, integer weights, perfect scale expansion. This is the limit of algorithmic learning.
- Topological Insulator (Hamiltonian Crystal): The HPU‑Core case. Non‑trivial Berry phase, non‑trivial winding number, zero discretization margin achieved through topological protection rather than discretization.
- Polycrystalline: The Dirac case. High purity but non‑zero discretization margin. Trivial Berry phase. A phase that has crystallized but not into a single crystal domain.
The central question of this chapter is: why does the Dirac equation land in this intermediate phase?
- The Dirac Equation: Physical and Mathematical Foundation
Before presenting the experiments, I must establish the mathematical foundation. Nothing in this work is metaphor. Every equation I apply to the neural network has a precise physical meaning, and every metric I compute is derived from that mathematics.
The Dirac equation describes relativistic quantum mechanics for spin‑½ particles. In its standard form:
iℏγᵘ ∂ᵘ ψ − mcψ = 0
where:
- ψ is a 4‑component spinor, representing particle and antiparticle states
- γᵘ are the 4×4 Dirac gamma matrices
- m is the particle mass
- c is the speed of light
- ℏ is the reduced Planck constant
In natural units (ℏ = c = 1), this simplifies to:
iγᵘ ∂ᵘ ψ = mψ
To work with time evolution, I rearrange this as a Hamiltonian equation:
H_D ψ = i ∂_t ψ
where the Dirac Hamiltonian is:
H_D = c α·p + β mc²
Here:
- p = −iℏ∇ is the momentum operator
- αⁱ = γ⁰ γⁱ are the alpha matrices
- β = γ⁰ is the beta matrix
The gamma matrices are not arbitrary. They satisfy the Clifford algebra:
{γᵘ, γᵛ} = 2gᵘᵛ I₄
In the Dirac (standard) representation:
γ⁰ = β = ⎛ I₂ 0 ⎞ ⎝ 0 −I₂ ⎠
γⁱ = ⎛ 0 σⁱ ⎞ , i = 1,2,3 ⎝ −σⁱ 0 ⎠
where σⁱ are the Pauli matrices:
σ¹ = ⎛0 1⎞ , σ² = ⎛0 −i⎞ , σ³ = ⎛1 0⎞ ⎝1 0⎠ ⎝i 0⎠ ⎝0 −1⎠
These matrices have specific physical interpretations:
- γ⁰ distinguishes between particle and antiparticle components
- γⁱ couple to spatial momentum
- The 4‑component structure encodes spin and particle‑antiparticle duality
When I ask a neural network to learn Dirac dynamics, I am asking it to learn an operator that has very specific mathematical properties:
- Linearity in spinor components: The Hamiltonian acts linearly on the 4‑component spinor
- Symplectic structure: The evolution preserves the norm and certain inner products
- Relativistic dispersion: The energy‑momentum relation is E² = p²c² + m²c⁴
- Spin‑orbit coupling: The angular momentum operator must be properly constructed
These are not decorative properties. They are the physical content of the equation. If the network learns the dynamics correctly, it must learn an operator that preserves these structures.
- The Network Architecture
I designed the network architecture to respect the mathematical structure of the Dirac equation while leaving room for learning.
The network uses spectral (Fourier) convolution layers. A spectral layer operates in frequency space:
-
Input: A tensor x of shape [C, H, W] (channels, height, width)
-
Forward pass:
- Compute the 2D Fourier transform: x̂ = F₂D[x]
- Apply a learnable complex kernel: ŷ = x̂ ⊙ K where K = K_real + i K_imag is the learnable spectral kernel and ⊙ denotes element‑wise multiplication.
- Apply the inverse Fourier transform: y = F₂D⁻¹[ŷ]
The Dirac equation involves momentum operators. In position space, momentum is a derivative operator:
p̂_x = −iℏ ∂/∂x
In Fourier space, derivatives become multiplications:
F[ ∂ψ/∂x ] = i k_x ψ̂
Therefore, a spectral layer can naturally represent momentum operators. The learnable kernel K can encode the alpha matrices and the mass term.
The full architecture is:
- Input: 8 channels (4 spinor components × 2 for real/imaginary parts)
- ↓
- Input projection: 8 → 32 channels (1×1 convolution)
- ↓
- Expansion: 32 → 64 channels (1×1 convolution)
- ↓
- Spectral layer 1: 64 channels, operates in Fourier space
- ↓
- Spectral layer 2: 64 channels, operates in Fourier space
- ↓
- Contraction: 64 → 32 channels (1×1 convolution)
- ↓
- Output projection: 32 → 8 channels (1×1 convolution)
- ↓
- Output: 8 channels (predicted evolved spinor)
The network takes an initial spinor state and predicts its time evolution after a small time step Δt.
The training objective is simple mean‑squared error:
ℒ = (1/N) Σᵢ ||ψ_pred⁽ⁱ⁾ − ψ_true⁽ⁱ⁾||²
where ψ_true is computed by applying the analytical Dirac Hamiltonian:
ψ_true(t + Δt) ≈ ψ(t) − i Δt H_D ψ(t)
This is a first‑order approximation to the time evolution operator U(t) = exp(−i H t).
- The Five‑Phase Crystallization Protocol
I developed a five‑phase protocol specifically for the Dirac case, adapting what I learned from Strassen and HPU‑Core.
The batch size effect observed in Strassen is not unique to that problem. I found similar effects in the Dirac case. Phase 1 consists of short training runs with different batch sizes to identify which batch size produces the most favorable gradient covariance geometry.
Protocol:
For each candidate batch size B ∈ {8, 16, 32, 64}:
- Train for 30 epochs
- Measure the condition number κ of the gradient covariance matrix
- Measure the effective temperature T_eff
Select the batch size with κ closest to 1 and the lowest T_eff.
Mathematical foundation for κ:
The gradient covariance matrix is defined as: 5.2 Interpretation of Alpha The purity α=12.61 is high. In the Strassen case, α>10 indicates a "perfect crystal." But here, the perfect crystal label is misleading.
In Strassen, high α correlated with δ<0.01 . The weights were both aligned and close to integers. In the Dirac case, high α does not correlate with δ in the same way.
The high α tells us the weights have aligned into a low-dimensional manifold. But the non-zero (albeit tiny) δ tells us this manifold does not pass through the integer lattice.
5.3 Interpretation of Delta The discretization margin δ=3.33×10 −6
is extremely small. This is 5 orders of magnitude smaller than the Strassen threshold of 0.1.
But—and this is crucial—it is not zero.
For Strassen, I defined success as δ<0.1 because the weights could be rounded to integers. With δ=3.33×10 −6
, the weights could certainly be rounded. But what integers would they round to?
The answer: arbitrary integers. The weights are nearly constant, but they are not close to any physically meaningful integers like {-1, 0, 1} in the Strassen case.
5.4 Interpretation of Ricci Scalar The Ricci scalar R=8.6×10 15
is extremely large and positive. This requires explanation.
Mathematical foundation for Ricci scalar:
In differential geometry, the Ricci scalar measures the curvature of a manifold. On a sphere, R>0 . On a flat plane, R=0 . On a saddle, R<0 .
To apply this to a neural network, I treat the weight space as a Riemannian manifold with metric:
where
are the flattened weight parameters.
The Ricci scalar
where
Interpretation:
A large positive Ricci scalar indicates the weight manifold is highly curved—like a very small sphere. The weight space has collapsed into a tiny region.
This is consistent with crystallization. In a crystal, atoms are locked into rigid positions. In the neural network, large positive R indicates the weights have similarly locked into a rigid configuration.
5.5 The Phase Classification All 11 checkpoints are classified as "Polycrystalline." The classification algorithm uses the following logic:
if delta < DELTA_CRYSTAL_THRESHOLD and kappa < KAPPA_CRYSTAL_THRESHOLD: if temp < TEMPERATURE_CRYSTAL_THRESHOLD: return "Perfect Crystal" else: return "Polycrystalline" elif delta < DELTA_CRYSTAL_THRESHOLD and kappa >= KAPPA_CRYSTAL_THRESHOLD: return "Polycrystalline" elif delta >= DELTA_GLASS_THRESHOLD and temp < TEMPERATURE_CRYSTAL_THRESHOLD: return "Cold Glass" elif kappa > 1e6: return "Amorphous Glass" elif alpha > ALPHA_CRYSTAL_THRESHOLD: return "Topological Insulator" else: return "Functional Glass"
In the Dirac case:
δ=3.33×10 −6 <0.1 (crystal threshold) κ needs to be computed from gradient data Temperature needs to be computed from gradient data α=12.61>7.0 (topological insulator threshold) The classification as "Polycrystalline" rather than "Perfect Crystal" or "Topological Insulator" reflects the intermediate nature of the state.
- Berry Phase Analysis: The Key Distinction
The Berry phase analysis is what distinguishes the Dirac case from both Strassen and HPU-Core.
Berry phase is a geometric phase acquired by a quantum system when its parameters undergo adiabatic (slow) evolution around a closed loop.
Mathematical definition:
Consider a Hamiltonian H(λ) that depends on parameters λ . If the parameters traverse a closed loop C , the Berry phase is:
γ=∮ C ⟨n(λ)∣∇ λ ∣n(λ)⟩⋅dλ
where ∣n(λ)⟩ is the nth eigenstate of H(λ) .
In simpler terms: as the system changes slowly and returns to its starting point, the wave function picks up a phase factor e iγ .
The idea is to treat the training trajectory as a path in parameter space. As the network trains, its weights change. If the training passes through a series of checkpoints that can be connected into a closed loop (or approximated as such), we can compute the Berry phase.
Physical interpretation:
γ=0 : The path is "trivial"—the system returns without acquiring phase γ≠0 : The path encloses a singularity or topological feature γ=2π (winding number = 1): The path winds around a singularity once
In the HPU-Core Hamiltonian case, the Berry phases were ±10.26 rad, corresponding to winding numbers ±2 . This indicated the training trajectory had encountered a topological feature.
The Berry phase calculation proceeds as follows:
- Extract kernel parameters from checkpoints: For each checkpoint, extract the complex spectral kernels K=K real +iK imag
from the spectral layers. 2. Flatten and normalize: Flatten each kernel into a complex vector θ and normalize: θ̂_n = θ_n / ||θ_n|| 3. Compute overlaps between consecutive checkpoints: ⟨θ_n ∣ θ_{n+1}⟩ = θ̂_n^* · θ̂_{n+1} 4. Extract phases: ϕ_n = arg(⟨θ_n ∣ θ_{n+1}⟩) 5. Sum phases: γ = Σ_n ϕ_n 6. Compute winding number: W = round(γ / 2π)
From the Berry phase visualization:
Berry Phase: -0.0000 rad (-0.0 deg) Total Phase: -0.000000 rad Phase mod 2π: -0.000000 rad Winding Number: 0 Interpretation: Trivial (γ ≈ 0) Checkpoints analyzed: 11
Interpretation:
The Berry phase is essentially zero. The training trajectory did not enclose any topological feature.
This distinguishes the Dirac case from HPU-Core:
HPU-Core: γ=±10.26 rad, W=±2 (topological insulator) Dirac: γ≈0 , W=0 (no topological feature)
And it also distinguishes Dirac from Strassen:
Strassen: No Berry phase computation needed because the structure is purely algebraic (integer weights), not topological Dirac: Berry phase is computable but trivial
- The Metric Evolution: Watching the Phase Stabilize
The metric evolution plot shows how various quantities changed across the 11 checkpoints (epochs 820-910).
The purity α is nearly constant at 12.61 with standard deviation 7.3×10 −5 . This is remarkable stability.
Interpretation: By epoch 820, the system had already crystallized into a fixed configuration. The refinement phases (4 and 5) did not change the purity—they only refined the details.
The discretization margin δ is also nearly constant at 3.33×10 −6 with standard deviation 2.4×10 −10 . Again, remarkable stability.
Interpretation: The refinement phases did not push the weights closer to integers. The system had found its equilibrium position, and that position is close to—but not on—the integer lattice.
The Ricci scalar shows more variation: mean 8.6×10 15 with standard deviation 1.7×10 15 .
Interpretation: While the purity and discretization margin are stable, the geometry of the weight manifold still fluctuates. This is consistent with a polycrystalline structure: the weights are locked into domains, but the domains themselves can shift slightly.
The health score is exactly 0.5 for all checkpoints.
What is health score?
The health score is a composite metric:
Health = ½ ( 1/(1+δ/δ_threshold) + α/α_threshold )
It combines discretization quality and purity into a single number between 0 and 1.
Interpretation: With δ=3.33×10 −6 ≪0.1 and α=12.61 , the health score evaluates to:
Health = ½ ( 1/(1+3.33×10^{-5}) + 12.61/7.0 ) ≈ ½ (0.999 + 1.80) ≈ 0.5
Wait, this doesn't match. Let me recalculate:
If health = 0.5 exactly, then either:
- The formula is different
- The discretization term is being evaluated at a much smaller threshold
- The formula has a cap
Looking at the code, the health score formula is:
Health = 0.5 × min(1, 1/(1+δ)) + 0.5 × min(1, α/α_threshold)
With δ=3.33×10 −6 :
Discretization term: 1/(1+3.33×10^{-6}) ≈ 0.999997 ≈ 1.0 Purity term: min(1,12.61/7.0)=1.0 Health: 0.5×1.0+0.5×1.0=1.0
This should give health = 1.0, not 0.5. There must be a different formula in the actual implementation, or the health score is computed differently.
Looking more carefully at the code, I see:
'health_score': {
"mean": 0.5,
"std": 0.0,
}The health score being exactly 0.5 with zero variance suggests it's a default or placeholder value, not computed from the actual metrics. This is an artifact of the analysis pipeline, not a meaningful physical quantity.
- Comprehensive Crystallographic Analysis
The comprehensive analysis at epoch 910 provides a snapshot of the fully crystallized state.
Pie chart: Shows valid, NaN, and Inf counts in weights.
Result: 100% valid weights, no NaN or Inf values.
Interpretation: The training was numerically stable throughout. This is a prerequisite for crystallization—numerical instabilities would corrupt the crystal structure.
Bar chart: Shows spectral gap, participation ratio, and effective dimension.
Mathematical foundation:
The spectral analysis computes eigenvalues of the weight correlation matrix:
C = (1/N) W Wᵀ
where W is the flattened weight matrix.
- Spectral gap: Difference between largest and second-largest eigenvalue Δλ = λ₁ − λ₂ Large spectral gap indicates the weights have a dominant direction.
- Participation ratio: Measures how many eigenvalues contribute significantly PR = (Σ_i λ_i)² / Σ_i λ_i² Low PR indicates energy concentrated in few modes; high PR indicates energy spread across many modes.
- Effective dimension: Number of eigenvalues above a threshold
Interpretation: A large spectral gap with low participation ratio indicates crystalline structure—all weight variance is captured by a small number of principal directions.
Scatter plot: Alpha vs. Temperature with the current checkpoint marked.
Interpretation: The checkpoint lies in the polycrystalline region: high alpha (above 7.0) but not in the low-temperature regime where perfect crystals form.
Bar chart: Shows Ricci scalar, mean sectional curvature, and curvature variance.
Mathematical foundation:
The Ricci scalar was computed earlier. The sectional curvature for a plane defined by tangent vectors u,v is:
K(u,v) = R(u,v,u,v) / (g(u,u)g(v,v) − g(u,v)²)
where R is the Riemann curvature tensor.
In practice, this is estimated by sampling random tangent directions and computing the Gaussian curvature of the induced 2D surface.
Interpretation: Large positive Ricci scalar with variance in sectional curvatures indicates the weight manifold is curved like a sphere but with local variations—consistent with a polycrystalline structure where different domains have different curvatures.
Histogram and metric: Level spacing ratio analysis for many-body localization.
Mathematical foundation:
The level spacing ratio measures the distribution of gaps between consecutive eigenvalues:
r_n = min(δ_n, δ_{n+1}) / max(δ_n, δ_{n+1})
where δ_n = λ_n − λ_{n-1}.
- Poisson distribution: r≈0.386 (localized states, integrable systems)
- Wigner-Dyson distribution: r≈0.5307 (delocalized states, chaotic systems)
Result from analysis: Level spacing ratio = 0.0
This extreme value suggests the eigenvalues are highly degenerate or the spectrum has a very specific structure.
Interpretation: A level spacing ratio of 0.0 is unusual. It could indicate:
- Exact degeneracies in the spectrum
- A highly structured spectrum (e.g., all eigenvalues identical)
- Numerical issues in the computation
For a crystallized system, eigenvalue degeneracy is expected—the crystal structure has symmetries that lead to degeneracies.
Bar chart or line plot: Shows the eigenvalue distribution.
Interpretation: The spectrum should show clear separation between dominant eigenvalues and the rest. This separation is a signature of crystalline structure.
Visualization of: R_cm (center of mass in Fourier space), localization index, alignment score, etc.
Mathematical foundation:
These metrics are computed from the spectral field—the complex kernel K in Fourier space.
- Center of mass: R_cm = ∫ k |K(k)|² dk / ∫ |K(k)|² dk This measures where in k-space the spectral weight is concentrated.
- Localization index: Computed from the inertia tensor of the spectral density I_ij = ∫ (k_i − R_i)(k_j − R_j) |K(k)|² dk The eigenvalues of I give the spread in different directions. The localization index is 1 − I₁/I₂ where I₁ < I₂ are the eigenvalues.
- Alignment score: Measures how aligned the spectral weight is with specific directions in k-space.
Interpretation: For a crystalline system, the spectral weight should be concentrated at discrete k-points (the reciprocal lattice). The center of mass should be well-defined, and the localization index should be high.
The Berry phase visualization shows the unit circle in the complex plane with the accumulated phase marked.
Result: Berry phase ≈ 0, winding number = 0.
Interpretation: The training trajectory did not enclose a topological singularity. This is the key distinction from the Hamiltonian Topological Insulator case.
- The Relativistic Orbital Visualization
The relativistic orbital visualization (dirac_orbital_3d_5_2.png) shows the wavefunction of a relativistic 3d orbital with j=2.5.
This visualization is not just a pretty picture. It represents what the network is learning: the spatial structure of relativistic wavefunctions.
The orbital shows:
- 3D structure: The wavefunction is not spherically symmetric. The angular structure encodes the angular momentum quantum numbers.
- Radial structure: The distance from the center shows the probability density.
- Phase structure: The coloring (red/blue) shows the phase of the wavefunction.
Relativistic Orbital 3d, j=2.5 n=3, l=2, j=2.5
This is a 3d orbital (n=3, l=2) with total angular momentum j = l + 1/2 = 2.5.
In relativistic quantum mechanics, the orbital angular momentum l is not a good quantum number alone. The total angular momentum j is conserved. For l=2 , the possible j values are:
- j = l − 1/2 = 1.5
- j = l + 1/2 = 2.5
The fine structure splitting between these two levels is given by the Dirac equation: ΔE_FS = E_{j=1.5} − E_{j=2.5}
The visualization used 2,000,000 Monte Carlo samples to reconstruct the orbital shape.
Mathematical foundation:
Monte Carlo sampling draws random positions r and accepts them with probability proportional to |ψ(r)|². This is rejection sampling:
- Propose a position r uniformly in a bounding volume
- Compute p = |ψ(r)|²
- Accept with probability p / p_max
The accepted points form a cloud whose density is proportional to |ψ|².
The relativistic orbital differs from the non-relativistic one due to:
- Spin-orbit coupling: The spin and orbital angular momenta couple
- Relativistic mass increase: Electrons moving faster have higher effective mass
- Darwin term: A correction for electrons very close to the nucleus
These effects split the non-relativistic energy levels into the fine structure multiplets.
- The Physical Constants in the Code
The code uses precise physical constants:
C_LIGHT: float = 137.035999084 # Fine structure constant inverse
ALPHA_FS: float = 1.0 / 137.035999084 # Fine structure constant
HBAR_PHYSICAL: float = 1.054571817e-34The fine structure constant α_FS ≈ 1/137 is a dimensionless constant that characterizes the strength of electromagnetic interactions:
α_FS = e² / (4πϵ₀ ℏc)
In atomic units (setting ℏ = m_e = e = 1), the speed of light is c = 1/α_FS ≈ 137.
This is why the code uses c=137.036.
The code uses atomic units, where:
- ℏ = 1 (reduced Planck constant)
- m_e = 1 (electron mass)
- e = 1 (electron charge)
- a₀ = 1 (Bohr radius)
In these units:
- Energy is measured in Hartrees: E_h = 27.21 eV
- Length is measured in Bohr radii: a₀ = 0.529 Å
- Time is measured in atomic time units: t₀ = 2.42×10⁻¹⁷ s
By using real physical constants, the network is learning physics, not just mathematical patterns. When the network learns to evolve a Dirac spinor, it is learning the dynamics that real electrons obey.
This is why I can compare the network's predictions to analytical solutions—the network should reproduce the fine structure splitting, the relativistic dispersion relation, and other physical effects.
- Comparison: Strassen Diamond vs. Dirac Polycrystal vs. Hamiltonian Topological Insulator
Now I can provide a systematic comparison across the three cases.
-
Nature: Discrete algorithmic structure
-
Key metrics:
- δ = 0 (exactly on integer lattice after discretization)
- α > 20 (extreme purity)
- κ = 1 (perfect isotropy)
- T_eff < 10⁻¹⁶ (essentially zero temperature)
- Berry phase: Not applicable (algebraic, not topological)
- Structure: 7 discrete products with coefficients in {-1, 0, 1}
- Physical analogue: A perfect crystal with atoms at exact lattice positions
-
Success criterion: Weights round to exact Strassen coefficients
-
Expansion: Zero-shot expansion from 2×2 to 64×64 matrices
-
Nature: Continuous dynamical structure
-
Key metrics:
- δ = 3.33×10⁻⁶ (close to but not on integers)
- α = 12.61 (high purity)
- κ: Needs gradient data
- T_eff: Needs gradient data
- Berry phase: γ ≈ 0 (trivial)
- Ricci scalar: R ∼ 10¹⁶ (extreme curvature)
- Level spacing ratio: r ≈ 0 (highly degenerate)
- Physical analogue: A polycrystalline material with multiple domains
-
Success criterion: Network learns correct Dirac evolution
-
Expansion: The learned operator works for any initial spinor
-
Nature: Topological dynamical structure
-
Key metrics:
- δ = 0.3687 (not close to integers)
- α = 1.0 (normalized)
- κ = ∞ (singular)
- T_eff = 0 (zero effective temperature)
- Berry phase: γ = ±10.26 rad
- Winding number: W = ±2
- Lyapunov exponent: λ_max = +0.00175
- Physical analogue: A topological insulator with protected edge states
-
Success criterion: Network learns Hamiltonian dynamics with topological invariants
-
Expansion: The Berry phase and winding number are quantized and stable
| Property | Strassen | Dirac | HPU-Core |
|---|---|---|---|
| Discretization | Perfect | Near-perfect | Poor |
| Purity | Very high | High | Normal |
| Berry phase | N/A | Trivial | Non-trivial |
| Winding | N/A | 0 | ±2 |
| Structure type | Algebraic | Dynamical | Topological |
| Physical analogue | Perfect crystal | Polycrystal | Topological insulator |
- Why the Difference? A Hypothesis
The three cases represent different endpoints of the crystallization process. Why?
- Strassen: The target is discrete. The algorithm requires exact integer operations. The only way to learn it is to land on the integer lattice.
- Dirac: The target is continuous. The Dirac equation has continuous parameters (the gamma matrices can be unitarily transformed). There is no unique discrete solution to land on.
- HPU-Core: The target is topological. The Hamiltonian has topological invariants (Berry phases, winding numbers). These are quantized but not discrete—they are robust under continuous deformations.
- Strassen: The loss landscape has sharp minima at the discrete Strassen configurations. These are global minima separated by barriers.
- Dirac: The loss landscape has a broad minimum valley. The network can achieve zero loss anywhere within this valley. The valley does not pass through discrete points.
- HPU-Core: The loss landscape has topological features. The Berry phase creates an obstruction to smooth deformation—the system must "choose" a topological sector.
- Strassen: Discretization (pruning + rounding) provides explicit constraints that force the system to a discrete lattice.
- Dirac: No explicit discretization constraints were applied. The network learned continuous dynamics.
- HPU-Core: The Hamiltonian structure itself provides constraints—conservation laws and topological invariants that restrict the space of valid solutions.
- Strassen: Grokking is a first-order phase transition. The system abruptly jumps from glass to crystal.
- Dirac: The transition is smoother. The system gradually approaches a fixed point.
- HPU-Core: The transition involves topological sector changes. The system must cross a barrier to change winding number.
- Thermodynamic Interpretation
I can interpret the three cases through the lens of statistical thermodynamics.
In statistical mechanics, the partition function encodes all thermodynamic properties:
Z = Σ_{microstates} e^{−E / k_B T}
For neural networks, I can define an analogous partition function:
Z = Σ_{weight configurations} e^{−ℒ(θ) / T_eff}
where T_eff is the effective temperature from gradient noise.
The Gibbs free energy is:
G = E − T S
where E is internal energy and S is entropy.
For the neural network:
G = ℒ(θ) − T_eff · S(θ)
The system minimizes free energy, balancing low loss (internal energy) against high entropy.
- Strassen: Low temperature crystallization. The system freezes into a single microstate with minimal entropy. The free energy is dominated by the internal energy term.
- Dirac: Intermediate temperature. The system crystallizes but with higher entropy (multiple equivalent configurations). The free energy has both terms significant.
- HPU-Core: Topological constraints. The entropy is restricted by topological sector choice. The system can only access microstates with the same winding number.
From the discretization margin, I can estimate an entropy-like quantity:
S ∼ −log δ
- For Strassen (δ = 0): S = 0 (zero entropy)
- For Dirac (δ = 3.33 × 10⁻⁶): S ≈ 14.5 (finite entropy)
- For HPU-Core (δ = 0.3687): S ≈ 1 (low entropy due to topological constraint)
- Implications for Algorithmic Learning
What does this mean for learning algorithms in neural networks?
There is not just one type of "algorithmic learning." The phase diagram contains multiple distinct phases:
- Perfect crystals (algebraic algorithms)
- Polycrystals (continuous dynamics)
- Topological insulators (protected structures)
- Glasses (memorization without structure)
The batch size, regularization, and initialization determine which phase the system enters. Small changes in these parameters can cause phase transitions.
The nature of the target structure (discrete, continuous, or topological) determines what phase is achievable. You cannot crystallize a discrete algorithm from a continuous target.
- Strassen: The algorithm was discovered independently, but neural networks can be engineered to recover it.
- Dirac: The equation is known. Neural networks can learn to implement it, but not in a discrete way.
- HPU-Core: The network discovered a Hamiltonian structure with topological properties. This is more discovery than engineering.
- Open Questions
This work raises more questions than it answers.
If I applied even more crystallization pressure, would the Dirac network eventually reach a discrete state? Or is the polycrystalline state the true endpoint?
In a polycrystal, how many domains form? What determines their boundaries?
Is the polycrystalline state a precursor to either the perfect crystal or topological insulator? Or is it a distinct endpoint?
Can we determine in the early epochs which phase the system will eventually reach? The κ metric was predictive for Strassen. What metrics predict the Dirac outcome?
What happens if we try to learn other physical equations? The Schrödinger equation? The Navier-Stokes equations? Maxwell's equations? Each may have different crystallization behaviors.
- Conclusion
I have documented the crystallization of a relativistic quantum structure in a neural network. The result is a polycrystalline phase—highly structured but not discrete, trivial topology but extreme curvature.
This phase sits between two previously documented phases:
- The Strassen diamond: perfect crystallization of a discrete algorithm
- The Hamiltonian topological insulator: topological protection of a continuous structure
The key insight is that the nature of the target determines the nature of the crystallized state. Discrete targets yield discrete crystals. Continuous targets yield polycrystals. Topological targets yield topological insulators.
The mathematics is not metaphor. Every metric I computed—discretization margin, purity, Berry phase, Ricci scalar, level spacing ratio—is derived from physical or geometric considerations. The fact that these metrics consistently distinguish between the three cases validates the framework.
The phase diagram of algorithmic learning is real. It is observable, measurable, and bounded by physical and mathematical constraints.
— grisun0
class GammaMatrices:
"""
Dirac gamma matrices in Dirac (standard) representation.
"""
def __init__(self, representation: str, device: str):
self.representation = representation
self.device = device
self._init_matrices()
def _init_matrices(self):
# gamma^0 (beta)
self.gamma0 = torch.tensor([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, -1]
], dtype=torch.complex64, device=self.device)
# gamma^1
self.gamma1 = torch.tensor([
[0, 0, 0, 1],
[0, 0, 1, 0],
[0, -1, 0, 0],
[-1, 0, 0, 0]
], dtype=torch.complex64, device=self.device)
# gamma^2
self.gamma2 = torch.tensor([
[0, 0, 0, -1j],
[0, 0, 1j, 0],
[0, 1j, 0, 0],
[-1j, 0, 0, 0]
], dtype=torch.complex64, device=self.device)
# gamma^3
self.gamma3 = torch.tensor([
[0, 0, 1, 0],
[0, 0, 0, -1],
[-1, 0, 0, 0],
[0, 1, 0, 0]
], dtype=torch.complex64, device=self.device)
# gamma^5 = i * gamma^0 * gamma^1 * gamma^2 * gamma^3
self.gamma5 = torch.tensor([
[0, 0, 1, 0],
[0, 0, 0, 1],
[1, 0, 0, 0],
[0, 1, 0, 0]
], dtype=torch.complex64, device=self.device)def apply_dirac_hamiltonian(self, spinor: torch.Tensor) -> torch.Tensor:
"""
Apply Dirac Hamiltonian to 4-component spinor.
H_psi = c * (alpha_x * p_x + alpha_y * p_y) @ psi + beta * m * c^2 * psi
"""
device = spinor.device
if spinor.dim() == 3:
spinor = spinor.unsqueeze(0)
batch_size = spinor.shape[0]
result = torch.zeros_like(spinor, dtype=torch.complex64)
# Kinetic term: c * alpha . p
for c in range(4):
psi_c = spinor[:, c, :, :]
psi_c_fft = torch.fft.fft2(psi_c)
# p_x * psi in Fourier space
px_psi_fft = self.kx_grid * psi_c_fft
py_psi_fft = self.ky_grid * psi_c_fft
px_psi = torch.fft.ifft2(px_psi_fft)
py_psi = torch.fft.ifft2(py_psi_fft)
for d in range(4):
alpha_x_cd = self.alpha_x[c, d].item()
alpha_y_cd = self.alpha_y[c, d].item()
result[:, c, :, :] += self.c * (
alpha_x_cd * px_psi +
alpha_y_cd * py_psi
)
# Mass term: beta * m * c^2
mass_term = self.mass * self.c**2
for c in range(4):
for d in range(4):
beta_cd = self.beta[c, d].item()
result[:, c, :, :] += beta_cd * mass_term * spinor[:, d, :, :]
return resultdef compute_berry_connection_discrete(self, theta_prev: torch.Tensor,
theta_curr: torch.Tensor) -> float:
"""
Compute Berry connection between consecutive checkpoints.
γ_n = arg(⟨θ_n | θ_{n+1}⟩)
"""
if theta_prev is None or theta_curr is None:
return 0.0
# Normalize
theta_prev_norm = theta_prev / (torch.norm(theta_prev) + 1e-10)
theta_curr_norm = theta_curr / (torch.norm(theta_curr) + 1e-10)
# Compute overlap
overlap = torch.sum(torch.conj(theta_prev_norm) * theta_curr_norm)
if torch.abs(overlap) < 1e-10:
return 0.0
# Extract phase
phase = torch.angle(overlap).item()
return phase
def calculate_berry_phase(self, checkpoint_dir: str) -> Dict[str, Any]:
"""
Calculate total Berry phase from checkpoint trajectory.
γ_total = Σ γ_n
W = round(γ_total / 2π)
"""
checkpoints = self.load_checkpoints(checkpoint_dir)
if len(checkpoints) < 2:
return {'error': f'Need at least 2 checkpoints, found {len(checkpoints)}'}
# Extract kernel parameters
kernels = []
for ckpt in checkpoints:
kernel = self.flatten_kernel_params(ckpt['state_dict'])
kernels.append(kernel)
# Compute phases
berry_phases = []
for i in range(1, len(kernels)):
if kernels[i-1] is not None and kernels[i] is not None:
phase = self.compute_berry_connection_discrete(kernels[i-1], kernels[i])
berry_phases.append(phase)
else:
berry_phases.append(0.0)
# Total phase
cumulative_phase = np.cumsum(berry_phases)
total_phase = cumulative_phase[-1] if len(cumulative_phase) > 0 else 0.0
# Mod 2π
phase_mod_2pi = total_phase % (2 * np.pi)
if phase_mod_2pi > np.pi:
phase_mod_2pi -= 2 * np.pi
# Winding number
winding_number = int(round(total_phase / (2 * np.pi)))
return {
'total_berry_phase': total_phase,
'berry_phase_mod_2pi': phase_mod_2pi,
'winding_number': winding_number,
'num_checkpoints': len(checkpoints)
}def _compute_ricci_scalar(self, metric: np.ndarray) -> float:
"""
Compute Ricci scalar from metric tensor.
For a metric tensor g, the Ricci scalar is:
R = g^{ij} R_{ij}
Simplified computation using eigenvalues:
R = n * Σ (1/λ_i)
"""
eigenvalues = eigh(metric, eigvals_only=True)
eigenvalues = eigenvalues[eigenvalues > EIGENVALUE_TOL]
n = len(eigenvalues)
if n < 2:
return 0.0
ricci_scalar = n * np.sum(1.0 / eigenvalues)
return ricci_scalar
def _estimate_sectional_curvatures(self, metric: np.ndarray,
samples: int = 100) -> np.ndarray:
"""
Estimate sectional curvatures by sampling tangent planes.
For tangent vectors u, v:
K(u,v) = R(u,v,u,v) / (g(u,u)g(v,v) - g(u,v)^2)
Approximated by computing Gaussian curvature of 2D subsurface.
"""
curvatures = []
n = metric.shape[0]
for _ in range(samples):
i, j = np.random.choice(n, 2, replace=False)
block = metric[np.ix_([i, j], [i, j])]
det = np.linalg.det(block)
if det > EIGENVALUE_TOL:
curvatures.append(1.0 / det)
return np.array(curvatures) if curvatures else np.array([0.0])def _compute_level_spacing_ratio(self, spacings: np.ndarray) -> float:
"""
Compute level spacing ratio for MBL analysis.
r_n = min(δ_n, δ_{n+1}) / max(δ_n, δ_{n+1})
Returns mean of r_n over all n.
Reference values:
- Wigner-Dyson (chaotic): r ≈ 0.5307
- Poisson (localized): r ≈ 0.3863
"""
if len(spacings) < 2:
return 0.0
ratios = []
for i in range(len(spacings) - 1):
s1 = abs(spacings[i])
s2 = abs(spacings[i+1])
if s1 > 1e-15 and s2 > 1e-15:
ratios.append(min(s1, s2) / max(s1, s2))
return np.mean(ratios) if ratios else 0.0def compute(self, model: nn.Module, **kwargs) -> Dict[str, Any]:
"""
Compute discretization margin and purity metrics.
"""
margins = []
all_params = []
layer_deltas = {}
for name, param in model.named_parameters():
if param.numel() > 0:
p_data = param.data.detach()
all_params.append(p_data.flatten())
# Discretization margin
margin = (p_data - p_data.round()).abs().max().item()
margins.append(margin)
layer_deltas[name] = margin
# Maximum margin
delta = max(margins) if margins else 0.0
# Purity (alpha)
alpha = -np.log(delta + EPSILON) if delta > 0 else 20.0
# Spectral entropy
flat_params = torch.cat(all_params)[:PARAM_FLATTEN_LIMIT]
spectral_entropy = self._compute_spectral_entropy(flat_params)
return {
'delta': delta,
'alpha': alpha,
'spectral_entropy': spectral_entropy,
'is_discrete': delta < DELTA_CRYSTAL_THRESHOLD,
'layer_deltas': layer_deltas
}def _classify_phase(self, delta: float, kappa: float,
temp: float, alpha: float) -> str:
"""
Classify the phase of the system based on thermodynamic metrics.
Classification hierarchy:
1. Perfect Crystal: delta < 0.1, kappa < 1.5, temp < 1e-9
2. Polycrystalline: delta < 0.1, but not perfect crystal conditions
3. Cold Glass: delta >= 0.4, temp < 1e-9
4. Amorphous Glass: kappa > 1e6
5. Topological Insulator: alpha > 7.0
6. Functional Glass: everything else
"""
if (delta < DELTA_CRYSTAL_THRESHOLD and
kappa < KAPPA_CRYSTAL_THRESHOLD and
temp < TEMPERATURE_CRYSTAL_THRESHOLD):
return "Perfect Crystal"
if (delta < DELTA_CRYSTAL_THRESHOLD and
kappa >= KAPPA_CRYSTAL_THRESHOLD):
return "Polycrystalline"
if (delta >= DELTA_GLASS_THRESHOLD and
temp < TEMPERATURE_CRYSTAL_THRESHOLD):
return "Cold Glass"
if kappa > 1e6:
return "Amorphous Glass"
if alpha > ALPHA_CRYSTAL_THRESHOLD:
return "Topological Insulator"
return "Functional Glass"[1] Nanda, N., et al. "Progress measures for grokking via mechanistic interpretability." arXiv preprint arXiv:2301.05217 (2023).
[2] Power, A., et al. "Grokking: Generalization beyond overfitting on small algorithmic datasets." arXiv preprint arXiv:2201.02177 (2022).
[3] Miller, J., et al. "Discrete structures in neural networks." NeurIPS (2021).
[4] Berry, M. V. "Quantal phase factors accompanying adiabatic changes." Proceedings of the Royal Society A 392.1802 (1984): 45-57.
[5] Dirac, P. A. M. "The quantum theory of the electron." Proceedings of the Royal Society A 117.778 (1928): 610-624.
[6] Perelman, G. "The entropy formula for the Ricci flow and its geometric applications." arXiv preprint math/0211159 (2002).
[7] Citation for Grokking and Local Complexity (LC): Title: Deep Networks Always Grok and Here is Why, Authors: A. Imtiaz Humayun, Randall Balestriero, Richard Baraniuk, arXiv:2402.15555, 2024.
[8] Citation for Superposition as Lossy Compression: Title: Superposition as lossy compression, Authors: Bereska et al., arXiv 2024.
[9] grisun0. Algorithmic Induction via Structural Weight Transfer. Zenodo, 2025. https://doi.org/10.5281/zenodo.18072858
[10] grisun0. From Boltzmann Stochasticity to Hamiltonian Integrability: Emergence of Topological Crystals and Synthetic Planck Constants. Zenodo, 2026. https://doi.org/10.5281/zenodo.18407920
[11] grisun0. Thermodynamic Grokking in Binary Parity (k=3) : A First Look at 100 Seeds. Zenodo, 2026. https://doi.org/10.5281/zenodo.18489853
[12] grisun0. Schrödinger Topological Crystallization: Phase Space Discovery in Hamiltonian Neural Networks. Zenodo, 2026. https://doi.org/10.5281/zenodo.18725428