Stabilizing Transformer Training by Preventing Attention Entropy Collapse
By Shuangfei Zhai, Tatiana Likhomanenko, Etai Littwin, Dan Busbridge, Jason Ramapuram, Yizhe Zhang, Jiatao Gu, J. Susskind. 2023
184 citations recorded by the source corpus.
Training stability is of great importance to Transformers. In this work, we investigate the training dynamics of Transformers by examining the evolution of the attention layers. In particular, we track the attention entropy for each attention head during the course of training, which is a proxy for model sharpness. We identify a common pattern across different architectures and tasks, where low attention entropy is accompanied by high training instability, which can take the form of oscillating loss or divergence. We denote the pathologically low attention entropy, corresponding to highly concentrated attention scores, as $\textit{entropy collapse}$. As a remedy, we propose $\sigma$Reparam, a simple and efficient solution where we reparametrize all linear layers with spectral normalization and an additional learned scalar. We demonstrate that $\sigma$Reparam successfully prevents entropy collapse in the attention layers, promoting more stable training. Additionally, we prove a tight lower bound of the attention entropy, which decreases exponentially fast with the spectral norm of the attention logits, providing additional motivation for our approach. We conduct experiments with $\sigma$Reparam on image classification, image self-supervised learning, machine translation, speech recognition, and language modeling tasks. We show that $\sigma$Reparam provides stability and robustness with respect to the choice of hyperparameters, going so far as enabling training (a) a Vision Transformer {to competitive performance} without warmup, weight decay, layer normalization or adaptive optimizers; (b) deep architectures in machine translation and (c) speech recognition to competitive performance without warmup and adaptive optimizers. Code is available at \url{https://github.com/apple/ml-sigma-reparam}.
Subfields: Artificial Intelligence, Computer Vision and Pattern Recognition, Electrical and Electronic Engineering, Model Architectures, Optimization & Training
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Luke S. Zettlemoyer
- Ali Farhadi
- Ludwig Schmidt
- Tim Dettmers
- Mitchell Wortsman
- Percy Liang
- Mohit Bansal
- Hannaneh Hajishirzi
In Computer Vision and Pattern Recognition
- Ali Farhadi
- Luke S. Zettlemoyer
- Luc Van Gool
- Mitchell Wortsman
- Trevor Darrell
- Ming-Hsuan Yang
- Ludwig Schmidt
- Dacheng Tao
In Electrical and Electronic Engineering
In Model Architectures
In Optimization & Training
- Luke S. Zettlemoyer
- Tim Dettmers
- Ali Farhadi
- Ludwig Schmidt
- Ari S. Morcos
- Mitchell Wortsman
- Torsten Hoefler
- Tal Ben-Nun
Citations in the corpus
- Stable and low-precision training for large-scale vision-language models (2023, methodology): “Loss spikes can emerge when scaling up models [8, 25, 14, 69, 71, 54, 74].”