Skip to content

Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfer

Skip →DCLM
Pretraining stage 2 #3extendedfundamentalpaperrubric 8/122022 · NeurIPS 2021 · ~30 min

Greg Yang, Edward J. Hu, Igor Babuschkin, …, Jianfeng Gao

Status

TL;DR. In the standard parametrisation (SP), the best learning rate and initialisation change as you widen a network, so tuning a large model requires sweeps at full size. Yang et al. show that under the Maximal Update Parametrization (μP), many optimal hyperparameters stay nearly constant with width. You can therefore tune a small proxy and copy the values to the large model unchanged (μTransfer).

μP is an “abc-parametrisation”: per-layer choices of a multiplier, an initialisation variance and a learning-rate scale, as functions of width. The rules (Table 3) for Adam:

LayerInit varianceAdam LR
Input weights and all biases1/fan_in1 (fixed)
Hidden weights1/fan_in1/fan_in
Output weights1/fan_in² (SP: 1/fan_in)1/fan_in

Attention uses q⊤k/dq^\top k/d instead of q⊤k/dq^\top k/\sqrt{d}. With these rules every layer’s features change by Θ(1)\Theta(1) per step at any width, so feature updates are comparable across widths; empirically, many good hyperparameter settings then transfer approximately from narrow to wide models. The paper argues μP is the unique parametrisation in this family with that property.

Results. Transferring hyperparameters from a 13M-parameter proxy beats the published BERT-large (350M) numbers, with total tuning cost about one BERT-large pretraining. Transferring from a 40M proxy beats the published 6.7B GPT-3 results with tuning cost only 7% of pretraining cost. The open-source mup package implements the rules for PyTorch.

  • Kaplan scaling laws — scaling-law fits assume each size is well tuned; μP makes that cheaper.
  • Muon — its per-shape update scale (0.2·√max(A, B)) is another rule for keeping updates comparable across matrix shapes.
  • AdamW — the optimizer whose LR scaling μP prescribes.
  • GPT-3 — the 6.7B baseline that μTransfer beats.

Questions to think through

These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.

  1. Derive / compute

    Under Adam, each entry of a hidden weight update has size about η regardless of width n. Show that the change in a hidden pre-activation, ΔW·x with x of width n and Θ(1) entries, grows as Θ(η·n) when the update is aligned with x, and use this to justify μP's 1/fan_in Adam learning rate for hidden weights. If the tuned hidden learning rate is 1×10⁻³ at width 256, what should it be at width 4096?

    What a strong answer covers
    • After a step, ΔW is correlated with the input x (it is built from x times a gradient), so the n terms in (ΔW x)_i add coherently, giving Θ(η·n) instead of the Θ(η·√n) for random signs.
    • To keep the feature update Θ(1) as n grows, η must scale as 1/n, which is the 1/fan_in rule in μP's Table 3.
    • For SGD the gradient entries already shrink with width, which is why the hidden SGD learning rate in μP is constant.
    • Width 256 → 4096 is ×16, so the hidden Adam LR becomes 1×10⁻³/16 ≈ 6.25×10⁻⁵. Input-layer and bias LRs stay fixed, and the output layer also scales as 1/fan_in.
  2. Mechanism

    μP replaces the usual 1/√d attention scaling by 1/d and initialises output weights with variance 1/fan_in² instead of 1/fan_in. Explain the mechanism behind each change, and why standard parametrisation's logits blow up with width after training starts.

    What a strong answer covers
    • At initialisation q and k are roughly independent, so q·k is Θ(√d) and 1/√d is right. After training, q and k become correlated, so q·k grows as Θ(d); 1/d keeps attention logits Θ(1) at all widths.
    • The output layer sums n features that become correlated with the readout weights during training. With 1/fan_in variance this sum grows with width after one step, so logits blow up; 1/fan_in² keeps them Θ(1).
    • In standard parametrisation the optimal learning rate therefore shrinks with width, so a value tuned on a small model diverges or under-trains on a large one.
    • μP is chosen so every layer's features change by Θ(1) per step at any width, the "maximal update" that keeps feature learning (unlike the kernel regime).
  3. Design

    You are scaling a reranker from 100M to 3B parameters by widening it. Design a μTransfer workflow, say which hyperparameters you expect to transfer and which you would still check at full size, and give a quick test that your μP implementation is correct.

    What a strong answer covers
    • Parametrise in μP (the mup package helps), keep depth and other shapes fixed, and tune LR, initialisation scale, and per-layer multipliers on a narrow proxy.
    • Table 1: optimisation HPs (LR, schedule, Adam betas), initialisation and parameter multipliers transfer; regularisation (dropout, weight decay) does not. Transfer across depth, batch size, training time and sequence length is validated only empirically on Transformers, so re-check those at full size.
    • Correctness check ("coordinate check"): train a few steps at several widths and plot the size of activations per layer; under μP they should stay flat with width, under SP some grow.
    • Validate by sweeping LR at two widths: the loss-vs-LR curves should have their minimum at the same value.

Done with this page?

Status