Abstract
Large Language Models (LLMs) have achieved remarkable success, yet recent findings reveal that their deeper layers often contribute minimally and can be pruned without affecting overall performance. While some view this as an opportunity for model compression, we identify it as a training shortfall rooted in the widespread use of Pre-Layer Normalization (Pre-LN). We demonstrate that Pre-LN, commonly employed in models like GPT and LLaMA, leads to diminished gradient norms in its deeper layers, reducing their effectiveness. In contrast, Post-Layer Normalization (Post-LN) preserves larger gradient norms in deeper layers but suffers from vanishing gradients in earlier layers. To address this, we introduce Mix-LN, a novel normalization technique that combines the strengths of Pre-LN and Post-LN within the same model. Mix-LN applies Post-LN to the earlier layers and Pre-LN to the deeper layers, ensuring more uniform gradients across layers. This allows all parts of the network—both shallow and deep layers—to contribute effectively to training. Extensive experiments with various model sizes from 70M to 7B demonstrate that Mix-LN consistently outperforms both Pre-LN and Post-LN, promoting more balanced, healthier gradient norms throughout the network, and enhancing the overall quality of LLM pre-training. Furthermore, we demonstrate that models pre-trained with Mix-LN learn better compared to those using Pre-LN or Post-LN during supervised fine-tuning (SFT) and reinforcement learning from human feedback (RLHF), highlighting the critical importance of high-quality deep layers.
Introduction: The Curse of Depth
In the current LLM landscape, state-of-the-art models such as GPT-4 and Llama 3 predominantly utilize Pre-Layer Normalization (Pre-LN). While Pre-LN facilitates stable training at scale, it introduces a significant drawback: the "Curse of Depth." Recent studies indicate that deeper layers in these architectures are often redundant; they can be pruned with negligible impact on accuracy. This research identifies the root cause as a training inefficiency. In Pre-LN models, gradient norms diminish as they propagate to deeper layers, effectively transforming them into identity mappings that contribute little to the final representation. Conversely, the older Post-LN standard maintains strong gradients in deep layers but suffers from vanishing gradients in early layers, often leading to training instability.
Methods: The Mix-LN Architecture
To overcome these limitations, we propose Mix-LN, a hybrid normalization strategy that balances gradient flow across the entire network without adding parameters.
Mix-LN partitions the model into two segments based on a hyperparameter $\alpha$:
- Post-LN for Early Layers: The initial portion of the model uses Post-LN. This ensures that gradients flowing back from the output remain robust as they traverse the middle and deep sections.
- Pre-LN for Deeper Layers: The subsequent layers utilize Pre-LN, providing the necessary stability to prevent the total gradient collapse often observed in pure Post-LN configurations.
Mathematically, the Jacobian matrix of Pre-LN tends toward an identity matrix as depth increases, explaining the stagnation of deep layers. Mix-LN leverages the "gradient-boosting" effect of Post-LN to keep these deeper layers actively engaged in the learning process.
Key Insights and Ideas
The effectiveness of Mix-LN stems from its ability to maintain "gradient health" throughout the network.
- Escaping the Identity Trap: In Pre-LN models, unconstrained residual connections lead to an accumulation of outputs where the residual branch becomes negligible. Mix-LN ensures every layer contributes to the representational power.
- Balanced Gradient Distribution: Mix-LN aims for a more uniform distribution of gradient norms compared to the decaying norms of Pre-LN or the early-layer vanishing gradients of Post-LN.
- Representation Diversity: Using "Angular Distance" to measure layer-wise changes, we find that Mix-LN models exhibit significantly higher diversity in deep layers. In contrast, Pre-LN layers often become nearly identical.
- Enhanced Downstream Learning: Models pre-trained with Mix-LN demonstrate superior gains during supervised fine-tuning (SFT) and RLHF, indicating that the underlying representations are of higher quality.
Experimental Results
We validated Mix-LN across various scales (70M to 7B parameters) and domains:
- Language Modeling: Mix-LN consistently achieved lower perplexity on the C4 dataset. For a 1B parameter model, Mix-LN reached a perplexity of 18.18, compared to 18.65 for Pre-LN.
- Reasoning Benchmarks: On BoolQ, the Mix-LN 250M model outperformed the Pre-LN baseline by 17.31%.
- RLHF Performance: In RLHF experiments using the Ultrafeedback dataset, Mix-LN achieved a final reward of 1.32, nearly doubling the 0.75 of the Pre-LN baseline.
- Vision Transformers: On ImageNet-1K, Mix-LN improved ViT-Small top-1 accuracy from 75.99% to 76.40%.
Conclusion and Limitations
Mix-LN effectively addresses the inefficiency of deep layers in modern LLMs by balancing gradient norms. While highly effective up to 7B parameters, stability at extreme scales remains a challenge. As models grow, they become more sensitive to the ratio of Post-LN layers ($\alpha$). For the 7B model, an $\alpha$ of 6.25% was required for stability. Future work will explore further stabilization of the Post-LN component to unlock even greater potential in massive-scale models.
Summary updated