Skip to content
Skip to lesson
Back to Topics
LearnTransformer & Multimodal ArchitecturesLayer Normalization: Pre-LN vs Post-LN
HardTransformer Architecture13 min read

Layer Normalization: Pre-LN vs Post-LN

Each residual write can change a token's scale, and where LayerNorm sits decides what the next branch reads and how its gradient gets back.

On this page

In a 32-layer decoder, every token carries a hidden vector through the stack. That running vector is the . Take one token state: [3.0, 1.0, -1.0, 5.0]. Attention reads other visible tokens and adds an update; the feed-forward network adds another. Across dozens of layers, repeated additions stretch the stream's scale. How do we keep what each sublayer reads well-scaled without strangling gradients on their way back from the loss?

centers a single token's features and scales them by their spread, then applies learned gain and shift parameters. Placing that exact operation after the residual addition (Post-LN) versus before the sublayer branch (Pre-LN) creates two completely different forward trajectories and backward gradient paths.

One residual stream, many writes

Write the bare residual update for any transformer sublayer (attention or MLP):

xl+1=xl+Fl(xl)x_{l+1} = x_l + F_l(x_l)

If each sublayer adds a roughly independent perturbation with variance σsub2\sigma_{\text{sub}}^2, hidden variance grows linearly with depth ll and standard deviation expands like l\sqrt{l}:

Var⁡(xl)≈Var⁡(x0)+l⋅σsub2\operatorname{Var}(x_l) \approx \operatorname{Var}(x_0) + l \cdot \sigma_{\text{sub}}^2

Correlated writes can bend that curve faster or slower, yet left unchecked, deep residual sums drift in magnitude. Normalization tames that drift, and where it sits around the + decides how error signals flow backward during .[1] First, trace the exact arithmetic inside LayerNorm on one vector.

LayerNorm by hand

Take a single 4-dimensional token state x = [3.0, 1.0, -1.0, 5.0] and compute every step without framework magic:

  1. Feature mean: Average across the token's d=4d = 4 hidden features:
