Rethinking Batch Normalization in Transformers

Sheng Shen, Zhewei Yao, Amir Gholami, Michael W. Mahoney, Kurt KeutzerarXiv 2020

Abstract

Power Normalization (PN) is a novel normalization scheme designed to replace Layer Normalization (LN) in Transformer models. By identifying that the failure of Batch Normalization (BN) in NLP stems from massive fluctuations in batch statistics, the authors propose using a running quadratic mean and an approximate backpropagation scheme to achieve superior stability and performance across translation and language modeling tasks.

Introduction: The Normalization Divide

In deep learning, normalization is essential for stable training. However, a curious divide exists: Computer Vision (CV) models almost exclusively use Batch Normalization (BN), while Natural Language Processing (NLP) models rely on Layer Normalization (LN).

When researchers attempt to use BN in Transformers, performance typically craters. This paper identifies the culprit: batch statistic instability. Unlike CV data, where batch means and variances stabilize quickly, NLP data exhibits massive fluctuations and persistent "extreme outliers" throughout the entire training process. Naively applying BN in this environment introduces significant noise into the gradients, leading to poor convergence.

Comparison of normalization dimensions: Layer Normalization (left) operates across features, while Batch/Power Normalization (right) operates across the batch dimension.

Power Normalization (PN)

To bridge this gap, the authors introduce Power Normalization (PN), which modifies the standard BN formula through three key innovations:

  1. Relaxing Zero-Mean Normalization: Standard BN subtracts the batch mean. PN removes this step, focusing only on scaling, which eliminates a primary source of fluctuation.
  2. Enforcing Quadratic Mean: Instead of using variance, PN scales activations by the quadratic mean ($\sqrt{E[x^2]}$). Empirically, the quadratic mean is significantly more stable than variance for NLP data.
  3. Running Statistics in Training: Standard BN uses current batch statistics during training and running statistics during inference, creating a "train-test mismatch." PN uses running statistics for both. To enable this during backpropagation, an approximate backpropagation scheme is introduced to ensure bounded gradients and convergence.

The "Wild" Statistics of NLP

The paper's most striking finding is the empirical visualization of batch statistics. In CV (e.g., CIFAR-10), the distance between batch statistics and running statistics shrinks to near zero as training progresses. In contrast, for NLP (e.g., IWSLT14), this distance remains high with "spiky" outliers that never disappear.

Empirical comparison of batch statistic stability between CV (CIFAR10) and NLP (IWSLT14). NLP data shows significantly higher fluctuations in both mean and variance throughout training.

This explains why BN-based models struggle to settle in NLP tasks. PN-V (the version using quadratic mean) preserves the "first-order smoothness" property that makes BN effective in CV, providing the benefits of batch-level normalization without the NLP-specific noise.

Key Results and Performance

Power Normalization consistently outperformed the industry-standard Layer Normalization across several benchmarks:

  • Machine Translation: PN achieved gains of +0.4 BLEU on IWSLT14 and +0.6 BLEU on WMT14 over the Pre-Norm Transformer baseline.
  • Language Modeling: Improvements were dramatic, with PN reducing testing Perplexity (PPL) by 5.6 points on PTB and 3.0 points on WikiText-103 compared to LN.
  • Representational Capacity: Using Singular Value Decomposition (SVD), the authors found that PN leads to a more "well-conditioned" embedding layer, suggesting it helps the model utilize its full representational capacity across the batch dimension.

Conclusion and Limitations

While PN is a powerful drop-in replacement for LN, it does introduce a moving average coefficient ($\alpha$) that may require tuning. Additionally, the authors noted that decoders in Neural Machine Translation can exhibit unstable gradient issues, sometimes requiring LN to be maintained in those specific layers. Despite these considerations, PN offers a robust path forward for stabilizing and improving Transformer architectures.

Summary updated

BibTeX
@misc{shen2020rethinking,
  author = {Sheng Shen and Zhewei Yao and Amir Gholami and Michael W. Mahoney and Kurt Keutzer},
  title = {{Rethinking Batch Normalization in Transformers}},
  year = {2020},
  eprint = {2003.07845},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2003.07845},
}
Figure