Methods of improving LLM training stability

Oleg Rybakov, Mike Chrzanowski, Peter Dykas, Jinze Xue, Ben LanirarXiv 2024 · DOI

Introduction

Training Large Language Models (LLMs) is notoriously brittle. As models scale, they frequently encounter "divergence"—sudden, catastrophic spikes in loss that can terminate training runs costing millions of dollars. Researchers at NVIDIA have identified that this instability is driven by the explosive growth of L2 norms in the outputs of specific linear layers: QKV, Projection (Proj), and the second Feed-Forward layer (FC2).

By introducing two novel architectural modifications—QKV Layer Normalization and a combination of QK Normalization with Softmax Capping—they successfully increased the stable learning rate by 1.5x while significantly improving model perplexity compared to standard baselines.

The Mechanics of Divergence

The authors analyzed a standard Transformer block and observed that in diverging models, the L2 norms of outputs for the QKV, Proj, and FC2 layers grew more than 2x compared to stable models. This growth leads to a "one-hot" trap: when the magnitude of inputs to a softmax function becomes too large, the output becomes a one-hot vector (where one value is 1 and the rest are 0). This effectively kills the gradients for all other tokens, leading to a total loss of information flow and causing the model to stop learning.

L2 norm analysis of weights (W), inputs (X), and outputs (Y) across different layers, comparing converging (blue) and diverged (black) training runs.

Proposed Architectural Modifications

To combat this volatility, the researchers tested several targeted normalization strategies within the Transformer block. Unlike previous work that focused almost exclusively on Query and Key ($QK$) relationships, this study highlights that the Projection and FC2 layers are equally volatile.

Schematic of the Transformer block architecture, identifying the QKV, Projection, and Feed-Forward layers targeted for normalization.

The primary methods proposed include:

  • QKV Layer Normalization ($QKV\_norm$): Applying LayerNorm to the entire QKV output and removing the traditional pre-layer normalization. This simplifies the architecture while inducing stability.
  • QK Norm + Softmax Capping ($QK\_norm\_cap$): Combining $QK\_norm$ with a $tanh$ capping function that prevents logit values from exceeding a specific threshold (e.g., 50).
  • QK-Proj-FC2 Normalization ($QK\_FC\_norm$): Applying LayerNorm specifically after the QK, Proj, and FC2 layers.

Experimental Results and Insights

The models were trained on a 1-trillion token dataset encompassing 53 human languages and 37 programming languages. Using an 830M parameter proxy model, the researchers found that:

  1. Stability Boost: Both $QKV\_norm$ and $QK\_norm\_cap$ allowed the model to converge at a learning rate of 60e-3, whereas the standard $QK\_norm$ baseline diverged at 40e-3 (a 1.5x improvement).
  2. Accuracy Gains: All proposed normalization methods showed significant perplexity improvements. For example, $QK\_norm$ achieved a perplexity of 10.84 compared to the baseline's 11.19.
  3. Learning Rate Correlation: The ability to train at higher learning rates is not merely a matter of speed; it consistently leads to better final model performance, provided the architecture remains stable.

Conclusion

Targeting the specific linear layers prone to L2 norm explosion offers a robust path toward stabilizing LLM training. While these results were established on an 830M parameter proxy model, the findings suggest that architectural simplicity and targeted normalization are more effective than broad, unguided normalization strategies. Future work will focus on validating these methods at even larger scales.

Summary updated

BibTeX
@misc{rybakov2024methods,
  author = {Oleg Rybakov and Mike Chrzanowski and Peter Dykas and Jinze Xue and Ben Lanir},
  title = {{Methods of improving LLM training stability}},
  year = {2024},
  eprint = {2410.16682},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.16682},
}
Figure