The Curse of Depth in Large Language Models

Wenfang Sun, Xin-Yuan Song, Peng-Xiang Li, Lu Yin, Yefeng Zheng +1 more
2/1/2025
75 citations
transformer-attention

Official code: lmsdss/LayerNorm-Scaling (76 stars, Python, Apache-2.0, last commit 2026-03-03).

Abstract

In this paper, we introduce the Curse of Depth, a concept that highlights, explains, and addresses the recent observation in modern Large Language Models (LLMs) where nearly half of the layers are less effective than expected. We first confirm the wide existence of this phenomenon across the most popular families of LLMs such as Llama, Mistral, DeepSeek, and Qwen.

Show full abstract

Our analysis, theoretically and empirically, identifies that the underlying reason for the ineffectiveness of deep layers in LLMs is the widespread usage of Pre-Layer Normalization (Pre-LN). While Pre-LN stabilizes the training of Transformer LLMs, its output variance exponentially grows with the model depth, which undesirably causes the derivative of the deep Transformer blocks to be an identity matrix, and therefore barely contributes to the training. To resolve this training pitfall, we propose LayerNorm Scaling (LNS), which scales the variance of output of the layer normalization inversely by the square root of its depth. This simple modification mitigates the output variance explosion of deeper Transformer layers, improving their contribution. Across a wide range of model sizes (130M to 7B), our experiments show that LNS consistently outperforms previous normalization and scaling techniques in enhancing LLM pre-training performance. Moreover, this improvement seamlessly carries over to supervised fine-tuning. All these gains can be attributed to the fact that LayerNorm Scaling enables deeper layers to contribute more effectively during training. Our code is available at \href{https://github.com/lmsdss/LayerNorm-Scaling}{LayerNorm-Scaling}.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[NeurIPS 2025] Official Pytorch Implementation of "The Curse of Depth in Large Language Models" by Wenfang Sun, Xinyuan Song, Pengxiang Li, Lu Yin,Yefeng Zheng, Shiwei Liu

764Python, ShellFeb 7, 20259 months agoApache-2.0

Similar Papers

Cite this paper

@article{sun2025curse,
  title  = {The Curse of Depth in Large Language Models},
  author = {Wenfang Sun and Xin-Yuan Song and Peng-Xiang Li and Lu Yin and Yefeng Zheng and Shi-Wei Liu},
  year   = {2025},
  eprint = {2502.05795},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2502.05795},
  url    = {https://doi.org/10.48550/arXiv.2502.05795},
  journal = {Neural Information Processing Systems}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.05795.svg)](https://codeofpaper.com/paper/2502.05795)

Discussion