μ=3.0+1.0+(−1.0)+5.04=2.0\mu = \frac{3.0 + 1.0 + (-1.0) + 5.0}{4} = 2.0
  1. Centering: Subtract μ=2.0\mu = 2.0 from every coordinate, giving [1.0, -1.0, -3.0, 3.0].
  2. Population variance: Average the squared deviations using 1/d1/d (not Bessel's 1/(d−1)1/(d - 1)):
σ2=1.02+(−1.0)2+(−3.0)2+3.024=20.04=5.0\sigma^2 = \frac{1.0^2 + (-1.0)^2 + (-3.0)^2 + 3.0^2}{4} = \frac{20.0}{4} = 5.0
  1. Standardize: Ignoring ϵ\epsilon for the hand check, divide by σ=5.0≈2.236\sigma = \sqrt{5.0} \approx 2.236:
x^=[1.02.236,−1.02.236,−3.02.236,3.02.236]≈[0.447,−0.447,−1.342,1.342]\hat{x} = \left[\frac{1.0}{2.236}, \frac{-1.0}{2.236}, \frac{-3.0}{2.236}, \frac{3.0}{2.236}\right] \approx [0.447, -0.447, -1.342, 1.342]
  1. Affine transform: Multiply by learned per-channel scale γ\gamma (initialized to 1) and add shift β\beta (initialized to 0), giving the general formula for x∈Rdx \in \mathbb{R}^d:[2]
LayerNorm(x)=γ⊙x−μσ2+ϵ+β\text{LayerNorm}(x) = \gamma \odot \frac{x - \mu}{\sqrt{\sigma^2 + \epsilon}} + \beta

Adding ϵ\epsilon (typically 10−510^{-5} or 10−610^{-6}) prevents division by zero on constant vectors, turning pre-affine output variance into σ2/(σ2+ϵ)\sigma^2 / (\sigma^2 + \epsilon). Notice that every reduction stays strictly inside one token's feature axis.

Three side-by-side calibrated bar plots track features f1 through f4 on a shared vertical scale from -3 to 6. Stage 1 Input x = [3, 1, -1, 5] has mean 2 (dashed line) and variance 5. Stage 2 subtracts mean 2 to produce centered [1, -1, -3, 3] with mean 0 and variance 5. Stage 3 divides by sqrt(5) to yield normalized [0.45, -0.45, -1.34, 1.34] with mean 0 and variance 1.
Tracking features f1f_1 through f4f_4 on a shared [−3,6][-3, 6] axis. Subtracting μ=2\mu = 2 centers the vector while preserving variance 55; dividing by 5\sqrt{5} compresses spread to unit variance (ϵ=0,γ=1,β=0\epsilon=0, \gamma=1, \beta=0).

Why transformers use LayerNorm instead of BatchNorm

BatchNorm normalizes each feature channel across the mini-batch (and often across time in BatchNorm1d), creating three headaches for causal language models:[3]

PropertyBatchNormLayerNorm
Reduction axisMini-batch (and temporal positions)Feature coordinates within one token
Causality & paddingTime reduction can leak future tokens; padding skews statsHidden-only stats never mix tokens
Train vs eval behaviorUses batch stats in training, stored running averages in evalIdentical per-token computation in both modes
Single-token decodingRelies on running estimates; sensitive to batch shiftExact match with training, even at batch size 1

In PyTorch, passing an integer nn.LayerNorm(d_model) to a (batch, seq_len, d_model) tensor normalizes strictly along the last axis.[4] Passing a tuple (seq_len, d_model) reduces over time too and leaks future-token edits backward into earlier positions. In , always upcast FP16/BF16 inputs to FP32 for the mean and variance reductions before casting back.

layernorm-verify-and-causality.py
import torch
import torch.nn as nn

class LayerNorm(nn.Module):
    def __init__(self, d_model: int, eps: float = 1e-5):
        super().__init__()
        self.gamma = nn.Parameter(torch.ones(d_model))
        self.beta = nn.Parameter(torch.zeros(d_model))
        self.eps = eps

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        work = x.float() if x.dtype in (torch.float16, torch.bfloat16) else x
        mean = work.mean(dim=-1, keepdim=True)
        var = work.var(dim=-1, keepdim=True, unbiased=False)
        x_hat = (work - mean) / torch.sqrt(var + self.eps)
        return (self.gamma * x_hat + self.beta).to(x.dtype)

# 1. Match the hand calculation on [3, 1, -1, 5].
ln = LayerNorm(4)
out = ln(torch.tensor([[[3.0, 1.0, -1.0, 5.0]]]))
print("hand check:", out.round(decimals=2).detach().tolist())
assert torch.allclose(out.round(decimals=2), torch.tensor([[[0.45, -0.45, -1.34, 1.34]]]))

# 2. Hidden-only LayerNorm isolates token 0 when token 1 changes; reducing over (seq, d) leaks future edits.
seq = torch.tensor([[[1.0, 2.0, 4.0], [2.0, 5.0, 8.0]]], dtype=torch.float64)
edited = seq.clone()
edited[:, 1] += 100.0
per_token = nn.LayerNorm(3, elementwise_affine=False).double()
over_time = nn.LayerNorm((2, 3), elementwise_affine=False).double()
Per-token LayerNorm matches hand math and preserves causality
hand check: [[[0.44999998807907104, -0.44999998807907104, -1.340000033378601, 1.340000033378601]]]
token 0 unchanged (hidden-only): True
token 0 unchanged (seq+hidden):  False

Pre-LN vs Post-LN: placement and gradient flow

Every transformer block wraps two sublayers (multi-head attention and an MLP), each taking xlx_l and adding an update F(xl)F(x_l). Two classic placements put LayerNorm on opposite sides of the addition:

xl+1=LayerNorm(xl+F(xl))x_{l+1} = \text{LayerNorm}(x_l + F(x_l)) xl+1=xl+F(LayerNorm(xl)),y=Head(FinalNorm(xL))x_{l+1} = x_l + F(\text{LayerNorm}(x_l)), \qquad y = \text{Head}(\text{FinalNorm}(x_L))
Two stacked computational graphs compare normalization placement. Pre-LN sends x through LN and the sublayer F while a blue identity skip bypasses both and reaches the addition. Post-LN sends x through F, adds the skip, and then routes the whole sum through LN. Their Jacobians are I plus J F times J LN, and J LN times the quantity I plus J F, respectively.
Trace the blue identity skip from xx to yy. Pre-LN bypasses normalization (J=I+JFJLNJ = I + J_F J_{\text{LN}}), whereas Post-LN pushes the combined sum through LayerNorm (J=JLN(I+JF)J = J_{\text{LN}}(I + J_F)). Backpropagation multiplies by JTJ^T.

Why Pre-LN trains more stably

Differentiating each block exposes why depth behaves so differently in backward pass. For one token with standardized state x^\hat{x} and denominator s=σ2+ϵs = \sqrt{\sigma^2 + \epsilon}, the LayerNorm Jacobian scales inversely with ss and projects out the constant mean direction and radial scaling direction:

JLN=diag⁡(γ)s(I−11Td−x^x^Td)J_{\text{LN}} = \frac{\operatorname{diag}(\gamma)}{s}\left(I - \frac{\mathbf{1}\mathbf{1}^T}{d} - \frac{\hat{x}\hat{x}^T}{d}\right)

Now compare how block Jacobians chain from layer ll to output LL:

  • Post-LN: ∂xl+1∂xl=JLN,l(I+JF,l)\frac{\partial x_{l+1}}{\partial x_l} = J_{\text{LN}, l}(I + J_{F, l}). Every backward signal along the skip path must pass through a chain of normalization Jacobians JLN,lT⋯JLN,L−1TJ_{\text{LN}, l}^T \cdots J_{\text{LN}, L-1}^T. Under Xiong et al.'s initialization analysis, gradients concentrate heavily near the top layers (final-FFN norm O(dln⁡d)O(d\sqrt{\ln d}) vs Pre-LN's O(dln⁡d/L)O(d\sqrt{\ln d / L})), making careful learning-rate warmup essential to keep early steps from diverging.[1]
  • Pre-LN: ∂xl+1∂xl=I+JF,lJLN,l\frac{\partial x_{l+1}}{\partial x_l} = I + J_{F, l} J_{\text{LN}, l}. Expanding across layers keeps an explicit identity term II outside the branch products:
