Sam Babichenko

Reading notes / Lazy training and feature learning

Maximal update parametrization

Yang and Hu, 2021

Context. By 2020 wide networks had two infinite-width limits, NTK (frozen features, kernel regression) and mean field (moving neurons, but only for one hidden layer), and the standard parametrization used in practice fit neither. Yang and Hu scale each layer's multiplier and initialization variance, and the learning rate, as powers of the width and classify the whole space. After one step a weight update is correlated with the activations it multiplies, so it acts by a law of large numbers (a factor nn) where the random initialization acts by a central limit theorem (a factor n\sqrt n). Balancing these exponents gives one number r≥0r\ge0 with ΔxL=Θ(n−r)\Delta x^L=\Theta(n^{-r}): every stable, nontrivial parametrization either has r>0r>0, frozen features and kernel gradient descent, or r=0r=0, moving features and no kernel description. The Maximal Update Parametrization (μ\muP), which extends mean field to depth, updates every layer as much as stability allows.

Setting. An LL-hidden-layer MLP h1=W1ξh^1=W^1\xi, xl=ϕ(hl)x^l=\phi(h^l), hl+1=Wl+1xlh^{l+1}=W^{l+1}x^l, f(ξ)=WL+1xLf(\xi)=W^{L+1}x^L of width nn, trained by batch-1 SGD for a number of steps that does not grow with nn. An abc-parametrization sets Wl=n−alwlW^l=n^{-a_l}w^l with trainable wαβl∼N(0,n−2bl)w^l_{\alpha\beta}\sim N(0,n^{-2b_l}) and learning rate ηn−c\eta n^{-c}; the shift al↦al+θa_l\mapsto a_l+\theta, bl↦bl−θb_l\mapsto b_l-\theta, c↦c−2θc\mapsto c-2\theta leaves training unchanged. The named points are NTK (a1=0a_1=0, al=12a_l=\frac12 for l≥2l\ge2, bl=0b_l=0, c=0c=0), the standard parametrization SP, PyTorch's default (al=0a_l=0, b1=0b_1=0, bl=12b_l=\frac12 for l≥2l\ge2), one-hidden-layer mean field (a1=0a_1=0, a2=1a_2=1, b=0b=0, c=−1c=-1), and μ\muP (a1=−12a_1=-\frac12, al=0a_l=0 for 2≤l≤L2\le l\le L, aL+1=12a_{L+1}=\frac12, bl=12b_l=\frac12, c=0c=0). Stable means hl,xlh^l,x^l are Θ(1)\Theta(1) at initialization and hl,xl,fh^l,x^l,f stay O(1)O(1) in training; nontrivial means ff moves. The classification assumes ϕ=tanh⁡\phi=\tanh or a smoothed ReLU.

