Residual Koopman Spectral Profiling for Predicting and Preventing Transformer Training Instability
Organizations: Graduate School of Engineering, The University of Tokyo, Japan
Abstract
Training divergence in transformers wastes compute, yet practitioners discover instability only after expensive runs begin. They therefore need an expected probability of failure for a transformer before training starts. Our study of Residual Koopman Spectral Profiling (RKSP) provides such an estimate. From a single forward pass at initialization, RKSP extracts Koopman spectral features by applying whitened dynamic mode decomposition to layer-wise residual snapshots. Our central diagnostic, the near-unit spectral mass, quantifies the fraction of modes concentrated near the unit circle, which captures instability risk. For predicting divergence across extensive configurations, this estimator achieves an AUROC of 0.995, outperforming the best gradient baseline. We further make this diagnostic actionable through Koopman Spectral Shaping (KSS), which reshapes spectra during training. We empirically validate that our method works in practice: RKSP predicts divergence at initialization, and when RKSP flags high risk, turning on KSS successfully prevents divergence. In the challenging high learning rate regime without normalization layers, KSS reduces the divergence rate from 66.7% to 12.5% and enables learning rates that are 50% to 150% higher. These findings generalize to WikiText-103 language modeling, vision transformers on CIFAR-10, and pretrained language models, including GPT-2 and LLaMA-2 up to 7B, as well as emerging architectures such as MoE, Mamba-style SSMs, and KAN.
Figures & tables
| Norm Type | Div.% (lower) | Acc.% (higher) | ||||
|---|---|---|---|---|---|---|
| Pre-LN | 25 | |||||
| Post-LN | 69 | |||||
| RMSNorm | 12 | |||||
| DeepNorm | 12 | |||||
| SubLN | 12 | |||||
| No-Norm | 84 |
| Predictor | AUROC (higher) | 95% CI | Timing |
|---|---|---|---|
| at initialization | Initialization | ||
| Initialization | |||
| Spectral radius at init | Initialization | ||
| Eigenvector condition at init | Initialization | ||
| Gradient-Based Baselines | |||
| Initial gradient norm | After 1 step | ||
| Method | Div.% (lower) | Acc.% (higher) | Overhead | |
|---|---|---|---|---|
| No control | — | |||
| Gradient clip 0.5 | ||||
| Gradient clip 1.0 | ||||
| KSS | ||||
| KSS | ||||
| KSS |
| Method | Div.% (lower) | Acc.% (higher) | Overhead |
|---|---|---|---|
| No stabilization, AdamW | — | ||
| Gradient clipping at 1.0 | |||
| Spectral normalization | |||
| Weight normalization | |||
| Gradient penalty with | |||
| Advanced Optimizers | |||
| Norm Type | Max LR w/o KSS | Max LR w/ KSS | Increase |
|---|---|---|---|
| Pre-LN | |||
| RMSNorm | |||
| No-Norm |
| Method | Div.% (lower) | Acc.% (higher) | Mechanism | |
| No regularization | — | |||
| Generic Regularization, about 11% overhead | ||||
| Random on residuals | Magnitude damping | |||
| Jacobian penalty | Gradient smoothness | |||
| Activation variance reg. | Distribution control | |||
| Spectral-Specific Regularization, about 11% overhead | ||||
| Model | Params | Method | Div. of 24 (lower) | PPL (lower) | Overhead |
|---|---|---|---|---|---|
| Extra Large, , | 350M | Baseline | 6 of 24 | — | |
| Extra Large, , | 350M | KSS | 3 of 24 |
| Model | Params | Method | Div. of 24 (lower) | PPL (lower) | Max LR | Steps |
|---|---|---|---|---|---|---|
| Small, , | 25M | Baseline | 2 of 24 | 10K | ||
| Small, , | 25M | KSS | 0 of 24 | 10K | ||
| Medium, , | 85M | Baseline | 4 of 24 | 10K | ||
| Medium, , | 85M | KSS | 1 of 24 | 10K | ||
| Large, , | 125M | Baseline | 5 of 24 | 10K | ||
| Large, , | 125M | KSS | 2 of 24 | 10K |
| Model | Norm | Method | Div. of 24 (lower) | Acc.% (higher) | |
|---|---|---|---|---|---|
| ViT-Tiny, , | Pre-LN | Baseline | 1 of 24 | ||
| ViT-Tiny, , | Pre-LN | KSS | 0 of 24 | ||
| ViT-Tiny, , | RMSNorm | Baseline | 2 of 24 | ||
| ViT-Tiny, , | RMSNorm | KSS | 0 of 24 |
| Layer Group | Pattern | |||
|---|---|---|---|---|
| Early 0 to 10 | Lower | |||
| Middle 11 to 21 | Mid | |||
| Late 22 to 31 | Higher |
| Architecture | Stability Character | |||
|---|---|---|---|---|
| Transformer, Pre-LN | Balanced, tunable | |||
| Transformer, No-Norm | High memory, risky | |||
| MoE, top-2, 8 experts | Routing-dependent | |||
| Mamba (SSM) | Contractive, short-memory | |||
| KAN | Higher |
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Meaning |
|---|---|
| Core sizes and indices | |
| The number of layers. | |
| Layer index. | |
| Hidden dimension. | |
| The number of snapshots. | |
| Randomized DMD rank, the number of eigenvalues used in KSS. | |
| Method | Div.% (lower) | Acc.% (higher) | Transfer | Overhead | |
|---|---|---|---|---|---|
| Standard Init, AdamW | ✗ | — | |||
| P, width transfer | ✓ | ||||
| P + higher learning rate | ✓ | ||||
| KSS, | ✗ | ||||
| P + KSS | ✓ |
| Optimizer | Div.% (lower) | Acc.% (higher) | Best LR | Overhead | |
| AdamW | — | ||||
| AdamW + grad clip | |||||
| LAMB | about 5% | ||||
| LAMB + warmup | about 5% | ||||
| Lion | about 15% | ||||
| KSS, |
| Model | Layers | ||||
|---|---|---|---|---|---|
| GPT-2 124M | Early 0 to 3 | ||||
| GPT-2 124M | Middle 4 to 7 | ||||
| GPT-2 124M | Late 8 to 11 | ||||
| GPT-2 355M | Early 0 to 7 | ||||
| GPT-2 355M | Middle 8 to 15 | ||||
| GPT-2 355M | Late 16 to 23 |
| Configuration | Top- | Div. of 24 | Acc.% | |||
|---|---|---|---|---|---|---|
| MoE-Small, 8 experts | 6 of 24 | |||||
| MoE-Small, 8 experts | 2 of 24 | |||||
| MoE-Small, 8 experts | 1 of 24 | |||||
| MoE-Medium, 16 experts | 4 of 24 | |||||
| MoE-Medium, 16 experts | + KSS | 1 of 24 |
| Model | Div. of 24 | Acc.% | |||
|---|---|---|---|---|---|
| Mamba-Small, | 0 of 24 | ||||
| Mamba-Medium, | 0 of 24 | ||||
| Transformer, Pre-LN, comparable | 1 of 24 |
| Model | Div. of 24 | DMD reliability | |||
|---|---|---|---|---|---|
| KAN-Transformer, | 3 of 24 | Marginal, 68% | |||
| KAN-Transformer, | 4 of 24 | Low, 52% | |||
| KAN-Transformer + KSS | 1 of 24 | Improved, 78% |
Transformer
Transformers are neural architectures that use attention to model relationships among sequence elements in language, vision, and scientific data.
See all 540 papers