← Back to LLMs Mind Map
⚡ LLMsID: preln-rmsnorm

Pre-LN & RMSNorm

归一化 Pre-LN/RMSNorm
🎯Core Definition
LayerNorm standardizes the last dimension: LN(x)=x−meanvar⋅γ+βLN(x) = \frac{x - mean}{\sqrt{var}} \cdot \gamma + \beta; Pre-LN places normalization before the residual sublayer (x+SubLayer(LN(x))x + SubLayer(LN(x))) while Post-LN applies it after the residual addition; RMSNorm drops the mean and scales by root-mean-square only: RMSNorm(x)=xmean(x2)⋅γRMSNorm(x) = \frac{x}{\sqrt{mean(x^2)}} \cdot \gamma.
💡Use Cases
mainstream models (LLaMA, Mistral, Qwen) uniformly use Pre-LN + RMSNorm; classic interview questions are "why Pre-LN trains deep models stably" and "why RMSNorm can drop the mean".
⚡Key Problems Solved
in Post-LN the residual signal is progressively attenuated by normalization, making deep training unstable and requiring delicate warmup and gradient clipping; Pre-LN lets gradients flow back through the near-identity residual path, stabilizing depth; RMSNorm removes the mean computation (saving about 1/3 of normalization FLOPs) and experiments show re-centering is essentially unnecessary for Transformers.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Pre-LN & RMSNorm.
Use Cases
In production engineering, what are the primary use cases for Pre-LN & RMSNorm and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Structural difference between Pre-LN and Post-LN? Why is Pre-LN more stable for deep models?
2
RMSNorm formula? Difference from LayerNorm, and why dropping the mean works?
3
Downsides of Pre-LN (residual drift; late-training accuracy vs Post-LN, warmup switching)?
4
Why does the position of normalization relative to the residual matter? Why must the γ\gamma scale be kept?
5
What problem does DeepNorm solve (stable training of 1000-layer Post-LN models)?
Updated 2026-08-12
🎯
Verify Mastery: Practice Exam Questions for "Pre-LN & RMSNorm"
Take pitfall multiple-choice questions with derivation options; mistakes are automatically logged.
🚀 Start Card Practice ➔
← Previous CardFFN & SwiGLUNext Card →FlashAttention

🔗 More LLMs Knowledge Cards

引用出处: TalentMe 450+ 工业级 AI 架构考点知识库 (Tech Vault) · 遵循 CC-BY-4.0 知识共享协议
URL: https://talentme.airsota.com/resources/tech/roadmap/mindmap/LLM/card/preln-rmsnorm
中文速览与面试要点

归一化 Pre-LN/RMSNorm (Pre-LN & RMSNorm)

定义: LayerNorm 沿最后一维标准化:LN(x) = x - mean var + ;Pre-LN 把归一化放在残差子层之前(x + SubLayer(LN(x))),Post-LN 放在残差相加之后;RMSNorm 去掉均值项,只按均方根缩放:RMSNorm(x) = x mean(x^2) 。 使用场景: LLaMA/Mistral/Qwen 等主流模型全部用 Pre-LN + RMSNorm;面试常考"为什么 Pre-LN 训练深层更稳""RMSNorm 为什么能去均值"。 解决的问题: Post-LN 中残差信号被逐层归一化衰减,深层训练不稳定,需要精细 warmup 与梯度裁剪;Pre-LN 让梯度沿残差恒等路径直接回传,深层稳定;RMSNorm 去掉均值计算(归一化算力约省 1/3),且实验表明重中心化对 Transformer 精度几乎无影响,因此可以省略。

核心要点

  • Pre-LN 与 Post-LN 的结构区别?为什么 Pre-LN 深层训练更稳定?
  • RMSNorm 的公式?与 LayerNorm 的差异及为什么去掉均值可行?
  • Pre-LN 的缺点?(残差信号漂移,后期精度可能不如 Post-LN,可预热后切换)
  • 归一化在残差内外的位置为什么重要? 缩放参数为什么必须保留?
  • DeepNorm 解决什么问题?(Post-LN 千层模型的稳定训练)