Theorems 3.3 to 3.9 (stability, nontriviality, Dynamical Dichotomy). Let r=min⁡(aL+1+bL+1, 2aL+1+c)+c−1+min⁡l≤L[2al+1(l=1)].r=\min(a_{L+1}+b_{L+1},\,2a_{L+1}+c)+c-1+\min_{l\le L}\big[2a_l+\mathbb 1(l=1)\big]. The parametrization is stable iff a1+b1=0a_1+b_1=0, al+bl=12a_l+b_l=\frac12 for 2≤l≤L2\le l\le L, aL+1+bL+1≥12a_{L+1}+b_{L+1}\ge\frac12, r≥0r\ge0, 2aL+1+c≥12a_{L+1}+c\ge1 and aL+1+bL+1+r≥1a_{L+1}+b_{L+1}+r\ge1, and then nontrivial iff one of the last two is an equality. A nontrivial stable parametrization admits feature learning (ΔxL\Delta x^L has Ω(1)\Omega(1) coordinates for some routine) iff it evolves the feature kernel iff r=0r=0, and it is in the kernel regime (the limit is ft+1(ξ)=ft(ξ)−ηK(ξ,ξt)L′(ft(ξt),yt)f_{t+1}(\xi)=f_t(\xi)-\eta K(\xi,\xi_t)\mathcal L'(f_t(\xi_t),y_t) for a PSD KK) iff r>0r>0. Corollary 3.10: every feature-learning limit has f0→0f_0\to0 and is deterministic. Theorem H.17: in a kernel-regime limit pretraining has no effect on transfer: a new head, with or without fine-tuning the body, gives the same limit as random initialization.

Theorem 4.1, Theorem 5.6 and the Master Theorem. SP is stable for all routines only with learning rate O(1/n)O(1/n) (c≥1c\ge1); the nontrivial choice c=1c=1 gives r=12r=\frac12 for L≥2L\ge2, the kernel regime. In μ\muP every WlW^l, l≤L+1l\le L+1, is updated maximally (ΔWtlxtl−1\Delta W^l_tx^{l-1}_t has Θ(1)\Theta(1) coordinates, and ΔWtL+1xtL=Θ(1)\Delta W^{L+1}_tx^L_t=\Theta(1)) and WL+1W^{L+1} is also initialized maximally (W0L+1ΔxtL=Θ(1)W^{L+1}_0\Delta x^L_t=\Theta(1)), and μ\muP is the unique stable abc-parametrization with this property, modulo the shift. Master Theorem (from Tensor Programs III): for any program built from Gaussian n×nn\times n matrices with N(0,σW2/n)N(0,\sigma_W^2/n) entries, initial vectors with i.i.d. Gaussian coordinates, MatMul, coordinatewise Nonlin and Moment (coordinate averages), and pseudo-Lipschitz ψ\psi, 1n∑α=1nψ(hα1,…,hαk)→a.s.E ψ(Zh1,…,Zhk),\frac1n\sum_{\alpha=1}^n\psi(h^1_\alpha,\dots,h^k_\alpha)\xrightarrow{a.s.}\mathbb E\,\psi(Z^{h^1},\dots,Z^{h^k}), where the random variables ZhZ^h are defined recursively by the rules of Step 4.

Step 1

One step of a one-hidden-layer network shows why the exponents matter. Take f=Vxf=Vx, x=ϕ(Uξ)x=\phi(U\xi), V=n−avvV=n^{-a_v}v, U=n−auuU=n^{-a_u}u, and χ0=L′(f0,y0)=Θ(1)\chi_0=\mathcal L'(f_0,y_0)=\Theta(1). One step moves the preactivations by Δh1(ξ)=−n−2auχ0ξ0ξ (V0⊤⊙ϕ′(h0)).\Delta h_1(\xi)=-n^{-2a_u}\chi_0\xi_0\xi\,(V_0^\top\odot\phi'(h_0)). In NTK, au=0a_u=0 and V0V_0 has coordinates Θ(n−1/2)\Theta(n^{-1/2}), so Δx1=Θ(n−1/2)\Delta x_1=\Theta(n^{-1/2}) and the feature kernel does not move. The output still moves by Θ(1)\Theta(1), through V0Δx1=−χ0ξ0ξ∑α(V0α)2ϕ′(h0(ξ)α)ϕ′(h0α)V_0\Delta x_1=-\chi_0\xi_0\xi\sum_\alpha(V_{0\alpha})^2\phi'(h_0(\xi)_\alpha)\phi'(h_{0\alpha}), a sum of nn positive-mean terms of size 1/n1/n, and through ΔV1x0\Delta V_1x_0, while ΔV1Δx1→0\Delta V_1\Delta x_1\to0. In μ\muP (au=−12a_u=-\frac12, V0V_0 of size 1/n1/n) it gives Δh1=Θ(n)⋅Θ(1/n)=Θ(1)\Delta h_1=\Theta(n)\cdot\Theta(1/n)=\Theta(1), so features move, and with nonlinear ϕ\phi the step is not linear in η\eta, which rules out a kernel.

Step 2

Stability comes down to comparing CLT and LLN exponents. At initialization Wlxl−1W^lx^{l-1} has coordinates of size n1/2−al−bln^{1/2-a_l-b_l} by the CLT, which fixes al+bla_l+b_l. A gradient step adds the rank-one δWl=−ηn−c−2aldh x⊤\delta W^l=-\eta n^{-c-2a_l}dh\,x^\top, and in the next forward pass δWlxˉ=−η n1−c−2al(x⊤xˉn)dh,\delta W^l\bar x=-\eta\,n^{1-c-2a_l}\Big(\frac{x^\top\bar x}{n}\Big)dh, where x⊤xˉ/nx^\top\bar x/n has a nonzero limit because the new activation is correlated with the old one: a law of large numbers, which gives a full factor nn. With dhdh of the readout's size, n−(aL+1+bL+1)+n−(2aL+1+c)n^{-(a_{L+1}+b_{L+1})}+n^{-(2a_{L+1}+c)}, this is Θ(n−rl)\Theta(n^{-r_l}) with rl=min⁡(aL+1+bL+1,2aL+1+c)+c−1+2al+1(l=1)r_l=\min(a_{L+1}+b_{L+1},2a_{L+1}+c)+c-1+2a_l+\mathbb 1(l=1), the indicator accounting for the fixed input dimension, and r=min⁡lrlr=\min_lr_l. So r≥0r\ge0 means the features do not blow up, the other two conditions bound the readout's update and its initial weights acting on the feature change, and imposing maximal updates everywhere leaves only μ\muP.

