English

Numerical Fragility in Transformers: A Layer-wise Theory for Explaining, Forecasting, and Mitigating Instability

Machine Learning 2025-10-28 v1 Numerical Analysis Numerical Analysis

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\kappa_{\rm score}, a rowwise softmax sensitivity κsoftmax\kappa_{\rm softmax}, and value conditioning κ(V)\kappa(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\rho_{\rm LN} with a matching first-order bound in the ϵ\epsilon-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),WO2+κeff+CLN\kappa_{\rm softmax},(1+\kappa_{\rm score}),\kappa(V),|W_O|2+\kappa{\rm eff}+C_{\rm LN} tracks FP32\leftrightarrowLP mismatches across seeds, widths, and precisions; scaling by ϵmach\epsilon_{\rm mach} collapses mixed-precision points. (2) The time-series maximum of κsoftmax\kappa_{\rm softmax} acts as an early-warning signal, leading error spikes by 16-24 steps (corr. 0.65-0.82; permutation p!!103p!\approx!10^{-3}; Precision@K 0.89-1.00). (3) Guided by ρLN\rho_{\rm LN}, a small LayerNorm-ϵ\epsilon tweak targeting ρ\rho_\star gives consistent stabilization (mean tail-loss  0.010\downarrow\ \approx0.010 at ρ!=!0.6\rho_\star!=!0.6, cap=102=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.

Keywords

Cite

@article{arxiv.2510.21770,
  title  = {Numerical Fragility in Transformers: A Layer-wise Theory for Explaining, Forecasting, and Mitigating Instability},
  author = {Jinwoo Baek},
  journal= {arXiv preprint arXiv:2510.21770},
  year   = {2025}
}

Comments

15 pages

R2 v1 2026-07-01T07:04:33.770Z