skip to content

Search

← The Engine Room

Part II — Making Training Work (2014–2020)

Keeping Training Alive

BatchNorm, LayerNorm, RMSNorm, initialization, residuals, and muP transfer.

2015–2022 13 min read 4 papers

It is February 2015. Deep networks train, when they train at all, at the mercy of learning rates set an order of magnitude too conservative and initializations tuned by hand for every added layer. Two researchers at Google propose a fix that normalizes the activations flowing between layers, and within a year it is difficult to find a serious deep network that does not use some form of it. This chapter follows normalization from batches to layers to a single root-mean-square, and then follows a second, later thread — hyperparameters that transfer across model width — that keeps very large training runs from becoming unaffordable guesswork.

Where We Were

By the early 2010s, deep learning’s central practical obstacle was not a lack of ideas but the difficulty of actually training the networks those ideas required. Every layer’s weights update during training, which means every layer’s input distribution also shifts as training proceeds — the activations a layer receives at step 1,000 look statistically different from the activations it received at step 1. Each layer is effectively chasing a moving target, and the deeper the network, the more layers are chasing targets that are themselves moving because of the layers beneath them. The practical consequences were concrete: learning rates had to be kept small to avoid divergence, weight initialization had to be scaled with unusual care to keep activation variance from exploding or collapsing across depth, and saturating nonlinearities such as sigmoid and tanh were notoriously hard to train once a network had more than a handful of layers, because large pre-activations pushed them into flat regions with near-zero gradient.

None of this was a niche concern. AlexNet’s 2012 breakout showed that depth plus GPU-scale compute could beat decades of hand-engineered computer vision, and the field’s obvious next move was to go deeper still. But going deeper multiplied exactly the instability described above. Adam (December 2014) — the per-parameter adaptive optimizer covered in Chapter 5 — helped by rescaling gradients per parameter, but it addressed the symptom of noisy, badly scaled gradients rather than the underlying drift in what each layer was seeing. Something had to stabilize the activations themselves, not just the updates computed from them.

Going deeper multiplied an instability that Adam only half fixed A per-parameter learning-rate fix arrives first; the activations themselves still need their own stabiliser three months later. Grey monospace text names the chapter that covers each step. 2012 AlexNet Depth plus GPUs wins ImageNet Chapter 2 2012 Dec 2014 Adam Adapts per-parameter learning rates Chapter 5 Dec 2014 Feb 2015 Batch normalization Stabilises layer inputs directly Ioffe, Szegedy Feb 2015 Dec 2015 ResNet Pairs norm with residual connections skip connections Dec 2015 the depth bet fixes the update fixes the activations a pattern later reused everywhere
Adam fixes the update three months before batch normalization fixes the activations themselves; going deeper needed both. PNG ↓

The Breakthrough

Batch normalization (Ioffe and Szegedy, 2015) reframed the problem: rather than asking the network to tolerate shifting input statistics, force those statistics to stay fixed. For each mini-batch during training, the method computes the mean and variance of each feature (each channel, each hidden unit) across the examples in the batch, subtracts the mean and divides by the standard deviation, and then applies a learned scale and shift so the layer can still represent whatever distribution is actually useful. The normalization is folded directly into the model architecture and differentiated through like any other operation, so the network learns around a fixed statistical baseline instead of a moving one.

Fixing the statistics a layer sees, one mini-batch at a time Every activation is forced to zero mean and unit variance, then handed back its own learned scale and shift. The dashed plum arrow is the one path that only matters at inference time. Mini-batch activations x_i Compute stats mean, variance across the batch Normalize zero mean, unit var x hat Scale, shift gamma, beta learned params Nonlinearity ReLU or similar next op Next layer receives y_i stable input Running stats stored for inference no batch needed used only at inference
Everything left of the learned scale and shift happens the same way in training; only the dashed path, running statistics, exists purely to make inference work without a batch. PNG ↓

The paper’s own framing was internal covariate shift: by fixing the distribution each layer sees, the network no longer needs a small learning rate as insurance against distributional drift, and it no longer needs finely hand-tuned initialization to keep variance in a trainable range through depth. The reported effect on a state-of-the-art image classifier was large — the same accuracy in 14 times fewer training steps — and an ensemble of batch-normalized networks pushed the ImageNet top-5 error to 4.9% (4.8% on the test set), below the commonly cited human-rater error rate at the time. Batch normalization also turned out to act as an incidental regularizer: because each example’s normalization statistics depend on the other examples in its mini-batch, the network sees a slightly different transformation of the same input on every pass, an effect strong enough that some architectures dropped Dropout entirely.

