Hands-On Examples for the Axial-Parity Gauge Paper

Three interactive demos — the gauge theorem you can’t break, the negative-result scoreboard, and why hard \(\mathbb{F}_2\) kills the gradient

Companion to the tutorial and to the paper “Gauge Structure and Architectural Inductive Bias for Axial Parity Codes: A Theorem and a Negative Result” (B. Guarraci, Galatheus). The tutorial explains why the codec is a discrete fracton gauge theory and why hard-coding that algebra fails; this page lets you see it. Every widget runs entirely offline with hand-written canvas + JavaScript — no libraries. Widget 1’s parity checks, the gauge transformation \(T=\partial_x\partial_y\partial_z\), and the live rank \(3n^2-3n+1\) are exactly the construction in verify_fracton_theorem.py (its ranks \(\{37,91,169\}\) at \(n\in\{4,6,8\}\) are machine-checked there and reproduced live below). Widgets 2–3 take their numbers verbatim from Tables 1–2 of main.tex and the run log in experiments.tsv. Nothing is invented.

The one idea to hold onto The set of voxel grids passing every parity check — the codespace — is exactly the image of a discrete third derivative \(\partial_x\partial_y\partial_z\) over \(\mathbb{F}_2\). That makes the codec a discrete \(\mathbb{Z}_2\) fracton gauge theory: a codeword is the “field strength” of a hidden potential \(\phi\), and you can XOR in any \(\partial_x\partial_y\partial_z\phi\) without moving a single parity bit (Widget 1). And yet hard-wiring that exact algebra into a neural decoder makes it worse: it plateaus at IoU 0.283 against an unconstrained baseline’s 0.481 (Widget 2). Widget 3 shows the mechanism — the hard \(\mathbb{F}_2\) gate starves the gradient.

1. The gauge theorem you can’t break

Axial-parity gauge visualizer — one slice of an \(n^3\) lattice

What this teaches: the codespace is \(\mathrm{image}(\partial_x\partial_y\partial_z)\), a fracton-like \(\mathbb{Z}_2\) gauge structure. Toggle voxels to build a field and watch the line/plane/global syndrome light up. Then hit “Apply gauge \(T\phi\)”: it XORs in a codeword (the third derivative of a potential), the picture changes — but every parity check stays exactly as it was. That invariance is the theorem. The live rank uses the closed form \(3n^2-3n+1\) for your chosen \(n\).

voxel = 0 voxel = 1 odd line parity (lit check) even line parity (quiet)

quantitythis slice / lattice \(n\)closed formverifier (\(n\!\le\!8\))
Why the syndrome never moves (the theorem in one line) Each parity check is the \(\mathbb{F}_2\) inner product of the field with the indicator of an axis line, plane, or the whole lattice. A gauge codeword \(T\phi=\partial_x\partial_y\partial_z\phi\) has the property that every such sum telescopes to \(0\bmod 2\) under the periodic boundary — each \(\phi_v\) enters an even number of times. So \(\mathrm{image}(T)\subseteq\ker H\), and a dimension count (\(\dim\,\mathrm{image}\,T = n^3-(3n^2-3n+1) = \dim\ker H\)) forces equality: \(\mathcal{C}(n)=\mathrm{image}(\partial_x\partial_y\partial_z)\). The verifier confirms it exactly at \(n\in\{4,6,8\}\): \(\mathrm{rank}(H)=\{37,91,169\}\).
The bug the theorem caught Closed-form rank is also a correctness check. The previously deployed parity matrix reported rank 2016 at \(n=32\) instead of the correct 2977 (\(=3\cdot1024-96+1\)). Run through the same verifier its construction gives ranks \(\{28,66,120\}\) at \(n\in\{4,6,8\}\) — strictly smaller than \(\{37,91,169\}\), i.e. a genuinely different, lower-rank code from a duplicate-axis indexing error. The theorem paid rent.

2. The negative-result scoreboard

Unconstrained baseline vs. hard-gauge variants — the real Table 1 / Table 2 numbers

