Log inStart free
LESSON 27.18 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Fused LayerNorm and RMSNorm kernels

Watch one kernel add, normalize and scale a token's row in one HBM trip.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 27.18 · NORM BAYRMSNORM · FUSED ADD + NORM
01
Stage 1 of 6 · Rows in HBM
The residual stream x and the attention output a sit in HBM as FP16. The weights γ wait beside them.
Explain it simply

The bottom band is HBM, the GPU's big main memory. It holds the token's running vector x and the attention output a. The middle band is one SM with eight empty lanes, and every trip between the bands costs time.

HBM holds x, a and the weights, 8 values each. The 8 register lanes are empty. 1 kernel chip waits on top.

x, a, h and the statisticsweights γ, βnormalized output yextra HBM trips, overflowempty or not stored
01234567μ = 0msrxaγhyadd + rmsnormSMFP32HBMFP16kernels0 launchesreads 0 valueswrites 0 values0 B moved01234567μ = 0msrxaγhyadd + rmsnormSMFP32HBMFP16kernels0 launchesreads 0 valueswrites 0 values0 B moved
Toy: the 27.C3 token's norm before the MLP; 8 lanes per block
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
x, a, γ∈R8\sy{x}{data}{x},\ \sy{a}{data}{a},\ \sy{g}{param}{\gamma} \in \mathbb{R}^{8}
x1=0.91,  8×2 B=16 B per rowx_{1} = 0.91,\; 8 \times 2\,\text{B} = 16\,\text{B per row}

Each row holds 8 FP16 values of 2 bytes.

Common mix-ups

MYTHFusing the norm saves math, so it runs faster.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Switch to LayerNorm. How many reductions does the block run before it can scale?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.