∂xL∂xl=I+∑k=lL−1JF,kJLN,k∂xk∂xl\frac{\partial x_L}{\partial x_l} = I + \sum_{k=l}^{L-1} J_{F, k} J_{\text{LN}, k} \frac{\partial x_k}{\partial x_l}

That additive identity highway carries gradients cleanly to early blocks right from step zero. (Note that II does not create an absolute lower bound, since a branch can cancel along specific directions where JFJLNv=−vJ_F J_{\text{LN}} v = -v, and real recipes still pair Pre-LN with tuned warmup and initialization.)[1][8]

Verify both block Jacobians and the forward/backward contrast directly in PyTorch:

pre-vs-post-ln-verify.py
x = torch.tensor([3.0, 1.0, -1.0, 5.0], dtype=torch.float64, requires_grad=True)
W = torch.randn(4, 4, dtype=torch.float64) * 0.2
I = torch.eye(4, dtype=torch.float64)
ln = lambda v: nn.functional.layer_norm(v, (4,), eps=1e-5)
pre = lambda v: v + W @ ln(v)
post = lambda v: ln(v + W @ v)

torch.testing.assert_close(jacobian(pre, x), I + W @ jacobian(ln, x))
torch.testing.assert_close(jacobian(post, x), jacobian(ln, x + W @ x) @ (I + W))
print("Block Jacobians match autograd: True")