What this teaches: hard-coding the exact \(\mathbb{F}_2\) gauge algebra into the architecture hurts. The unconstrained x-prior ResNet3D (green) reaches val_IoU 0.481; the best phi-prior that enforces \(x=\partial_x\partial_y\partial_z\phi\) at every voxel plateaus at 0.283 (amber); and the degenerate hard-\(\mathbb{F}_2\) variants (tanh-product XOR, straight-through estimator, residual escape hatch) collapse to near zero. Flip the view to see the best phi-prior across 14 configs never escapes the \(\approx0.29\) plateau, while capacity buys the baseline nothing.

The gap is the result — not any single cell At matched 5.0M params and 20 epochs the only thing that changes between x-prior (0.481) and phi-prior (0.283) is the fixed output operator \(\partial_x\partial_y\partial_z\). Across 14 configurations — capacity (5M = 12M), training length (20 = 30 epochs), positive-class weighting (sweet spot pos_weight = 19), and data scale (2K = 8K) — the phi-prior never clears \(\approx0.29\). And x-prior capacity saturates too: 12M gives 0.489, 17.9M gives 0.474. Capacity is not the bottleneck; the hard constraint is.
For completeness: what actually wins (Table 2) A gauge-free multi-scale autoencoder (encoder \(\to 8^3\) latent \(\to\) SharpNet upsample) beats everything at 0.572 ± 0.004 over seeds \(\{42,43,44\}\). A soft U(1) transporter helps modestly (0.509), but a controlled ablation removing its gauge machinery improves it to 0.518 — the gauge structure is not load-bearing. The lesson: a known mathematical structure tells you what is reachable, not the right inductive bias.

3. Why hard \(\mathbb{F}_2\) collapses learning

One gauge gate, two ways — soft relaxation vs. hard XOR / straight-through

What this teaches: the mechanism behind the collapse. To flip a single residual bit the phi-prior must nudge a whole product of corner \(\phi\)’s through the bilinear soft-XOR; with the output bias initialised at \(-5\) (to break XOR symmetry), the gate sits deep in saturation and its gradient is multiplicatively attenuated. The hard / straight-through estimator (STE) version is worse still — the true XOR has zero gradient almost everywhere. Drag the input logits and read the gradient that reaches \(\phi\): the soft path keeps a usable signal; the hard path flatlines, which is exactly why the STE and tanh-product runs land at val_IoU 0.001–0.002.

A non-local credit-assignment problem (the paper’s own explanation) The toy here uses two inputs; the real operator XORs 8 corner \(\phi\)’s per voxel. To flip one residual bit the network must simultaneously modulate all 8 — and most residual targets are 0, so BCE provides little drive. The gradient through the bilinear product is bounded by 1 but attenuated at every factor, and the STE forward/bilinear backward split (run exp05) left the loss flat at 0.36 because \(\sigma'(-5)\approx0.007\) crushed the passed-through gradient. Correct constraint, hostile landscape.

Companion to the tutorial and main.tex. Widget 1’s lattice, parity checks, gauge operator \(T=\partial_x\partial_y\partial_z\), and the closed-form rank \(3n^2-3n+1\) follow verify_fracton_theorem.py exactly; its machine-checked ranks \(\{37,91,169\}\) (correct) and \(\{28,66,120\}\) (the caught bug) at \(n\in\{4,6,8\}\), and the \(n=32\) value \(2977\), are reproduced verbatim. Widget 2’s scoreboard is Tables 1–2 of main.tex (x-prior 0.481/0.489/0.474; phi-prior 0.283/0.276/0.291/0.292 and the degenerate 0.002/0.021/0.001/0.001; autoencoder \(0.572\pm0.004\); transporter 0.509/0.518) cross-checked against the per-run log in fracton_xcube/src/gauge_paper/experiments.tsv. Widget 3 is a schematic of the bilinear soft-XOR vs. STE gate described in §6 of main.tex; the −5 bias init and the flat-loss STE failure are from experiments.tsv (exp02, exp05). No results were invented.