Three-Phase Transformer
Organizations: Brains Build Research, Ramallah, Palestine
Abstract
We present Three-Phase Transformer (3PT), a residual-stream structural prior for decoder-only Transformers on a standard SwiGLU + RMSNorm + RoPE + GQA backbone. The hidden vector is partitioned into N equally-sized cyclic channels, each maintained by phase-respecting ops: a per-channel RMSNorm, a 2D Givens rotation between attention and FFN that rotates each channel by theta + i*(2*pi/N), and a head-count constraint aligning GQA heads with the partition. The architecture is a self-stabilizing equilibrium between scrambling and re-imposition, not a bolted-on module. The partition carves out a one-dimensional DC subspace orthogonal to the channels, into which we inject a fixed Gabriel's horn profile r(p) = 1/(p+1) as an absolute-position side-channel composing orthogonally with RoPE's relative-position rotation. The canonical N=3 borrows its metaphor from balanced three-phase AC, where three sinusoids 120 degrees apart sum to zero with no anti-correlated pair. At 123M parameters on WikiText-103, 3PT achieves -7.20% perplexity (-2.62% bits-per-byte) over a matched RoPE-Only baseline at +1,536 parameters (0.00124% of total), with 1.93x step-count convergence speedup (1.64x wall-clock). N behaves as a parameter-sharing knob rather than a unique optimum: at 5.5M an N-sweep over {1,2,3,4,6,8,12} is near-monotone with N=1 winning; at 123M a three-seed sweep finds N=3 and N=1 statistically indistinguishable. The load-bearing mechanism is the channel-partitioned residual stream, per-block rotation, per-phase normalization, and horn DC injection. We characterize (a) self-stabilization of the geometry without explicit enforcement, a novel instance of the conservation-law framework for neural networks; (b) a U-shaped depth profile of rotation-angle drift at 12 layers; (c) orthogonal composition with RoPE, attention, and FFN.
Figures & tables
| Rank | Variant | Final PPL | Val Loss | Time |
|---|---|---|---|---|
| 1 (winner) | B. 3Phase-Embed | 64.96 | 4.1737 | 170s |
| 2 | D. 3Phase-Full | 65.33 | 4.1795 | 179s |
| 3 | C. 3Phase-Attn | 72.77 | 4.2873 | 172s |
| 4 | A. Baseline | 73.17 | 4.2928 | 162s |
| Rank | Variant | Final PPL | Val Loss | Time |
|---|---|---|---|---|
| 1 (winner) | A. RoPE | 53.85 | 3.9862 | 150s |
| 2 | C. RoPE+YaRN | 55.07 | 4.0086 | 153s |
| 3 | D. 3Phase | 62.29 | 4.1317 | 165s |
| 4 | B. Sinusoidal | 69.70 | 4.2442 | 145s |
| Rank | Variant | Final PPL | Val Loss | Time |
|---|---|---|---|---|
| 1 (winner) | G. 3PhLrn+RoPE | 45.58 | 3.8195 | 183s |
| 2 | F. 3Ph+RoPE | 46.20 | 3.8330 | 179s |
| 3 | A. RoPE | 53.85 | 3.9862 | 152s |
| 4 | C. YaRN | 55.07 | 4.0086 | 155s |
| 5 | E. 3Phase-Lrn (no RoPE) | 61.58 | 4.1203 | 171s |
| 6 | D. 3Phase (no RoPE) | 62.29 | 4.1317 | 164s |
| # | Variant | Final PPL | Val Loss | Time | vs Baseline |
|---|---|---|---|---|---|
| 1 | 1. Baseline (= G) | 45.48 | 3.8172 | 186s | — |
| 2 | 2. +Align | 45.39 | 3.8154 | 200s | −0.08 |
| 3 (winner) | 3. +PhRMS | 45.22 | 3.8115 | 202s | −0.26 |
| 4 | 4. +HardZS | 46.58 | 3.8411 | 198s | +1.10 |
| 5 | 5. +PhDrop | 52.44 | 3.9597 | 198s | +6.96 |
| 6 | 6. +Shrink | 62.21 | 4.1306 | 170s | +16.74 |
| Rank | Code | Flags ON | PPL | Loss | Time |
|---|---|---|---|---|---|
| 1 | ArhdsL | Align + LrnOff | 44.687 | 3.7997 | 193s |
| 2 | Arhdsl | Align only | 44.747 | 3.8010 | 192s |
| 3 | ARhdsL | Align + PhRMS + LrnOff | 44.758 | 3.8013 | 199s |
| 4 | ARhdsl | Align + PhRMS | 44.762 | 3.8014 | 198s |
| 5 | arhdsL | LrnOff only | 45.128 | 3.8095 | 186s |
| Flag | Δ PPL ON vs OFF | Verdict |
|---|---|---|
| Align | −0.74 | Only real winner |
| LrnOff | −0.005 | Pure noise |
| HardZS | +1.22 | Hurts |
| PhRMS | +1.91 | Hurts at 2k steps (flips at 20k - see Experiment 5) |
| PhDrop | +4.12 | Hurts badly |
| Shrink | +9.06 | Catastrophic |
| Rank | Variant | Params | Final PPL | Val Loss | Time |
|---|---|---|---|---|---|
| baseline | RoPE-Only Transformer | 5,463,744 | 17.0564 | 2.8365 | 1,348s |
| 1 (winner) | ARhdsL (Align + PhRMS + LrnOff) | 5,463,910 | 14.7873 | 2.6938 | 1,687s |
| 2 | ARhdsl (Align + PhRMS) | 5,463,907 | 14.7895 | 2.6939 | 1,640s |
| 3 | ArhdsL (Align + LrnOff) | 5,463,910 | 14.8060 | 2.6950 | 1,574s |
| 4 | Arhdsl (Align only) | 5,463,907 | 14.8128 | 2.6955 | 1,617s |
| Rank | Variant | Params | Final PPL | Val Loss | Time |
|---|---|---|---|---|---|
| baseline | RoPE-Only Transformer (from Exp. 5) | 5,463,744 | 17.0564 | 2.8365 | — |
| 1 (winner) | ChannelStructure (no sinusoidal PE) | 5,463,875 | 14.4012 | 2.6673 | 1,612s |
| 2 | PhaseAlignedHeads + PhaseAwareRMSNorm + LrnOff (ref.) | 5,463,910 | 14.7873 | 2.6938 | 1,726s |
| 3 | PhaseAlignedHeads + PhaseAwareRMSNorm (ref.) | 5,463,907 | 14.7895 | 2.6939 | 1,656s |
| Rank | Variant | Params | Final PPL | Val Loss | Time |
|---|---|---|---|---|---|
| 1 (winner) | NoScale variant | 5,463,872 | 13.9712 | 2.6370 | 1,604s |
| # | Variant | use_zero_sum | residual_pr | Final PPL | Val Loss | Time |
|---|---|---|---|---|---|---|
| 1 (winner) | A_baseline_winner | True | False | 13.9712 | 2.6370 | 1,471s |
| 2 | B_no_zero_sum | False | False | 14.0015 | 2.6392 | 1,465s |
| 3 | C_no_zero_sum + residual_pr | False | True | 14.0602 | 2.6433 | 1,475s |
| # | Variant | zero_mean | aux_loss | horn | Final PPL | Val Loss | Time |
|---|---|---|---|---|---|---|---|
| 1 (winner) | C_gabriels_horn | False | False | True | 13.9015 | 2.6320 | 1,519s |
| 2 | A_zero_mean_only | True | False | False | 13.9712 | 2.6370 | 1,477s |
| 3 | B_aux_loss_only | False | True | False | 14.0047 | 2.6394 | 1,512s |
| # | Variant | Final PPL | Val Loss | Time | Params |
|---|---|---|---|---|---|
| 1 (winner) | learnable_gabriels_horn | 13.8810 | 2.6305 | 1,451s | 5,464,001 |
| # | Model | Final PPL | Final BPB | Val Loss | Params | Time |
|---|---|---|---|---|---|---|
| 1 (baseline) | RoPE-Only Vanilla 123M | 17.31 | 1.1148 | 2.8513 | 123,489,024 | 6,636s |
| 2 (winner) | ThreePhase + Gabriel's horn 123M | 16.06 | 1.0855 | 2.7765 | 123,490,560 | 7,777s |
| Block | init θ̄ | final θ̄ | L2 drift | direction |
|---|---|---|---|---|
| 0 | 0.131 | 0.178 | 0.541 | grew (+36%) |
| 1 | 0.262 | 0.282 | 0.238 | grew |
| 2 | 0.393 | 0.397 | 0.069 | nearly fixed ← min |
| 3 | 0.524 | 0.515 | 0.112 | shrank slightly |
| 4 | 0.654 | 0.635 | 0.232 | shrank |
| 5 | 0.785 | 0.755 | 0.348 | shrank |
| # | Seed | Final PPL | Val Loss | Time |
|---|---|---|---|---|
| 1 | 1 | 13.7940 | 2.6242 | 1,633s |
| 2 | 100 | 13.8252 | 2.6265 | 1,602s |
| 3 | 40 | 13.8363 | 2.6273 | 1,616s |
| 4 | 13 | 13.8929 | 2.6314 | 1,629s |
| 5 | 42 | 13.9015 | 2.6320 | 1,519s |
| N | d_phase | n_thetas | Heads (Q/KV) | d_head | Phase offset |
|---|---|---|---|---|---|
| 1 | 192 | 96 | 6/3 | 32 | 360° (degenerate) |
| 2 | 96 | 48 | 4/2 | 48 | 180° |
| 3 | 64 | 32 | 6/3 | 32 | 120° (canonical) |
| 4 | 48 | 24 | 8/4 | 24 | 90° |
| 6 | 32 | 16 | 12/6 | 16 | 60° |
| 8 | 24 | 12 | 16/8 | 12 | 45° |
| N | Thetas/blk | Final PPL | Val Loss | Time |
|---|---|---|---|---|
| 1 | 96 | 13.6268 (winner) | 2.6120 | 1,525s |
| 2 | 48 | 13.6812 | 2.6160 | 1,551s |
| 3 | 32 | 13.9015 | 2.6320 | ~1,519s |
| 4 | 24 | 13.8674 | 2.6295 | 1,886s |
| 6 | 16 | 13.9780 | 2.6375 | 1,954s |
| 8 | 12 | 14.0090 | 2.6397 | 2,495s |
| # | Variant | Final BPB | Final PPL | Val Loss | Params | Time |
|---|---|---|---|---|---|---|
| 1 (winner) | ThreePhase N=3 123M | 1.0855 | 16.0631 | 2.7765 | 123,490,560 | 7,777s |
| 2 | OnePhase N=1 123M | 1.0880 | 16.1656 | 2.7829 | 123,493,632 | 7,196s |
| # | Seed | Final PPL | Final BPB | Val Loss | Time |
|---|---|---|---|---|---|
| 1 (best) | 42 | 16.0631 | 1.0855 | 2.7765 | 7,777s |
| 2 | 100 | 16.2145 | 1.0892 | 2.7859 | 7,774s |
| 3 | 1 | 16.2393 | 1.0898 | 2.7874 | 7,722s |
| # | Seed | Final PPL | Final BPB | Val Loss | Time |
|---|---|---|---|---|---|
| 1 (best) | 100 | 16.0078 | 1.0842 | 2.7731 | 7,178s |
| 2 | 1 | 16.11 | 1.0866 | 2.7792 | 7,182s |
| 3 | 42 | 16.1656 | 1.0880 | 2.7829 | 7,196s |
| Seed | N=3 PPL | N=1 PPL | Δ PPL (N=3 − N=1) | Winner at this seed |
|---|---|---|---|---|
| 1 | 16.2393 | 16.11 | +0.1293 | N=1 |
| 42 | 16.0631 | 16.1656 | −0.1025 | N=3 (Exp. 14) |
| 100 | 16.2145 | 16.0078 | +0.2067 | N=1 |
| Rank | Model | Params | Trained on WT103? | Val Loss | PPL | BPB |
|---|---|---|---|---|---|---|
| 1 | neulab/gpt2-large-finetuned-wikitext103 | 838.4M | yes | 2.6363 | 13.9615 | 0.8366 |
| 2 | neulab/gpt2-med-finetuned-wikitext103 | 406.3M | yes | 2.9085 | 18.3299 | 0.9230 |
| 3 | neulab/gpt2-finetuned-wikitext103 | 163.0M | yes | 3.0788 | 21.7322 | 0.9770 |
| 4 | neulab/distilgpt2-finetuned-wikitext103 | 120.5M | yes | 3.1490 | 23.3138 | 0.9993 |
| 5 | ThreePhase 123M (N=3, seed 42) | 123.5M | yes | 2.7765 | 16.0631 | 1.0855 |
| 6 | OnePhase 123M (N=1, seed 42) | 123.5M | yes | 2.7829 | 16.1656 | 1.0880 |
| Architecture step | PPL | Params |
|---|---|---|
| Start: Experiment 5 winner (sinusoidal PE + learnable freqs + LrnOff + PhaseAlignedHeads + PhaseAwareRMSNorm) | 14.7873 | 5,463,910 |
| Removed LearnableOffsets (→ fixed 120°) | 14.7895 (noise) | 5,463,907 |
| Removed sinusoidal PE entirely (→ Experiment 6, ChannelStructure) | 14.4012 (record) | 5,463,875 |
| Removed phase_scale + √d_model scaling (→ Experiment 7) | 13.9712 (record) | 5,463,872 |
| Added Gabriel's horn (→ Experiment 9, canonical 5.5M winner) | 13.9015 (record) | 5,463,872 |
| 123M scale-up (→ Experiment 11) | 16.06 PPL / 1.0855 BPB | 123,490,560 |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 535 papers