# 2. Compare stream norm growth and per-block gradients across a 6-layer residual MLP stack.
def run_stack(style: str, depth: int = 6, d_model: int = 64):
    torch.manual_seed(0)
    norms = nn.ModuleList([nn.LayerNorm(d_model) for _ in range(depth)])
    mlps = nn.ModuleList([
        nn.Sequential(nn.Linear(d_model, d_model * 4), nn.ReLU(), nn.Linear(d_model * 4, d_model))
        for _ in range(depth)
    ])
    final_norm = nn.LayerNorm(d_model) if style == "pre" else nn.Identity()
    head = nn.Linear(d_model, 16)
    h = torch.randn(2, 8, d_model)
    target = torch.randn(2, 8, 16)
    for norm, mlp in zip(norms, mlps):
        h = h + mlp(norm(h)) if style == "pre" else norm(h + mlp(h))
    stream_rms = float(h.pow(2).mean().sqrt())
    loss = nn.functional.mse_loss(head(final_norm(h)), target)
    loss.backward()
    grads = [round(float(m[0].weight.grad.norm()), 4) for m in mlps]
    print(f"{style:4s} | pre-head stream RMS={stream_rms:.3f} | block grads={grads}")

run_stack("pre")
run_stack("post")
Pre-LN vs Post-LN Jacobians and 6-layer gradients
Block Jacobians match autograd: True
pre  | pre-head stream RMS=1.151 | block grads=[0.2664, 0.2565, 0.2494, 0.2392, 0.2472, 0.2415]
post | pre-head stream RMS=1.000 | block grads=[0.2663, 0.2614, 0.2619, 0.2555, 0.2684, 0.2698]

Notice two concrete signatures in that output: Post-LN clamps the stream RMS right at 1.000, while Pre-LN's unnormalized residual stream has already grown to 1.151 after just 6 blocks, which is why deleting FinalNorm in a Pre-LN checkpoint port changes the scale hitting the language-modeling head.

Representation collapse and DeepNorm

Leaving the Pre-LN residual highway unnormalized carries a structural tradeoff in very deep stacks. Because xL=x0+∑l=0L−1Fl(LN(xl))x_L = x_0 + \sum_{l=0}^{L-1} F_l(\text{LN}(x_l)), uncorrelated unit-scale writes push ∥xl∥≈O(l)\|x_l\| \approx O(\sqrt{l}), so each late layer's relative write shrinks like:

∥Δxl∥∥xl∥≈O ⁣(1l)\frac{\|\Delta x_l\|}{\|x_l\|} \approx O\!\left(\frac{1}{\sqrt{l}}\right)

In deep Pre-LN translation models, ResiDual documented rising cosine similarity between consecutive normalized states and diminishing late-layer updates (often called representation collapse).[9] Before declaring a late block redundant from a small norm ratio alone, run a controlled ablation zeroing only that block's write on held-out tokens and check task loss directly.

To recover Post-LN's crisp representation updates at extreme depth without instability, DeepNorm (Wang et al., 2022) scales the residual skip by a depth-dependent constant α>1\alpha > 1 while down-scaling selected sublayer initializations (FFN weights and attention value/output projections) by β<1\beta < 1:[10]

xl+1=LayerNorm(α⋅xl+Gl(xl))x_{l+1} = \text{LayerNorm}(\alpha \cdot x_l + G_l(x_l))

For an NN-layer encoder-only or MM-layer decoder-only model, DeepNorm sets α=(2N)1/4\alpha = (2N)^{1/4} and β=(8N)−1/4\beta = (8N)^{-1/4} (encoder-decoder stacks adjust constants for cross-attention). Critically, β\beta is applied only at weight initialization, never as a second runtime multiplier on Gl(xl)G_l(x_l). DeepNet scaled Post-LN transformers to 1,000 layers while still retaining learning-rate warmup in its translation runs.[10]

