Why Pre-LayerNorm Transformers Train More Stably Than Post-LayerNorm

Last updated: November 29, 2026

Quick Overview

The original transformer applied layer normalization after each residual addition, while most modern large language models apply it before each sublayer. Explain why the pre-LN placement trains more stably at depth, what it costs, and what other techniques keep very deep models stable.

OpenAI
Machine Learning
Machine Learning Engineer
OpenAI
November 29, 2026
Machine Learning Engineer
Onsite
Machine Learning
Hard

0

0

0 solved


The original transformer applied layer normalization after each residual addition, while most modern large language models apply it before each sublayer. Explain why the pre-LN placement trains more stably at depth, what it costs, and what other techniques keep very deep models stable.

Training runs at OpenAI's scale are expensive enough that a divergence is a major loss, so interviewers probe whether candidates understand the gradient dynamics behind architecture choices rather than reciting them. Expect follow-ups on warmup, initialization, and loss spikes.

What the Interviewer Expects
  • Writes both formulations correctly
  • Explains the identity path for gradients in pre-LN
  • Connects post-LN to the need for learning rate warmup
  • Notes the representation growth trade-off in pre-LN
  • Mentions RMSNorm, scaled initialization, and other stabilizers
Key Topics to Cover
layer normalization
residual connections
gradient flow
training stability
warmup
How to Approach This
  1. Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
  2. Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
  3. Feature engineering is often more impactful than model selection.
  4. Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
  5. Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
  • Why do loss spikes still happen in pre-LN models, and how do you recover from one?
  • What does a final layer norm before the output head do?
  • How does RMSNorm differ from LayerNorm and why is it cheaper?
  • How would you detect early that a run is heading toward divergence?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Explore ML Interview Prep
Sample Answer
Clarify

Post-LN: xl+1=LN(xl+F(xl))x_{l+1} = \mathrm{LN}(x_l + F(x_l)). Pre-LN: xl+1=xl+F(LN(xl))x_{l+1} = x_l + F(\mathrm{LN}(x_l)), with a final LN before the output projection....

Approach

Look at the gradient of the loss with respect to an early layer. In pre-LN, unrolling gives xL=x0+∑lFl(LN(xl))x_L = x_0 + \sum_{l} F_l(\mathrm{LN}(x_l)), so $\frac{\partial x_L}{\partial x_l} = I + \sum_{k \ge l} \fr...


Submit Your Answer
Markdown supported