Step 3

SP is forced into the kernel regime, and μ\muP is the minimal fix. In a two-hidden-layer linear SP network f=Vhˉf=V\bar h, hˉ=Wh\bar h=Wh, h=Uξh=U\xi, with Uαβ∼N(0,1)U_{\alpha\beta}\sim N(0,1) and W,V∼N(0,1/n)W,V\sim N(0,1/n), one step on WW gives f1=f0−n−cχ (VV⊤)(h⊤h)=f0−Θ(n1−c)f_1=f_0-n^{-c}\chi\,(VV^\top)(h^\top h)=f_0-\Theta(n^{1-c}), since h⊤h=Θ(n)h^\top h=\Theta(n) by the LLN. So c≥1c\ge1; then hˉ\bar h moves by O(n−1/2)O(n^{-1/2}) per coordinate, r=12r=\frac12, and f1−f0→−χ∥ξ∥2f_1-f_0\to-\chi\|\xi\|^2, kernel descent with the linear kernel. The blowup comes from the LLN: at initialization WL+1xLW^{L+1}x^L is a sum of independent zero-mean terms, but after one update x1Lx^L_1 is correlated with W1L+1W^{L+1}_1 and the sum grows like n1−aL+1−bL+1n^{1-a_{L+1}-b_{L+1}}. Dividing the logits by n\sqrt n (aL+1=12a_{L+1}=\frac12) with c=0c=0 keeps ff bounded and lets hˉ\bar h move by Θ(1)\Theta(1). The first layer still moves only by O(1/n)O(1/n), since its backward vector has coordinates of size 1/n1/n; a1=−12a_1=-\frac12, b1=12b_1=\frac12 (same forward pass, gradient scaled up by nn) fixes that, and hidden layers keep the standard N(0,1/n)N(0,1/n) initialization.

Step 4

Tensor Programs compute every limit by tracking a typical coordinate. Write training as a program and give each vector hh a random variable ZhZ^h for a typical coordinate: Gaussian for initial vectors, the function applied for Nonlin, an expectation for Moment. A product WxWx splits as ZWx=Z^Wx+Z˙WxZ^{Wx}=\hat Z^{Wx}+\dot Z^{Wx}: the first part is jointly Gaussian with Cov(Z^Wx,Z^Wy)=σW2EZxZy\mathrm{Cov}(\hat Z^{Wx},\hat Z^{Wy})=\sigma_W^2\mathbb EZ^xZ^y, as if WW were independent of xx; the second corrects for using both WW and W⊤W^\top, as backpropagation does, by a Gaussian integration-by-parts (Stein) term Z˙Wx=σW2∑iZyi E∂Zx∂Z^W⊤yi\dot Z^{Wx}=\sigma_W^2\sum_iZ^{y^i}\,\mathbb E\frac{\partial Z^x}{\partial\hat Z^{W^\top y^i}} over the vectors yiy^i that xx depends on through W⊤yiW^\top y^i. For one hidden layer in μ\muP the limit is a closed recursion (Theorem 6.1), f˚t(ξ)=E ZnVtϕ(ξZUt),ZnVt+1=ZnVt−χ˚tϕ(ξtZUt),ZUt+1=ZUt−χ˚tξtZnVtϕ′(ξtZUt).\mathring f_t(\xi)=\mathbb E\,Z^{nV_t}\phi(\xi Z^{U_t}),\quad Z^{nV_{t+1}}=Z^{nV_t}-\mathring\chi_t\phi(\xi_tZ^{U_t}),\quad Z^{U_{t+1}}=Z^{U_t}-\mathring\chi_t\xi_tZ^{nV_t}\phi'(\xi_tZ^{U_t}). For linear ϕ\phi, ZUtZ^{U_t} and ZnVtZ^{nV_t} stay linear combinations of the two initial Gaussians, so the limit is a width-(d+do)(d+d_o) network with diagonal initialization, which makes the Word2Vec and MAML limits computable; for nonlinear networks the nesting of ϕ′\phi' inside ϕ\phi (and, in deeper networks, the Z˙\dot Z terms) makes the cost grow exponentially with the number of steps.

Step 5