PropertyPost-LNPre-LNDeepNorm
Residual equationLN(x+F(x))\text{LN}(x + F(x))x+F(LN(x))x + F(\text{LN}(x))LN(αx+G(x))\text{LN}(\alpha x + G(x))
Skip gradient pathChained JLNJ_{\text{LN}}Direct identity IIScaled skip through JLNJ_{\text{LN}}
Final norm needed?No (last block normalizes)Yes (stream unnormalized)No (last block normalizes)
Primary riskSteep top-layer gradients without warmupRelative write dilution at great depthMust preserve exact (α,β)(\alpha, \beta) init recipe

RMSNorm and mixed-precision traps

Zhang and Sennrich (2019) asked whether mean-centering was necessary at all and introduced RMSNorm, which drops mean subtraction and learned bias β\beta, dividing only by the uncentered root mean square:[11]

RMSNorm(x)=γ⊙x1d∑i=1dxi2+ϵ\text{RMSNorm}(x) = \gamma \odot \frac{x}{\sqrt{\frac{1}{d}\sum_{i=1}^d x_i^2 + \epsilon}}
Two side-by-side paired grouped bar charts compare LayerNorm (purple) and RMSNorm (green) on input x = [3, 1, -1, 5] and shifted input x + 10 = [13, 11, 9, 15] over a shared [-1.6, 1.9] axis. LayerNorm outputs remain invariant at [0.45, -0.45, -1.34, 1.34] after the +10 shift because mean subtraction removes uniform offsets, whereas uncentered RMSNorm shifts from [1.00, 0.33, -0.33, 1.67] to all-positive [1.07, 0.90, 0.74, 1.23].
Comparing LayerNorm (purple) and RMSNorm (green) on x and x + 10 (ϵ=0,γ=1,β=0\epsilon=0, \gamma=1, \beta=0). Centering makes LayerNorm invariant to uniform additive shifts; uncentered RMSNorm pulls every output positive.

Llama, Mistral, Qwen 2.5, and Gemma 2 all adopt RMSNorm.[12][13] Do not assume dropping mean calculation halves GPU runtime, though: fused LayerNorm kernels compute mean and variance in one pass via Welford's algorithm, so memory bandwidth dominates, and even halving a normalization kernel that takes 2% of step time only trims 1% end to end.[14][15][11]

In mixed precision, always cast FP16 activations to FP32 before squaring. A finite FP16 number like 300.0 squares to 90,000, overflowing FP16's ceiling (65,504) into inf before the square root ever runs. Separately, FP32 accumulation cannot rescue precision already destroyed by input rounding ([10000, 10001, 9999, 10002] all round to 10000.0 in FP16 before normalization starts):[16][17]

rmsnorm-and-fp16-overflow.py
class RMSNorm(nn.Module):
    def __init__(self, d_model: int, eps: float = 1e-6):
        super().__init__()
        self.weight = nn.Parameter(torch.ones(d_model))
        self.eps = eps

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        work = x.float() if x.dtype in (torch.float16, torch.bfloat16) else x
        rms = torch.sqrt(work.pow(2).mean(dim=-1, keepdim=True) + self.eps)
        return (self.weight * (work / rms)).to(x.dtype)

x = torch.tensor([[[3.0, 1.0, -1.0, 5.0]]])
out = RMSNorm(4)(x)
print("RMSNorm([3, 1, -1, 5]):", out.round(decimals=4).detach().tolist())

