[Paper Review] On Layer Normalization in the Transformer Architecture
The paper analyzes how layer normalization placement affects Transformer optimization and shows that Pre-LN enables training without a warm-up stage and faster convergence, while Post-LN relies on warm-up for stability.
The Transformer is widely used in natural language processing tasks. To train a Transformer however, one usually needs a carefully designed learning rate warm-up stage, which is shown to be crucial to the final performance but will slow down the optimization and bring more hyper-parameter tunings. In this paper, we first study theoretically why the learning rate warm-up stage is essential and show that the location of layer normalization matters. Specifically, we prove with mean field theory that at initialization, for the original-designed Post-LN Transformer, which places the layer normalization between the residual blocks, the expected gradients of the parameters near the output layer are large. Therefore, using a large learning rate on those gradients makes the training unstable. The warm-up stage is practically helpful for avoiding this problem. On the other hand, our theory also shows that if the layer normalization is put inside the residual blocks (recently proposed as Pre-LN Transformer), the gradients are well-behaved at initialization. This motivates us to remove the warm-up stage for the training of Pre-LN Transformers. We show in our experiments that Pre-LN Transformers without the warm-up stage can reach comparable results with baselines while requiring significantly less training time and hyper-parameter tuning on a wide range of applications.
Motivation & Objective
- Motivate why learning rate warm-up is essential for Post-LN Transformers and how layer normalization placement influences gradient behavior.
- theoretically analyze gradient scales at initialization using mean field theory for Post-LN and Pre-LN variants.
- Empirically verify whether warm-up can be removed for Pre-LN and measure training speed and performance across NLP tasks.
Proposed method
- Mean field theory to study gradient scales at initialization for Post-LN and Pre-LN Transformers.
- Theoretical analysis of gradient norms of the last FFN layer and their dependence on depth L.
- Empirical experiments on IWSLT14 De-En, WMT14 En-De, and BERT pre-training to compare warm-up vs no-warm-up setups.
- Controlled initialization: single-head attention, Xavier initialization, zero Q/K in attention, and Gaussian inputs.
- Comparison of Post-LN vs Pre-LN architectures with and without warm-up using Adam and SGD/RAdam variants.
Experimental results
Research questions
- RQ1Does the learning rate warm-up stage become unnecessary for Pre-LN Transformers at initialization?
- RQ2How does the placement of layer normalization affect gradient scales and training stability in Transformer architectures?
- RQ3Can Pre-LN Transformers without warm-up achieve comparable or faster convergence and final performance to Post-LN baselines across translation and pre-training tasks?
Key findings
- Post-LN Transformers exhibit large gradients near the output layer at initialization, making large learning rates unstable without warm-up.
- Pre-LN Transformers have well-behaved gradients at initialization, allowing removal of the warm-up stage.
- Across IWSLT14 De-En, WMT14 En-De, and BERT pre-training, Pre-LN without warm-up matches or surpasses Post-LN with warm-up in speed and final performance.
- Pre-LN training converges faster than Post-LN under the same lr_max settings, reducing hyperparameter sensitivity and training time.
- Warm-up removal yields substantial speedups (e.g., faster convergence and fewer hyperparameter tunings) while maintaining competitive results.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.