The dichotomy, from the limit equations. If r>0r>0, every scalar multiplying a feature update vanishes, features stay at initialization, and the logit update unrolls into kernel gradient descent with an NTK-type kernel, assembled from feature kernels at initialization and products of Eϕ′ϕ′\mathbb E\phi'\phi' terms over the layers updated at leading order. If r=0r=0, ∂η2E(Zx1L(ξ0))2≠0\partial_\eta^2\mathbb E(Z^{x^L_1(\xi_0)})^2\ne0 at η=0\eta=0 (the first derivative vanishes) and ∂η3f˚1(ξ)≠0\partial_\eta^3\mathring f_1(\xi)\ne0, so a small learning rate moves the feature kernel and the first step is not linear in η\eta. Corollary 3.10 follows from the exponents: r=0r=0 and stability force aL+1+bL+1≥1a_{L+1}+b_{L+1}\ge1, so f0f_0, of size n1/2−aL+1−bL+1n^{1/2-a_{L+1}-b_{L+1}}, vanishes, and a feature-learning limit has no Gaussian-process prior. Kernel limits trivialize transfer because the body acts on the output only through W0L+1W^{L+1}_0, which a new head resamples.

Step 6

In experiments the stable learning rate stays fixed with width under μ\muP, and the μ\muP limit learns features. On CIFAR-10 the largest stable learning rate scales like 1/width1/\text{width} in SP and stays constant in μ\muP. On Omniglot 1-shot 5-way with first-order MAML, the μ\muP limit of a one-hidden-layer linear network reaches 66.42% meta-test accuracy, against 47.60% and 47.82% for the GP and NTK limits of a ReLU network. On Word2Vec analogies the μ\muP limit scores 43.31% after text8 and 56.45% after fil9, while NTK and GP limits score essentially 0, since frozen embeddings make the answer uniform over the vocabulary. These are linear one-hidden-layer models chosen so the limit is computable; that deep nonlinear μ\muP limits model practice is only suggested.

Consequences and limits. The practical payoff came in Tensor Programs V: since μ\muP has a nontrivial limit in which every layer keeps learning at the same rate, optimal hyperparameters such as learning rate, initialization scale and multipliers are approximately stable in width, so they can be tuned on a small proxy and copied to the large model (μ\muTransfer). A 13M-parameter proxy beat the published BERT-large (350M) at a total tuning cost of about one BERT-large pretraining, and a 40M proxy beat the published 6.7B GPT-3 at 7% of its pretraining cost. Regularization (dropout, weight decay) does not transfer, transfer across depth, batch size and sequence length is only empirical, Adam needs its own μ\muP table (hidden-layer learning rate ∝1/fan-in\propto1/\text{fan-in}), and attention logits are scaled by 1/d1/d instead of 1/d1/\sqrt d. The paper fixes training time as n→∞n\to\infty (so leaving the kernel regime through a large learning rate, which takes time growing with width, is outside it), treats MLPs with batch-1 SGD, and leaves nonlinear deep limits expensive to compute exactly.

Terms

abc-parametrization
Wl=n−alwlW^l=n^{-a_l}w^l, wl∼N(0,n−2bl)w^l\sim N(0,n^{-2b_l}), learning rate ηn−c\eta n^{-c}
Symmetry
(al,bl,c)↦(al+θ,bl−θ,c−2θ)(a_l,b_l,c)\mapsto(a_l+\theta,b_l-\theta,c-2\theta) leaves training unchanged
rr
exponent with ΔxL=Θ(n−r)\Delta x^L=\Theta(n^{-r}); stability needs r≥0r\ge0
Dynamical Dichotomy
stable nontrivial: r>0r>0 kernel regime, r=0r=0 feature learning, never both
CLT vs LLN
initial weights act like n\sqrt n on activations, updates like nn, being correlated with them
Standard parametrization
needs c≥1c\ge1 (learning rate O(1/n)O(1/n)) for stability; at c=1c=1, r=12r=\frac12 (L≥2L\ge2): kernel
μ\muP
a1=−12a_1=-\frac12, aL+1=12a_{L+1}=\frac12, other al=0a_l=0, bl=12b_l=\frac12, c=0c=0; every layer updated maximally
Corollary 3.10
feature learning forces f0→0f_0\to0 and a deterministic limit; no GP prior
ZhZ^h
random variable for a typical coordinate of vector hh at infinite width
μ\muTransfer
tune hyperparameters on a small μ\muP model, copy them to the wide one

Quiz

  1. Corollary 3.10 says every feature-learning limit has f0→0f_0\to0. Where does this come from?
  2. Why does the dichotomy theorem assume ϕ\phi is tanh or a smoothed ReLU?
  3. In the one-hidden-layer μ\muP limit with linear ϕ\phi, why is the infinite-width network cheap to compute?
  4. Tensor Programs V tunes hyperparameters on a small model and copies them to a large one. Why does this need μ\muP?

Sources