The mechanism had a structural dependency, though: it normalizes across the batch dimension, which means it needs a batch of reasonable size to produce stable statistics, and at inference time — often on a single example — it has to fall back to running averages of mean and variance accumulated during training rather than statistics computed on the fly. That dependency was fine for the image classifiers of 2015, trained with batches in the hundreds. It was much less fine for recurrent networks processing variable-length sequences one step at a time, where “the batch” at a given timestep is a thin, awkward slice, and for any setting where per-device batches shrink — for instance under the large-scale data parallelism covered in Chapter 8, where splitting a batch across many accelerators can leave each device with only a handful of examples.

Layer normalization (Ba et al., 2016) removed the dependency by changing which dimension gets normalized. Instead of computing statistics across the examples in a batch, it computes them across the features of a single example — every example normalizes itself, using only its own activations. This makes the computation identical at training and inference time, indifferent to batch size, and a natural fit for recurrent networks and, later, the Transformer, whose sublayers are wrapped in exactly this normalization (full architecture in Language Models, Chapter 5).

Root mean square layer normalization (Zhang and Sennrich, 2019) asked a further question: does layer normalization need both of its two invariances? LayerNorm re-centers (subtracts the mean) and re-scales (divides by the standard deviation). RMSNorm’s authors hypothesized that the re-centering step was dispensable — that re-scaling alone, without computing and subtracting a mean, preserved the useful properties of normalization at a fraction of the compute, since dropping the mean removes an entire reduction and subtraction from every normalization call. Across a range of architectures and tasks, RMSNorm matched LayerNorm’s performance while cutting running time by 7% to 64%, and the simplification proved durable: it became the default normalization in most Transformer-based language models trained from the early 2020s onward, including LLaMA (February 2023) — covered in Language Models, Chapter 14.

Normalization solved instability within a fixed-size network. A separate instability problem appears the moment a team tries to scale that network up: hyperparameters tuned for one width rarely stay optimal at another, and for models with tens or hundreds of billions of parameters, running the equivalent of a grid search directly on the full-size model is not something most budgets tolerate. Tensor Programs V (Yang et al., 2022) introduced the maximal update parameterization (muP): a specific way of scaling initialization variance and learning rate with a network’s width such that a wide family of training dynamics stay stable and, crucially, such that the optimal hyperparameters stay the same across widths within that family. Tune a small proxy model cheaply, and the same hyperparameters transfer zero-shot to a much larger model in the same family — no retuning at scale required.

The Mathematics

Batch normalization’s core operation, applied per feature over a mini-batch, is:

x^i=xi−μBσB2+ϵ,yi=γ x^i+β\hat{x}_i = \frac{x_i - \mu_B}{\sqrt{\sigma_B^2 + \epsilon}}, \qquad y_i = \gamma\,\hat{x}_i + \beta
SymbolMeaning
xix_iraw activation for example ii in the current feature
μB\mu_Bmean of this feature across the mini-batch BB
σB2\sigma_B^2variance of this feature across the mini-batch BB
ϵ\epsilonsmall constant preventing division by zero
x^i\hat{x}_inormalized activation, zero mean and unit variance
γ,β\gamma, \betalearned scale and shift, restoring representational freedom
yiy_ithe layer’s normalized output for example ii

Layer normalization computes the same shape of transformation but along a different axis — across a single example’s own features, not across the batch:

μ=1d∑j=1dxj,σ2=1d∑j=1d(xj−μ)2yi=γi⋅xi−μσ2+ϵ+βi\begin{aligned} \mu &= \frac{1}{d}\sum_{j=1}^{d} x_j, \qquad \sigma^2 = \frac{1}{d}\sum_{j=1}^{d} (x_j - \mu)^2 \\ y_i &= \gamma_i \cdot \frac{x_i - \mu}{\sqrt{\sigma^2 + \epsilon}} + \beta_i \end{aligned}
SymbolMeaning
ddnumber of features in one example’s activation vector
xjx_jthe jj-th feature of the example being normalized
μ,σ2\mu, \sigma^2mean and variance of that example’s own features
xix_ithe specific feature being transformed
ϵ\epsilonsmall constant preventing division by zero
γi,βi\gamma_i, \beta_iper-feature learned scale and shift
yiy_ithe normalized, rescaled output for feature ii

RMSNorm drops the re-centering step entirely and normalizes only by the root mean square of the activations:

RMS(x)=1d∑j=1dxj2+ϵ,yi=γi⋅xiRMS(x)\mathrm{RMS}(x) = \sqrt{\frac{1}{d}\sum_{j=1}^{d} x_j^2 + \epsilon}, \qquad y_i = \gamma_i \cdot \frac{x_i}{\mathrm{RMS}(x)}
SymbolMeaning
ddnumber of features in the example’s activation vector
xjx_jthe jj-th feature, used to compute the RMS statistic
ϵ\epsilonsmall constant preventing division by zero
xix_ithe specific feature being transformed
RMS(x)\mathrm{RMS}(x)root-mean-square magnitude of the example’s features
γi\gamma_iper-feature learned scale
yiy_ithe normalized, rescaled output for feature ii