large = torch.tensor([300.0, -300.0], dtype=torch.float16)
fp16_rms = (large.square().mean() + 1e-6).sqrt()
fp32_rms = (large.float().square().mean() + 1e-6).sqrt()
print(f"FP16 squaring RMS={fp16_rms.item()} | FP32 upcast RMS={fp32_rms.item():.1f}")
assert torch.isinf(fp16_rms) and fp32_rms.item() == 300.0
RMSNorm and FP16 squaring overflow
RMSNorm([3, 1, -1, 5]): [[[1.0, 0.33329999446868896, -0.33329999446868896, 1.666700005531311]]]
FP16 squaring RMS=inf | FP32 upcast RMS=300.0

Modern layouts: QK-Norm and Peri-LN

Modern frontier models combine residual placement with targeted internal normalizers:

QK-Norm tames attention logit growth

Inside self-attention, Sij=qikjT/dkS_{ij} = q_i k_j^T / \sqrt{d_k} can grow extreme score differences as projection weights expand during long runs, pushing attention softmax toward one-hot spikes whose Jacobian Softmax⁡(S)i(δij−Softmax⁡(S)j)\operatorname{Softmax}(S)_i(\delta_{ij} - \operatorname{Softmax}(S)_j) collapses near zero. QK-Norm normalizes per-head queries and keys right before the dot product:[21][22]

q′=Norm(q),k′=Norm(k),Sij=qi′kj′Tdkq' = \text{Norm}(q), \qquad k' = \text{Norm}(k), \qquad S_{ij} = \frac{q'_i {k'_j}^T}{\sqrt{d_k}}

By Cauchy-Schwarz, unit-RMS vectors (Euclidean length dk\sqrt{d_k}) bound un-gained logits to ∣Sij∣≤dk|S_{ij}| \le \sqrt{d_k}. Learned gains raise that ceiling, and aligned signs across large dkd_k can still produce sharp softmax weights, so QK-Norm controls one scale source inside attention without replacing residual-stream normalization.

Peri-LN (sandwich normalization)

Sandwich layouts normalize both the incoming branch input and the outgoing branch write inside the branch before adding to the residual stream:

xl+1=xl+Normout(F(Normin(xl)))x_{l+1} = x_l + \text{Norm}_{\text{out}}(F(\text{Norm}_{\text{in}}(x_l)))

Because Normout\text{Norm}_{\text{out}} stays before the +, the direct identity skip survives while every newly added write has controlled scale. Kim et al. (2025) reported fewer gradient spikes and lower validation loss across 400M–3.2B models relative to Pre-LN.[8]

Debugging normalization failures

SymptomLikely causeCheck and fix
Nonfinite loss on early stepsFP16 squaring overflow, bad mask, or steep Post-LN gradientsFind the first nonfinite tensor; verify FP32 norm reduction and test learning-rate warmup
Nearly one-hot attentionGrowing Q/KQ/K projection norms or affine gainsLog attention logit gaps and entropy; compare QK-Norm or logit soft-capping
Shifted logits after porting Pre-LNDropped FinalNorm or mismatched epsRestore final norm, match checkpoint eps (note PyTorch nn.RMSNorm defaults eps=None to machine epsilon), and verify activations
Small early-block gradientsChained Post-LN Jacobians or branch cancellationLog per-block gradient norms across depth; compare Pre-LN or DeepNorm scaling
Suspected late-layer redundancyLarge Pre-LN stream diluting relative write sizeMeasure loss with only that block's write zeroed on held-out tokens before pruning
Check your understanding

Mastery Check

Check each question as you go, or answer all of them and check together. Score 75% or higher to complete this lesson.

