AI ENGVisual Encyclopedia

MODULE 3: THE PRE-TRAIN RECIPE · SCENE 11

RMSNorm and SwiGLU

The small layers that keep a 100-layer network trainable: normalize, then gate.

RMSNorm Formula

a_bar = (a / RMS(a)) * g --> Skips mean subtraction!

TECHNICAL BREAKDOWNModule 3: Modern Architectural Specifications (The Pre-Train Recipe)

Normalization & Activation Layer Evolution: RMSNorm & SwiGLU

Modern architecture recipes replaced standard LayerNorm with RMSNorm to eliminate mean-centering overhead, and replaced ReLU/GeLU with SwiGLU gated activations for superior gradient propagation.

RMSNorm (Root Mean Square Norm)

RMSNorm normalizes activation inputs using root mean square without calculating mean offset. This saves ~7% to 10% kernel latency per transformer block with zero loss in training stability.

SwiGLU Activation Function

SwiGLU combines Swish activation with Gated Linear Units: SwiGLU(x) = (xW + b) * Swish(xV + c). It provides smoother gradients and higher expressive capacity.

Pre-Normalization Architecture

Placing RMSNorm BEFORE attention and MLP blocks (Pre-LN) instead of after (Post-LN) keeps the residual main branch uncorrupted, preventing vanishing gradients in 80+ layer deep networks.

MATHEMATICAL FORMULATION · RMSNORM FORMULATION
a_bar_i = ( a_i / RMS(a) ) · g_i where RMS(a) = √( (1 / d) ∑_(j=1..d) a_j² + ε )

Rescales vector components by the L2 norm over dimension d, multiplied by learnable gain g_i.

REAL-WORLD PRODUCTION ENGINEERING
  • SwiGLU requires an intermediate hidden dimension of (8/3)d rather than 4d to match parameter count while improving convergence.