Numerical Fragility in Transformers: A Layer-wise Theory for Explaining, Forecasting, and Mitigating Instability
Abstract
Transformers trained in low precision can suffer forward-error amplification. We give a first-order, module-wise theory that predicts when and where errors grow. For self-attention we derive a per-layer bound that factorizes into three interpretable diagnostics: a score-scale ratio score, a rowwise softmax sensitivity softmax, and value conditioning (V). We prove a residual relaxation inequality showing that residual blocks attenuate depth-wise accumulation, and we introduce a precision- and width-aware LayerNorm indicator LN with a matching first-order bound in the ε-dominated regime. These pieces yield a unified forward-stability bound whose right-hand side is directly estimable during training. On Tiny-ViT/CIFAR-10 we evaluate the bound and components. (1) The combined predictor softmax,(1+ score),(V),|WO|2+ eff+C LN tracks FP32 mismatches across seeds, widths, and precisions; scaling by ε mach collapses mixed-precision points. (2) The time-series maximum of softmax acts as an early-warning signal, leading error spikes by 16-24 steps (corr. 0.65-0.82; permutation p!≈!10-3; Precision@K 0.89-1.00). (3) Guided by LN, a small LayerNorm-ε tweak targeting gives consistent stabilization (mean tail-loss \ ≈0.010 at !=!0.6, cap=10-2) with negligible overhead. Overall, our theory supplies actionable, unitless diagnostics that (i) explain when self-attention is fragile, (ii) forecast instability, and (iii) motivate a minimally invasive mitigation.
Turn this paper into a full lesson
ArcXiv compiles a staged curriculum from this paper: 8-12 lessons across beginner → advanced, synthesised section guides, visuals, flashcards, a quiz, exercises, and on-demand deep dives per section. Grounded in the abstract, never invented.