0 of 5 answered
1.For token [1, 2, 6, 11], LayerNorm uses gamma = 1, beta = 0, and eps = 0. What is the output to two decimal places?
2.A port replaces Pre-LN (x + F(LN(x))) with Post-LN (LN(x + F(x))). How does the direct skip contribution to the block Jacobian change?
3.An engineer ports a GPT-2-style Pre-LN decoder and deletes the final LayerNorm before the vocabulary head, arguing every block already normalizes its input. What should review flag?
4.A preprocessing shift adds +10 to every feature of a token vector while gamma, beta, and eps stay fixed. Separately, an FP16 RMSNorm kernel computes (x * x).mean() in FP16 on [300.0, -300.0]. What happens in each case?
5.A DeepNorm port initializes selected branch weights with gain beta = 0.5, and then multiplies the trained branch output G(x) by 0.5 again during every forward pass. Separately, a team removes residual normalization after adding QK-Norm. What should review flag?

5 questions remaining.

References

On Layer Normalization in the Transformer Architecture.

Xiong, R., et al. · 2020 · ICML 2020

https://arxiv.org/abs/2002.04745

Layer Normalization.

Ba, J. L., Kiros, J. R., & Hinton, G. E. · 2016

https://arxiv.org/abs/1607.06450

BatchNorm1d (PyTorch 2.14)

PyTorch Contributors · 2026

https://docs.pytorch.org/docs/2.14/generated/torch.nn.BatchNorm1d.html

LayerNorm

PyTorch Contributors · 2026

https://docs.pytorch.org/docs/2.14/generated/torch.nn.LayerNorm.html

Attention Is All You Need.

Vaswani, A., et al. · 2017

https://arxiv.org/abs/1706.03762

BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.

Devlin, J., et al. · 2019 · NAACL 2019

https://arxiv.org/abs/1810.04805

Language Models are Unsupervised Multitask Learners.

Radford, A., et al. · 2019

https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf

Peri-LN: Revisiting Normalization Layer in the Transformer Architecture

Kim, J., et al. · 2025 · ICML 2025

https://arxiv.org/abs/2502.02732

ResiDual: Transformer with Dual Residual Connections.

Xie, S., et al. · 2023 · ACL 2023

https://arxiv.org/abs/2304.14802

DeepNet: Scaling Transformers to 1,000 Layers.

Wang, H., Ma, S., et al. · 2022

https://arxiv.org/abs/2203.00555

Root Mean Square Layer Normalization.

Zhang, B. & Sennrich, R. · 2019 · NeurIPS 2019

https://arxiv.org/abs/1910.07467

Qwen2.5 Technical Report

Qwen Team · 2024

https://arxiv.org/abs/2412.15115

Gemma 2: Improving Open Language Models at a Practical Size

Gemma Team, Google DeepMind · 2024

https://storage.googleapis.com/deepmind-media/gemma/gemma-2-report.pdf

PyTorch CUDA LayerNorm kernels

PyTorch Contributors · 2026

https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/cuda/layer_norm_kernel.cu

Layer Normalization: fused forward and backward tutorial

Triton Contributors · 2026

https://triton-lang.org/main/getting-started/tutorials/05-layer-norm.html

RMSNorm

PyTorch Contributors · 2026

https://docs.pytorch.org/docs/2.14/generated/torch.nn.RMSNorm.html

Type Info

PyTorch Contributors · 2026

https://docs.pytorch.org/docs/2.14/type_info.html

Scaling Vision Transformers to 22 Billion Parameters

Dehghani, M., Djolonga, J., Mustafa, B., et al. · 2023

https://arxiv.org/abs/2302.05442

Gemma 3 Technical Report

Gemma Team et al. · 2025

https://arxiv.org/abs/2503.19786

Transformers 5.17.0 Qwen3 normalization and residual placement

Hugging Face Contributors · 2026

https://github.com/huggingface/transformers/blob/v5.17.0/src/transformers/models/qwen3/modeling_qwen3.py

Query-Key Normalization for Transformers

Henry, A., Dachapally, P. R., Pawar, S., & Chen, Y. · 2020

https://arxiv.org/abs/2010.04245

Methods of improving LLM training stability

Rybakov, O., et al. · 2024

https://arxiv.org/abs/2410.16682

Discussion

Questions and insights from fellow learners.

Discussion loads when you reach this section.