Standard neural networks treat weight matrices as unstructured, permutation-invariant point clouds. After training with isotropic ~12.6% of Frobenius energy lies below normalized frequency
Dirichlet Regularization (dreg) introduces a simple geometric inductive bias during training: neighboring entries on a 2D weight lattice should vary smoothly, analogous to topographic organization in biological cortex.
By combining scale-invariant Riemannian Rayleigh normalization ($\mathcal{R}(W) = \sum \Delta^2 / (2|W|_F^2)$) with parameter-weighted layer aggregation, dreg eliminates rectangular FFN gradient starvation and concentrates 91.6% (Attention) and 94.2% (FFN) of total Frobenius energy below .tritq) that beats both unregularized TritQ (4.04× lower PPL at 1.638 bpp, 11.4× lower PPL at sub-1-bit 0.914 bpp) and Spatial Group-wise INT2 (g=64, 2.19× lower PPL using 27% fewer bits).
Figure 1: Emergent 2D Cortical Weight Manifolds in TinyStories-10M (10,000 steps, seed 42). Representative Layer-3 weights (
mlp.gate_projtop,attn.q_projbottom). Left: Standard AdamW yields white-noise geometry (12.9%/12.5%energy$\le 0.40$ ). Right: Rayleigh + parameter-weighted Dirichlet annealing ($\lambda = 2.0 \to 0$ ) induces continuous cortical-like weight manifolds across both rectangular FFN and square Attention projections (94.1%/91.4%energy$\le 0.40$ ).
Standard
Because the eigenvectors of the 1D Neumann Laplacian are exactly the orthonormal Type-II DCT basis vectors,
Weighting each layer by its parameter share normalization="rayleigh_sg" detaches
Figure 2: Layer-Averaged 2D-DCT Spectral Compaction (all 24 FFN & 32 Attention layers, TinyStories-10M, 10k steps). Legacy
numel+uniform(purple) starves FFNs at21.7%vs.54.5%Attention. Scale-invariantrayleigh + param_weighted(teal) eliminates FFN starvation completely (94.1%FFN /91.4%Attention vs.12.9%/12.5%Standard AdamW).
pip install dirichlet-regularizationOr from source:
git clone https://github.com/mcarbonell/dirichlet-regularization.git
cd dirichlet-regularization
pip install -e .Optional extras:
pip install -e ".[examples]" # torchvision + matplotlib for examples
pip install -e ".[dev]" # pytest, pytest-cov, rufffrom dreg import DirichletLoss, StepCooldownScheduler
# Automatically skips nn.Embedding, lm_head, frozen weights, and deduplicates tied weights.
# For from-scratch training: normalization="rayleigh", weight_decay=1.0–2.0 + StepCooldownScheduler.
# For pre-trained LLM adaptation: normalization="rayleigh_sg" (scale lambda ~ N_total * sigma_W).
topo_reg = DirichletLoss(
weight_decay=2.0,
normalization="rayleigh",
layer_weighting="param_weighted",
)
topo_sched = StepCooldownScheduler(topo_reg, total_steps=10_000, cooldown_ratio=0.15)
# Inside your training loop:
task_loss = criterion(model(inputs), targets)
topo_sched.step()
total_loss = task_loss + topo_reg(model)
total_loss.backward()Controlled multi-seed (seeds = 42, 100, 2024) evaluation on 25 validation batches (204,800 tokens; full logs in results/tmlr_10000s_mseclip_multiseed_results.json):
Condition (10k, N=3) |
FP32 PPL | Attn / FFN |
0.430 bpp (74×) |
0.914 bpp (35×) |
1.638 bpp (19.5×) |
2.181 bpp (14.7×) |
2.794 bpp (11.5×) |
|---|---|---|---|---|---|---|---|
| Standard ( |
5.81 ± 0.01 | 12.6% / 12.9% | 3472.7 ± 950.0 | 1085.5 ± 214.1 | 68.21 ± 6.94 | 19.70 ± 0.70 | 9.79 ± 0.17 |
| Rayleigh ( |
7.39 ± 0.02 | 91.3% / 95.0% | 1914.7 ± 558.8 | 223.8 ± 134.7 | 23.74 ± 6.51 | 11.77 ± 1.87 | 8.68 ± 0.50 |
| Rayleigh ( |
8.19 ± 0.06 | 96.2% / 98.3% | 1302.0 ± 395.5 | 120.6 ± 40.3 | 23.46 ± 5.71 | 12.48 ± 1.76 | 9.14 ± 0.03 |
| Rayleigh Anneal ( |
7.78 ± 0.05 | 91.6% / 94.2% | 1131.4 ± 317.5 | 95.60 ± 28.26 | 16.87 ± 1.73 | 10.71 ± 0.64 | 8.56 ± 0.07 |
SOTA PTQ Baselines on the exact same 10k N=3 Standard models:
- Spatial Group-wise INT2 (
g=64,2.25 bpp):36.91 ± 6.03 PPL— beaten 2.19× by our1.638 bppmodel (27% fewer bits) and 3.45× by our2.181 bppmodel (10.71 ± 0.64 PPL). - Spatial Uniform INT2 (
2.00 bpp):47.39 ± 7.90 PPL(2.81× worse than our1.638 bpp). - Budget-Matched Quantized SVD (
INT8,~1.64 bpp):555.65 ± 65.74 PPL(32.9× worse). - Zero-Bit-Overhead Quantizer Ablation (
1.638 bpp,rayleigh_anneal2,N=3):minmax + legacy(51.55 ± 3.90) →+ Lloyd–Max Band-2(31.62 ± 2.88) →+ MSE-Clip Band-0/1(16.87 ± 1.73; verified on-disk.tritqround-trip16.702 == 16.702).
Figure 3: (a) 2k-step Rayleigh calibration sweep showing balanced Attn/FFN compaction (
12.7% → 97.8%) and monotonic compression gains. (b) Converged 10k multi-seed (N=3) rate–distortion frontier vs. SOTA PTQ baselines.
1,500-step rayleigh_sg + param_weighted adaptation (lr=3e-4, A10G, results/gpt2_124m_rayleigh_sg_1500s_results.json):
| GPT-2 (124M) Variant | FP32 | Attn / FFN |
1.63 bpp |
2.18 bpp |
2.79 bpp |
3.77 bpp |
Spatial INT4 (4.0b) |
|---|---|---|---|---|---|---|---|
| Base Pre-Trained (0 steps) | 11.96 | 12.6% / 12.9% | 8355.36 | 5474.80 | 2638.98 | 1761.02 | 2440.52 |
| Standard Fine-Tuned ( |
4.65 | 12.6% / 12.9% | 4130.36 | 4050.95 | 2546.29 | 684.46 | 1449.10 |
rayleigh_sg ( |
5.35 | 32.8% / 37.2% | 2052.39 | 638.34 | 152.76 | 31.96 | 963.10 |
rayleigh_sg Anneal ( |
12.93 | 71.2% / 76.8% | 281.84 | 117.55 | 43.20 | 21.62 | 997.09 |
rayleigh_sg ( |
18.64 | 73.0% / 79.2% | 178.71 | 60.35 | 33.07 | 23.37 | 1115.46 |
- Cuts weight roughness by −95.6% (
0.033514 → 0.001464) and reduces compressed perplexity by 23×–77× across1.63–3.77 bpp(beating Group INT2g=643209.12 PPLat2.25 bppby 53.2× at2.18 bpp).
| Metric | Standard MLP | Topographic MLP (dreg, |
Gain |
|---|---|---|---|
| FP32 Test Accuracy | 97.87% | 97.58% |
|
Dirichlet Energy (numel) |
0.0219 | 0.0034 | |
| Low-Frequency Energy ( |
27.87% | 52.84% | |
| Low-Pass Truncation Acc ( |
30.69% | 41.41% | +10.72% abs. |
Base-3 TritQ Acc (1.64 bpp) |
87.40% | 88.59% | +1.19% accuracy |
-
Exact Base-3 Trit Packing + Zero-Overhead Optimal Quantization: 5 balanced trits
${-1, 0, +1}$ pack bijectively into 1 byte ($3^5 = 243 \le 256 \Rightarrow 1.60\text{ bits/trit}$ ), paired with 1D Lloyd–Max Band-2 scaling and MSE-optimal asymmetric clipping on Bands 0 & 1 (band01_mode="mse_clip"), decoded in$\mathcal{O}(1)$ via a1.25 KBL1-cache LUT. Non-topographic parameters (token_emb,lm_head, LayerNorms) stay uncompressed in FP16. -
Portable C11 Micro-Kernel (
kernel/spectral_dma_kernel.c):-
Zero-copy async DMA double-buffering (Win32 Events / POSIX pthreads) verified to
3.6e-7float32 parity against PyTorch. -
Direct Spectral-Domain Streaming MatVec (
c_spectral_matvec_direct): Computes $y = \operatorname{IDCT}{1D}(S \cdot \operatorname{DCT}{1D}(x))$ via radix-2$\mathcal{O}(N \log N)$ Makhoul 1D-DCT directly from.tritqbitstreams without materializing$M \times N$ weights or storing DCT basis tables — cutting1024×256FFN working SRAM from8,448 KBdown to13.0 KB(650×reduction) and running45.6×faster than full-matrix 2D-IDCT reconstruction (8.9e-7float32 parity).
-
Zero-copy async DMA double-buffering (Win32 Events / POSIX pthreads) verified to
# 1. Run the master end-to-end verification suite (102 tests + C parity + trained MLP + controls)
python examples/reproduce_all.py
# 2. Build and benchmark the native C11 DMA & direct spectral micro-kernel
python kernel/build_kernel.py
python examples/benchmark_c_dma.py
# 3. Train a small Topographic Transformer or MNIST MLP locally
python examples/train_topographic.py
python examples/train_mlp_dirichlet.py --dataset mnist --epochs 5
python examples/evaluate_falsification.pydirichlet-regularization/
├── dreg/ # Core Python package
│ ├── topology.py # 2D Dirichlet energy (numel/edges/rayleigh/rayleigh_sg), DirichletLoss & schedulers
│ ├── spectral.py # Orthonormal 1D/2D-DCT/IDCT (float64 angles), spectral_matvec & BlockDCTTiler
│ ├── quantization.py # Base3TritQuantizer (mse_clip + lloyd_max) & .tritq binary checkpoint format
│ ├── model.py # Reference TopographicTransformer & TopographicLinear
│ └── baselines.py # Haar random orthogonal rotation & truncated SVD controls
├── kernel/ # Native C11 zero-copy DMA & direct spectral matvec micro-kernel
│ ├── spectral_dma_kernel.c # O(1) trit LUT, Win32/POSIX async DMA, radix-2 Makhoul 1D-DCT streaming matvec
│ ├── build_kernel.py # Cross-platform compiler wrapper (gcc/clang/cl)
│ └── Makefile
├── examples/ # Local CPU/GPU reproducible scripts
├── benchmarks/ # Modal cloud A10G multi-seed training, GPT-2, SOTA PTQ & figure pipelines
├── results/ # Raw JSON logs backing all paper Tables 1–6 and ablations
├── paper/ # Academic manuscript (LaTeX source, BibTeX, 300-DPI figures, PDF)
│ ├── paper-draft.pdf
│ ├── paper-draft.tex
│ ├── references.bib
│ └── figures/
├── tests/ # 102 automated unit, integration, and C-kernel tests
├── CITATION.cff
├── pyproject.toml
└── README.md
Read the full manuscript in paper/paper-draft.pdf:
"Inducing Spectral Smoothness in Neural Weight Manifolds via 2D Dirichlet Regularization"
Mario Raúl Carbonell Martínez (Independent Researcher)
@misc{carbonell2026dirichlet,
title={Inducing Spectral Smoothness in Neural Weight Manifolds via 2D Dirichlet Regularization},
author={Carbonell Mart{\'i}nez, Mario Ra{\'u}l},
year={2026},
howpublished={\url{https://github.com/mcarbonell/dirichlet-regularization}}
}MIT License — see LICENSE for details.


