Spectral-Margin Loop Regularizer
Implementation & benchmark of arXiv:2607.10681 — LayerNorm as Implicit Gain Control in Looped Transformers
Source paper: LayerNorm as Implicit Gain Control in Looped Transformers arXiv:2607.10681 ⓘ · analyzed Aug 30, 2026
AI-generated research hypothesis, automatically tested. Not peer-reviewed.
Idea description
Regularize the local recurrent Jacobian by its spectral radius rather than imposing the overly conservative operator-norm condition $\|J\|_2<1$. This permits useful non-normal updates with transient amplification while explicitly pushing the asymptotic dynamics toward a stable fixed point.
Formulas
Mathematical statement
For $h_{t+1}=\bar{A}\odot h_t+f(h_t,e)$, define the local Jacobian $J_t=\operatorname{Diag}(\bar{A})+\partial f(h_t,e)/\partial h_t$, where $\operatorname{Diag}(\bar{A})$ is the diagonal carry operator and the derivative is with respect to the flattened state $h_t$. The spectral radius is $\rho(J_t)=\max_i|\lambda_i(J_t)|$, where $\lambda_i$ are eigenvalues. Non-normal matrices can satisfy $\|J_t\|_2>1$ while $\rho(J_t)<1$, so an operator-norm penalty can reject asymptotically stable but expressive loops. Use $L_{\mathrm{spec}}=\operatorname{ReLU}(\rho(J_t)-r)^2$ with target margin $0<r<1$. Optionally control finite transient amplification with $L_{\mathrm{trans}}=\operatorname{ReLU}(\max_{1\leq k\leq K}\|J_t^k\|_2-g)^2$, where $K$ is a short horizon and $g$ is an allowed gain.
Implementation notes
Add the regularizer to a tied recurrent transformer during training, using the Jacobian of one or a few sampled loop states rather than unrolling every state. At each optimizer step, select a minibatch and loop index t, flatten h_t, and define a Jacobian-vector product function v -> J_t v using automatic differentiation through the update h_next=A*h_t+Block(h_t+e)-(h_t+e). For small d or short sequences, explicitly materialize J_t and compute eigenvalues with eigvals; for realistic models use a blockwise approximation and 8-16 Arnoldi iterations to estimate the largest-magnitude eigenvalue. Set r=0.95 initially and add lambda_spec*[max(0,rho-r)]^2 to the task loss. To avoid severe transient explosions, optionally estimate ||J^k||_2 by power iteration on K=3 powers of the JVP and add the transient term with g=2 or 4. Backpropagate through the differentiable eigensolver when available; otherwise stop gradients through the estimated rho and use it as a controller that increases lambda_spec when rho exceeds r. The paper's mathematical quantity is rho(J); the empirical estimate is the Arnoldi or power-iteration approximation. First test a 4-loop, 2-layer tied transformer on a delayed-copy task and CIFAR-10, comparing no regularizer, operator-norm regularization, and spectral regularization at equal training FLOPs. Measure loss stability, gradient spikes, final accuracy, estimated rho, and transient amplification. The desired result is lower divergence frequency and better accuracy than norm control, while allowing some ||J||_2>1.
Verification
Stage 1 · Toy mechanism gate: Passed ✓
Stage 2 · Mechanism transferred to benchmark: Not reproduced ✗
Stage 2 · Practical benchmark result: Significantly worse ✗
Methodology: 8 paired seeds, permutation test (p<0.05) against a learning-rate-tuned baseline. How verification works
Stage 1 — Mechanism check agent confidence 8/10
Implemented the spectral-radius regularizer and verified its mechanism on non-normal Jordan loops. The spectral radius stayed at 0.8 across shear values, observed norm scaling was 0.954 versus predicted 1, observed transient-gain scaling was 2.040 versus predicted 2, and the scalar stability-boundary sweep was 100% correct. The learned comparison showed spectral control allowing norm 1.503 with rho 0.878, but it did not outperform operator control on final MSE.
- Agent confidence
- 8/10
- Baseline
- Unregularized final MSE 4.71e-15, rho 1.235, norm 1.574, transient gain 3.772.
- Idea
- Spectral final MSE 2.57e-12, rho 0.878, norm 1.503, transient gain 2.471.
- Toy
- rho error 0, boundary accuracy 1.0, norm slope 0.954, transient-gain slope 2.040.
Limitations: Only a tiny 2D linear recurrent learner was tested; no tied recurrent transformer, delayed-copy task, or CIFAR-10. The toy used an exact eigensolver rather than Arnoldi/JVP estimation, and the transient term was measured but not trained.
How to run: python3 spectral_margin_experiment.py
Stage 2 — Benchmark vs. tuned baseline (arXiv:2607.10681)
Significantly WORSE than the tuned baseline (+2.9%, p=0.0163, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0055
- Idea mean
- 0.0057
- Effect (Δ)
- 0.0002 (+2.9%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0163 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±2.9%
- Mechanism
- Not confirmed ✗
- Practical effect
- Hurts
- Baseline tuning
- swept over 9 configs
The exact 64-dimensional GRU Jacobian was evaluated on CPU because cuDNN Jacobian evaluation failed; Arnoldi estimation and the optional transient regularizer were not tested. The benchmark used n_train=400, n_test=400, and 8 epochs rather than the full default dataset and longer training. The mechanism signature sampled one recurrent transition per trained model and found no norm2>1 cases.
How to run: python3 spectral_margin_bench.py
Verdict computed by deterministic test code from paired-seed statistics — not by the language model.
Stage 2 — Benchmark latest Failed ✗
Agent confidence: 10/10
Implemented and ran the full Stage-2 benchmark on the registered dynamics track with rnn_small, an equal-grid tuned operator-norm baseline, and 8 paired seeds. The spectral-margin idea was significantly worse: delta_mean=+0.0001590732 MSE, permutation p=0.0163, with 0/8 paired wins. The trained-model mechanism signature was not confirmed because no measured spectral model had norm2>1 while rho<1.
- Baseline
- Best operator baseline lr=0.003, lam=1.0; mean MSE 0.0055261581 over 8 seeds.
- Delta mean
- 0.00015907315537333488
- Idea
- Selected spectral setting lr=0.003, lam=0.5; mean MSE 0.0056852312 over 8 seeds.
- P value
- 0.0163
Benchmark result
Significantly WORSE than the tuned baseline (+2.9%, p=0.0163, wins 0 / 8 paired seeds).
- Benchmark
- Dynamics forecasting
- Model
- rnn_small
- Paired seeds
- 8
- Baseline mean
- 0.0055
- Idea mean
- 0.0057
- Effect (Δ)
- 0.0002 (+2.9%; negative = idea better)
- Wins
- 0 / 8 paired seeds
- p-value
- 0.0163 (permutation test, 20 000 shuffles)
- Smallest detectable effect
- ±2.9%
- Mechanism
- Not confirmed ✗
- Practical effect
- Hurts
- Baseline tuning
- swept over 9 configs
The exact 64-dimensional GRU Jacobian was evaluated on CPU because cuDNN Jacobian evaluation failed; Arnoldi estimation and the optional transient regularizer were not tested. The benchmark used n_train=400, n_test=400, and 8 epochs rather than the full default dataset and longer training. The mechanism signature sampled one recurrent transition per trained model and found no norm2>1 cases.
How to run: python3 spectral_margin_bench.py
Artifacts
- bench_report.json 17.0 KB View Raw
- report.md 1.3 KB View
- report_bench_2026-08-31T005703.md 5.5 KB View
- results.json 10.7 KB View Raw
- spectral_margin_bench.py 6.6 KB View Raw
- spectral_margin_experiment.py 6.2 KB View Raw