muP addresses a different variable entirely — not activation statistics within one network, but how hyperparameters should change as a network’s width changes. In its simplest form, for the hidden layers of a network family under muP, the learning rate and initialization variance at width nn are set relative to a tuned base width n0n_0 by:

η(n)=η0⋅n0n,σ2(n)=σ02⋅n0n\eta(n) = \eta_0 \cdot \frac{n_0}{n}, \qquad \sigma^2(n) = \sigma_0^2 \cdot \frac{n_0}{n}
SymbolMeaning
n0n_0width of the small, cheaply tuned proxy model
nnwidth of the full-size target model
η0,η(n)\eta_0, \eta(n)learning rate at the proxy width and at width nn
σ02,σ2(n)\sigma_0^2, \sigma^2(n)initialization variance at the proxy width and at width nn

What It Enabled

Normalization did not stay confined to image classifiers. Within months, DCGAN (November 2015) — covered in Image Generation, Chapter 4 — leaned on batch normalization as one of its key stabilizers for what was, at the time, a famously unstable training procedure. Later that same year, ResNet paired normalization with residual connections (the skip-connection idea taught in Chapter 1) to push trainable depth past 100 layers; the two techniques became a standard combination, each addressing a different failure mode of very deep networks. As sequence models and then Transformers took over language modeling, LayerNorm’s independence from batch size made it the default, and RMSNorm’s efficiency gain made it the default’s default — a small, compounding saving multiplied across every layer of every forward and backward pass of every large model trained since.

BatchNorm (2015)LayerNorm (2016)RMSNorm (2019)
Statistics computed overfeatures, across the batchfeatures, within one examplefeatures, within one example
Depends on batch sizeyes — needs running averages at inferencenono
Re-centers (subtracts mean)yesyesno
Best fitfixed-size batches, image CNNssequences, variable batch size, TransformersTransformers at scale
Reported efficiency claim14x fewer steps to matched accuracy—7%–64% less running time than LayerNorm

muP’s effect was narrower but, at frontier scale, more consequential for project economics. Tensor Programs V reported that transferring hyperparameters tuned on a 13-million-parameter proxy surpassed published BERT-large (350M parameters) results at a tuning cost equivalent to a single BERT-large pretraining run, and that transferring from a 40-million-parameter proxy outperformed the released 6.7-billion-parameter GPT-3 model at only 7% of the typical pretraining compute for a model that size. OpenAI’s GPT-4 technical report states plainly that “it is not feasible to do extensive model-specific tuning” on a training run at that scale, and lists Tensor Programs V among its cited references — muP’s proxy-then-transfer method is one answer to the question every later chapter on frontier training runs has to confront: how do you tune something you can only afford to train once. Chapter 10 covers the companion question of how much compute a given model size and dataset size should receive; muP is the piece that lets you find good hyperparameters for that compute-optimal model without spending the same budget twice.

Two separate lineages, both trying to make an expensive run tunable One stabilises what each layer sees; the other stabilises which hyperparameters to use before the run even starts. Grey monospace text is the year each step shipped. NORMALIZATION LINEAGE HYPERPARAMETER TRANSFER BatchNorm layer input stability 2015 LayerNorm batch-size independent 2016 RMSNorm drops re-centering 2019 Default in LLaMA-era LLMs nearly every large model 2023 onward Adam per-parameter rates 2014 muP hyperparameters transfer by width 2022 Cited in GPT-4 report tune once, not twice 2023
One lineage stabilises what a layer sees; the other stabilises which hyperparameters to use before an expensive run even starts. PNG ↓

Key Papers

PaperAuthorsYearLinkWhy it matters
Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate ShiftIoffe and Szegedy2015arXiv:1502.03167First normalization layer folded into the architecture; let deep networks train with higher learning rates and looser initialization
Layer NormalizationBa et al.2016arXiv:1607.06450Removed the batch-size dependency by normalizing across features instead of across examples; became the Transformer’s default
Root Mean Square Layer NormalizationZhang and Sennrich2019arXiv:1910.07467Dropped re-centering to cut normalization cost by up to 64%; the default in most large language models trained after 2020
Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter TransferYang et al.2022arXiv:2203.03466Introduced muP, letting hyperparameters tuned on a small proxy model transfer zero-shot to a much larger one

PM Lens

Papers referenced