Chapter 2 · Pretraining¶
2.1 What is the pretraining objective, and why does next-token prediction teach so many abilities? ★★¶
One-sentence answer
The pretraining objective is next-token prediction on massive unlabeled text: given the preceding context, maximize the probability of the true next token, which is equivalent to minimizing cross-entropy. It teaches many abilities because, to predict the next token well across all kinds of text, the model must master the regularities that generated that text (grammar, knowledge, code semantics and reasoning steps); and because text naturally contains a vast number of tasks, this single objective amounts to training on countless tasks at once.
I will address three aspects: what the objective is, why it teaches so many abilities, and where its limitations lie.
(1) Objective: predict the next token given the preceding context; the loss is cross-entropy.
Suppose a piece of text is tokenized into the sequence \(x_1,\dots,x_T\) and the model has parameters \(\theta\). The pretraining loss is
where \(x_{<t}\) denotes all tokens before position \(t\), and \(p_\theta(x_t\mid x_{<t})\) is the probability the model assigns to the true next token. The higher the probability the model gives to the correct answer, the lower the loss. Thanks to the causal mask, a single forward pass yields predictions for all positions at once, so training is very efficient. The objective requires no human labels at all, since the text itself is the supervision signal, which is why data on the order of ten trillion tokens can be used.
(2) Reasons: there are three main reasons this simple objective teaches so many abilities.
- Predicting well requires understanding the regularities behind the text: For example, to predict the word after "The capital of France is", the model must know Paris; to predict the next line of code, it must understand what the earlier variables mean; to predict the next step of a math proof, it must follow the derivation so far. The more diverse the data, the more the model is forced to learn in order to lower the loss. This is often summarized as "prediction is compression": the better the predictions, the shorter the code needed to describe the data, and a shorter code means more regularities have been captured.
- Text naturally contains a vast number of tasks: Web pages contain parallel translations, Q&A, tutorials, commented code and worked exercises. Continuing such text is itself performing tasks like translation, question answering and coding. Next-token prediction is therefore a form of implicit multi-task learning (Radford et al. 2019), and in-context learning, i.e. completing a new task from a few examples in the prompt, is an ability that arises naturally from this kind of training (Brown et al. 2020).
- The signal is dense and keeps scaling: Every token provides a supervision signal, so each unit of data carries a lot of information; at the same time, the loss decreases smoothly and predictably with parameters and data (see 2.3), so increasing scale keeps bringing improvements.
(3) Limitation: it learns "the distribution of text", not "a helpful assistant".
Pretraining only asks the model to imitate the distribution of the training text, so a base model faithfully reproduces the errors, biases and harmful content in that text, and it only continues text rather than actively following instructions. For example, if you ask it a question, it may continue with more similar questions, because on the web a question is often followed by more questions. Therefore, mid-training and post-training are still needed after pretraining to steer the model's abilities toward useful behavior (see Chapter 4 and Chapter 5).
In summary: next-token prediction is a simple, label-free and indefinitely scalable objective, and "predicting the next token well" forces the model to learn the regularities behind the text, which is precisely where pretrained abilities come from.
Going deeper: cross-entropy, KL divergence and why prediction is compression
(1) Minimizing cross-entropy is equivalent to minimizing the KL divergence from the true distribution, and to maximum likelihood estimation.
Let the true data distribution be \(p_{\text{data}}\) and the model distribution be \(p_\theta\). Their cross-entropy decomposes as
Here \(H(p_{\text{data}})\) is the entropy of the data itself; it does not depend on the model, represents the inherent uncertainty of language, and can never be reduced. Minimizing cross-entropy is therefore equivalent to minimizing the KL divergence, which pulls the model distribution toward the true distribution. On the training set, the cross-entropy loss is exactly the average negative log-likelihood, so it is also equivalent to maximum likelihood estimation.
(2) Prediction and compression are the same thing: cross-entropy is the average code length when the model is used for lossless compression.
With arithmetic coding, a model that assigns probability \(p_\theta(x_t\mid x_{<t})\) to token \(x_t\) can encode that token in about \(-\log_2 p_\theta(x_t\mid x_{<t})\) bits. The compressed length of a whole text therefore equals the sum of the base-2 losses, so lowering the loss is exactly equivalent to improving the compression rate. Delétang et al. (2023) tested this view experimentally: Chinchilla 70B, trained mainly on text, compresses ImageNet image patches to 43.4% of their raw size and LibriSpeech audio to 16.4%, beating the specialized PNG (58.5%) and FLAC (30.3%).
Follow-up questions
Follow-up 1: On which tokens is the pretraining loss computed, and how does this differ from SFT?
Pretraining computes the loss on all tokens, whereas SFT usually computes it only on the response. In pretraining, many documents are concatenated end to end and packed into fixed-length sequences, with an end-of-sequence token (EOS) between documents; every position in the sequence is a valid prediction target, so compute utilization is close to 100%. The purpose of SFT is to teach the model "how to respond", so the prompt is usually loss-masked and the loss is computed only on the response (see Chapter 5).
Follow-up 2: What are the limitations of next-token prediction, and are there complementary training objectives?
One limitation is that teacher forcing only trains "one-step prediction", which can lead to shortcuts on tasks that require planning ahead. During training the model is always conditioned on the true preceding context. Bachmann & Nagarajan (2024) constructed a simple path-finding task on a graph and found that the model exploits the previous ground-truth token as a shortcut instead of learning genuine planning. One complement is multi-token prediction, in which the model predicts several upcoming tokens at each position (Gloeckle et al. 2024); DeepSeek-V3 uses it as an auxiliary training objective.
Follow-up 3: How do BERT's masked LM and GPT's next-token prediction differ, and why does everyone now use the latter?
Masked LM predicts only the roughly 15% of tokens that are masked, whereas next-token prediction makes a prediction at every position and naturally supports generation. BERT randomly masks some tokens and predicts them from context on both sides, which is well suited to providing representations for understanding tasks; but only a few tokens per sequence provide a supervision signal, and it cannot directly generate text from left to right. Causal language modeling has a supervision signal at every position, trains the same way it generates, and exhibits in-context learning at scale, which is why it became the standard for today's LLMs.
Common mistakes
- Do not say "pretraining is just memorizing the training data": The model does memorize some frequent content, but the loss also falls on text it has never seen, which shows that it learns generalizable regularities.
- Do not say a base model already follows instructions: A base model only continues text; instruction following comes mainly from post-training.
- Do not say the lower bound of the cross-entropy is 0: Language is inherently uncertain, so the lower bound of the loss is the data entropy \(H(p_{\text{data}})\).
2.2 What is perplexity, and how does it relate to cross-entropy? ★★¶
One-sentence answer
Perplexity is the exponential of the average per-token cross-entropy loss, \(\mathrm{PPL}=\exp(\mathcal{L})\) (with the loss in natural log). Intuitively, it says how many candidate tokens the model is, on average, guessing uniformly among at each step, and lower is better; but it depends on the tokenizer and the evaluation data, cannot be compared directly across tokenizers, and does not fully represent downstream ability.
I will address three aspects: the definition and the relationship, the intuition, and the pitfalls in using it.
(1) Definition: perplexity is the exponential of the cross-entropy loss.
Let the model's average per-token negative log-likelihood on a text be \(\mathcal{L}=-\frac{1}{T}\sum_{t}\ln p_\theta(x_t\mid x_{<t})\). Then perplexity is \(\mathrm{PPL}=\exp(\mathcal{L})\). If the loss is computed with base-2 logarithms (in bits), then \(\mathrm{PPL}=2^{\mathcal{L}}\); both calculations give the same perplexity, and only the unit of the loss differs. Perplexity and cross-entropy therefore correspond monotonically: lowering one means lowering the other. For example, a loss of 2.0 nats corresponds to a perplexity of about \(e^{2.0}\approx 7.4\).
(2) Intuition: how many options the model hesitates between at each step, on average.
If at every step the model spreads its probability evenly over \(k\) tokens and the correct answer is always among them, the loss at each step is \(\ln k\) and the perplexity is exactly \(k\). So PPL = 1 means the model is completely certain and correct every time, while PPL = 20 means that, on average, it is as if the model were guessing at random among 20 candidates. Because language is inherently uncertain, perplexity has a lower bound \(\exp(H(p_{\text{data}}))\) and can never reach 1.
(3) Pitfalls: there are three points to watch when using perplexity.
- It cannot be compared directly across tokenizers: Perplexity is averaged per token. A model with a larger vocabulary covers more text per token, so each token is harder to predict and perplexity is naturally higher, but that does not mean the model is worse. For comparisons across tokenizers, convert to a byte-normalized metric such as bits-per-byte (BPB).
- It correlates with downstream ability but is not the same thing: Within one model family, lower perplexity usually means better downstream performance; but perplexity is dominated by the many easy-to-predict tokens and is insensitive to abilities such as reasoning and instruction following.
- It depends heavily on the evaluation data: Perplexities are comparable only on the same evaluation data; and if the evaluation text appeared in the training data (contamination), perplexity is badly underestimated.
In summary: perplexity is the exponential form of cross-entropy and is suitable for comparing models or monitoring training with the same tokenizer on the same evaluation set; comparisons across tokenizers need bits-per-byte, and assessing abilities requires downstream tasks.
Going deeper: converting to bits-per-byte, and a counterintuitive example
(1) Bits-per-byte normalizes the loss by the number of bytes in the raw text, so it is independent of the tokenizer.
where the numerator is the total negative log-likelihood of the text (in nats), dividing by \(\ln 2\) converts it to bits, \(N_{\text{bytes}}\) is the number of UTF-8 bytes in the text, and \(\bar b\) is the average number of bytes per token.
(2) A model with higher perplexity can actually be better when measured per byte.
| Model | Average bytes per token \(\bar b\) | Loss per token (nats) | Perplexity | BPB |
|---|---|---|---|---|
| Model A (large vocabulary) | 4 | 2.4 | \(e^{2.4}\approx 11.0\) | \(2.4/(0.693\times 4)\approx 0.87\) |
| Model B (small vocabulary) | 3 | 2.0 | \(e^{2.0}\approx 7.4\) | \(2.0/(0.693\times 3)\approx 0.96\) |
Model A has the higher perplexity, but it describes the same text with fewer bits, so it actually models the text better.
Follow-up questions
Follow-up 1: Does lower perplexity always mean better downstream performance?
Not necessarily; the two are strongly correlated only when the data, tokenizer and architecture are all the same. Under those conditions, models with the same pretraining loss perform about the same downstream, regardless of their parameter count and data size (Du et al. 2024). But once the tokenizer or data distribution changes, perplexity is no longer comparable; and perplexity is insensitive to abilities such as reasoning and instruction following, which have to be evaluated with downstream tasks.
Follow-up 2: What is the lower bound of the cross-entropy loss? Can the training loss reach 0?
No; the lower bound is the entropy of the data itself. Language is inherently uncertain, and many words can reasonably follow the same context, so even a model that perfectly learned the true distribution could only reduce the loss to \(H(p_{\text{data}})\). The constant term \(E\) in Chinchilla's parametric scaling law is an estimate of exactly this irreducible part (see 2.3).
Follow-up 3: Can long-context models be evaluated with perplexity?
Not reliably. Most tokens in a long text can be predicted from nearby context alone, so perplexity is insensitive to whether the model actually uses distant information. Gao et al. (2024) found that as the share of long data in long-context training increased, perplexity kept improving while long-context downstream tasks actually got worse; long-context downstream tasks should therefore be used for evaluation (see 4.3).
Common mistakes
- Do not compare perplexity directly between models with different tokenizers: Convert to bits-per-byte instead.
- Do not mix \(\ln\) and \(\log_2\) without saying so: With nats, \(\mathrm{PPL}=e^{\mathcal{L}}\); with bits, \(\mathrm{PPL}=2^{\mathcal{L}}\).
- Perplexity is the reciprocal of the geometric mean of the per-token probabilities: It is not "the reciprocal of the average probability" or "the reciprocal of accuracy".
2.3 What is a scaling law, and how do the Kaplan and Chinchilla conclusions differ? ★★★¶
One-sentence answer
A scaling law states that a model's loss decreases as a smooth power law in the number of parameters \(N\), the number of training tokens \(D\) and the training compute \(C\), so the curves can be fitted on a series of small models and extrapolated to predict large models. On how to split a fixed compute budget between \(N\) and \(D\), Kaplan et al. (2020) argued that the model should be scaled up preferentially (\(N_{\text{opt}}\propto C^{0.73}\)), whereas Chinchilla (Hoffmann et al. 2022) corrected this to scaling both in equal proportion (\(N_{\text{opt}},D_{\text{opt}}\propto C^{0.5}\)), about 20 tokens per parameter.
I will address three aspects: what a scaling law is, how the two papers' conclusions differ, and why they differ.
(1) Scaling law: the loss falls as a power law in scale, and is therefore predictable.
Kaplan et al. (2020) found that, as long as the other two factors are not the bottleneck, the loss follows a power law in each of \(N\), \(D\) and \(C\), for example \(L(N)\approx (N_c/N)^{\alpha_N}\), where \(N_c\) is a fitted constant and \(\alpha_N\approx 0.076\). On log-log axes this is a straight line, and it holds across many orders of magnitude. The small exponent means diminishing returns: making the model 10 times larger lowers the loss by only about 16%. Its greatest value is predictability: training a large model is extremely expensive, so trial and error is impossible; with a scaling law, one can first fit the curves on small models, then extrapolate the large model's loss, and use this to decide how large the model should be and how many tokens it should see for a given compute budget \(C\). Training compute can be estimated as \(C\approx 6ND\).
(2) Conclusions: the two papers give different answers on "how to split compute between \(N\) and \(D\)".
- Kaplan et al. (2020) argued that the model should grow faster: the optimal parameter count is \(N_{\text{opt}}\propto C^{0.73}\) and the optimal data size is \(D_{\text{opt}}\propto C^{0.27}\), so for every 10 times more compute, the model grows about 5 times while the data grows only about 2 times. The resulting advice was "train very large models and stop before convergence". GPT-3 is a product of this view: 175B parameters trained on only 300B tokens, fewer than 2 tokens per parameter.
- Chinchilla (Hoffmann et al. 2022) argued that parameters and data should grow in equal proportion: the authors fitted the relationship with three different methods and all found \(N_{\text{opt}}\) and \(D_{\text{opt}}\) roughly proportional to \(C^{0.5}\), so doubling the model means doubling the data, which works out to about 20 tokens per parameter. Chinchilla, trained on this basis (70B parameters, 1.4T tokens), used the same compute as Gopher (280B parameters, 300B tokens), yet it outperformed Gopher and GPT-3 on most tasks; and being 4 times smaller, it was also much cheaper at inference. This showed that the large models of the time generally had "too many parameters and too little data".
(3) Reason: the discrepancy comes mainly from experimental setup, not from the power law itself.
Chinchilla argued that an important reason was that Kaplan used a learning-rate schedule of fixed length for all experiments, without matching the length of the cosine decay to each run's actual number of tokens. As a result, runs with fewer tokens were evaluated before their learning rate had come down, their losses were too high, and the value of data was underestimated. Later work gave a more complete explanation: Pearce & Song (2024) attributed the gap mainly to Kaplan counting only non-embedding parameters and running experiments at small scale; Porian et al. (2024) pointed to the compute cost of the last layer, the warmup length and the scale-dependent tuning of optimizer hyperparameters as the main factors, and showed that correcting them reproduces Chinchilla's conclusion. Today, therefore, the field generally treats Chinchilla's conclusion as the reference for "compute-optimal".
In summary: the core value of scaling laws is using small-scale experiments to guide large-scale decisions; the accepted compute-optimal allocation is Chinchilla's "scale parameters and data in equal proportion, about 20 tokens per parameter", but it optimizes only training compute (see 2.4).
Going deeper: Chinchilla's three fitting methods, the parametric formula and a quick estimate
(1) All three methods give an exponent close to 0.5.
| Method | Procedure | \(a\) in \(N_{\text{opt}}\propto C^{a}\) |
|---|---|---|
| Method 1: fixed model sizes | For each model size, train for varying numbers of tokens, and take the lowest-loss point at each compute level | 0.50 |
| Method 2: IsoFLOP profiles | Fix 9 compute budgets, vary model size within each, fit a parabola of loss against \(\log N\) and take its minimum | 0.49 |
| Method 3: parametric fit | Fit the parametric formula below to all experimental results | 0.46 |
| Kaplan et al. (2020) | — | 0.73 |
(2) The parametric formula decomposes the loss into three terms.
where \(E\) is the irreducible entropy of the data, i.e. loss that no model size or data amount can remove; \(A/N^{\alpha}\) is the loss due to limited model capacity; and \(B/D^{\beta}\) is the loss due to limited data. Chinchilla's fitted values are \(E=1.69\), \(A=406.4\), \(B=410.7\), \(\alpha=0.34\) and \(\beta=0.28\). Minimizing \(L\) under the constraint \(C=6ND\) gives \(N_{\text{opt}}\propto C^{\beta/(\alpha+\beta)}\). Notably, the replication by Besiroglu et al. (2024) found that the original fit for Method 3 was flawed and inconsistent with the other two methods (the original fit implies about 70 tokens per parameter at the compute-optimal point); refitting gives \(\alpha\approx 0.35\) and \(\beta\approx 0.37\), corresponding to about 20 tokens per parameter, consistent with Methods 1 and 2.
(3) A quick estimate: \(N_{\text{opt}}\approx\sqrt{C/120}\).
Substituting \(D\approx 20N\) into \(C\approx 6ND\) gives \(C\approx 120N^2\), so \(N_{\text{opt}}\approx\sqrt{C/120}\) and \(D_{\text{opt}}\approx 20N_{\text{opt}}\). Checking on Chinchilla itself: \(C\approx 6\times 70\text{B}\times 1.4\text{T}\approx 5.9\times 10^{23}\) FLOPs, and substituting gives almost exactly 70B parameters and 1.4T tokens.
(4) Comparing the two.
| Kaplan et al. 2020 | Chinchilla (Hoffmann et al. 2022) | |
|---|---|---|
| Optimal parameters | \(N_{\text{opt}}\propto C^{0.73}\) | \(N_{\text{opt}}\propto C^{0.5}\) |
| Optimal tokens | \(D_{\text{opt}}\propto C^{0.27}\) | \(D_{\text{opt}}\propto C^{0.5}\) |
| Tokens per parameter | Few, and decreasing with scale | About 20, roughly constant |
| Advice | Grow the model much faster than the data | Grow model and data in equal proportion |
| Representative model | GPT-3: 175B parameters, 300B tokens | Chinchilla: 70B parameters, 1.4T tokens |
Follow-up questions
Follow-up 1: Where does \(C\approx 6ND\) come from?
The forward pass costs about \(2N\) FLOPs per token and the backward pass about \(4N\), for a total of \(6N\). In the forward pass, each parameter takes part in one multiplication and one addition, i.e. 2 floating-point operations; in the backward pass, gradients must be computed with respect to both the activations and the weights, which costs about twice the forward pass. Multiplying by the number of tokens \(D\) gives \(C\approx 6ND\). This estimate ignores the sequence-length-dependent computation in attention, which introduces little error at typical sequence lengths.
Follow-up 2: Can scaling laws predict downstream task performance?
Not directly, but they can predict it indirectly in two steps. Scaling laws predict the loss, while downstream accuracy is a nonlinear function of the loss, and some abilities appear to emerge suddenly (see 2.6). Llama 3's approach was to first relate training compute to the negative log-likelihood of the correct answers on downstream tasks, and then map that negative log-likelihood to accuracy with a sigmoid curve (Dubey et al. 2024). Gadre et al. (2024) likewise found a power-law relationship between perplexity and the average error across several downstream tasks.
Follow-up 3: Can scaling-law coefficients fitted by others be used directly?
No; the coefficients depend on the data, architecture, tokenizer and hyperparameters. For example, DeepSeek LLM found that the higher the data quality, the more of any additional compute should go to model scale (DeepSeek-AI 2024). Every team therefore needs to refit the law on its own setup using a series of small models.
Common mistakes
- Do not say "Chinchilla overturned scaling laws": It corrected the optimal allocation of compute between parameters and data; the power-law relationship itself still holds.
- Do not say 20 tokens per parameter is the "best" amount of training: It is only optimal for training compute; when inference cost is considered, models should be trained longer (see 2.4).
- Do not equate the predictability of loss with the predictability of abilities: Downstream metrics can jump (see 2.6).
- Note that Kaplan's \(N\) excludes embedding parameters: This is one of the reasons the two conclusions differ.
2.4 Given a compute budget, how should it be split between model size and data? Why are today's small models all "over-trained"? ★★¶
One-sentence answer
If only training compute matters, follow Chinchilla and scale parameters and tokens in equal proportion, about \(D\approx 20N\), i.e. \(N\approx\sqrt{C/120}\). But a model is trained once and used for inference countless times, and inference cost depends only on the parameter count, so what should really be minimized is the total cost of "training + inference"; as long as inference demand is large enough, one should therefore train a smaller model and feed it far more than 20 tokens per parameter, which is what "over-training" means.
I will address three aspects: how to allocate when only training compute matters, why over-training makes sense once inference is considered, and where the limits of over-training lie.
(1) Training compute only: allocate according to Chinchilla's ratio.
Training compute is about \(C\approx 6ND\), and Chinchilla's conclusion is that \(D\approx 20N\) at the compute-optimal point; substituting gives \(N_{\text{opt}}\approx\sqrt{C/120}\). For example, with a budget of \(10^{24}\) FLOPs, the compute-optimal model has about 91B parameters and 1.8T tokens. However, this ratio depends on the data and architecture, so before making the actual decision one usually refits it on one's own data with a series of small models (see 2.3).
(2) Once inference is considered: train smaller models for longer.
Chinchilla only answered "how to get the lowest-loss model for a fixed training budget". However, once trained, a model is called countless times; generating each token costs about \(2N\) FLOPs, and a popular model may process far more tokens over its lifetime than it was trained on. What should really be minimized, therefore, is the total cost of training and inference. Sardana et al. (2023) added inference demand to the scaling law and found that, as long as expected inference demand is large enough (for example, around a billion requests), one should train a model that is smaller than Chinchilla-optimal and trained for longer. This works because, with model size fixed and more data added, the loss keeps falling, albeit ever more slowly, so a small model trained longer can approach the level of a larger one. For example, Llama 3 8B was trained on about 15T tokens, roughly 100 times the Chinchilla-optimal amount, and Meta reported that its performance was still improving log-linearly with data; Qwen3's 0.6B model likewise used about 36T tokens.
(3) Limits: over-training is constrained in two ways.
- Diminishing returns: With \(N\) fixed, the loss approaches a floor set by model capacity, \(E+A/N^{\alpha}\), so each additional token brings less and less improvement, and a small model can never reach a large model's ceiling.
- The data wall: The total amount of high-quality text is finite. When data is limited, repeating the same data for about 4 epochs works about as well as fresh data, after which the benefit drops quickly (Muennighoff et al. 2023); so one has to rely on synthetic data (see Chapter 1) or distill small models from large ones (see Chapter 9).
In summary: "compute-optimal" is optimal only for training cost; when a model will be deployed at scale, the target should be the total cost of training and inference, which is why small models are commonly trained on thousands of tokens per parameter.
Going deeper: over-training in numbers
(1) The total-cost formula shows that the larger the inference demand, the smaller the optimal model.
where \(D_{\text{train}}\) is the number of training tokens and \(D_{\text{inf}}\) is the total number of inference tokens the model processes during deployment. For a given target loss, the larger \(D_{\text{inf}}\) is, the more inference cost is saved by shrinking \(N\), so the optimal \(N\) becomes smaller and \(D_{\text{train}}\) larger. Sardana et al. (2023) trained 47 models to validate this formula and found that model quality keeps improving even in the extreme range of 10,000 tokens per parameter.
(2) Llama 3 8B as an example: the same compute could have trained a compute-optimal model of about 77B.
Llama 3 8B's training compute is about \(6\times 8\text{B}\times 15\text{T}=7.2\times 10^{23}\) FLOPs. By \(N_{\text{opt}}\approx\sqrt{C/120}\), the compute-optimal model for the same compute would have about 77B parameters and 1.55T tokens. Meta chose a model about 10 times smaller, whose inference cost per token is also about 10 times lower; the price is a somewhat higher loss than that 77B compute-optimal model, but a far better one than an 8B model trained on only 160B tokens.
(3) Tokens per parameter for representative models.
| Model | Parameters | Training tokens | Tokens per parameter |
|---|---|---|---|
| GPT-3 | 175B | 300B | About 1.7 |
| Chinchilla | 70B | 1.4T | About 20 |
| Llama 3 405B | 405B | 15.6T | About 39 |
| Llama 2 7B | 7B | 2T | About 290 |
| Llama 3 8B | 8B | 15T | About 1,900 |
| Qwen3-0.6B | 0.6B | About 36T | About 60,000 |
Follow-up questions
Follow-up 1: Why are flagship models, by contrast, close to compute-optimal?
Because for the largest model, the goal is to push the capability ceiling as high as possible within the budget. A flagship model aims for the best possible results and is often used as the teacher for distilling smaller models; shrinking it in the spirit of over-training would sacrifice that ceiling. Llama 3 extrapolated its scaling law and found that the compute-optimal model at \(3.8\times 10^{25}\) FLOPs has about 402B parameters and 16.55T tokens; it ultimately trained a flagship of 405B parameters on 15.6T tokens, while its 8B and 70B models were trained far longer than compute-optimal (Dubey et al. 2024).
Follow-up 2: Is there a limit to over-training?
Yes, but in practice it is still far away. On one hand, the loss has a floor when the parameter count is fixed, so the returns from further training keep shrinking; on the other hand, high-quality data is limited, so later training must rely on repeated or synthetic data. Current empirical results show that quality keeps improving even at tens of thousands of tokens per parameter (Sardana et al. 2023). To improve small models further, the field often combines over-training with distillation; for example, Gemma 2's 2B and 9B models were trained with knowledge distillation instead of next-token prediction (see Chapter 9).
Follow-up 3: Can scaling laws still predict over-trained models?
Yes. Gadre et al. (2024) trained 104 models ranging from 0.011B to 6.9B parameters and found that in the over-trained regime the loss can still be extrapolated reliably with scaling laws: for example, using experiments that required about 300 times less compute, they predicted the validation loss of a 1.4B model trained on 900B tokens (about 32 times over-trained).
Common mistakes
- Do not say "training small models on so many tokens wastes compute": It trades more one-time training cost for cheaper inference every single time afterward.
- Do not say Chinchilla holds that training should stop at 20 tokens per parameter: 20 tokens per parameter is only the optimum when training compute is fixed.
- Inference cost depends only on the parameter count (and sequence length), not on how many tokens the model was trained on: This is exactly why over-training pays off.
2.5 What is a typical pretraining recipe: how are the learning-rate schedule (warmup, cosine, WSD), batch size and sequence length chosen? ★★¶
One-sentence answer
The learning rate is usually warmed up linearly to its peak over a few thousand steps and then decayed with a cosine schedule to about 10% of the peak, or a WSD schedule is used instead, holding it constant for a long time and decaying it quickly over the final 10–20% of steps. The batch size is counted in tokens, typically millions to tens of millions per step, and is increased gradually early in training; the sequence length for the main pretraining phase is usually 4K–8K, with long context left for mid-training. The specific values of the peak learning rate and batch size are usually extrapolated from small-scale experiments.
I will address three aspects: the learning-rate schedule, the batch size and the sequence length.
(1) Learning-rate schedule: warm up first, then decay; the two main decay styles are cosine and WSD.
- Warmup: At the start of training, Adam's second-moment estimate is based on only a few steps of gradients and is very unreliable, and the loss surface near initialization is steep; using the peak learning rate right away can easily jump into a bad region in a single step or even diverge. The learning rate is therefore usually increased linearly from near 0 to its peak over the first few hundred to few thousand steps.
- Cosine decay: After warmup, the learning rate follows a cosine curve from its peak down to about 10% of the peak. Lowering the learning rate late in training reduces the oscillation caused by gradient noise, so the parameters settle steadily into the valley floor and the loss drops noticeably further. Its drawback is that the curve's shape is set by the total number of steps, which must be fixed before training starts: if training stops midway, the learning rate has not yet come down and the model is not well converged; if one wants to continue training afterward, the learning rate has to be raised again.
- WSD (warmup-stable-decay): After warmup, the learning rate stays constant at its peak for most of training, and then decays quickly over the final 10–20% of steps (Hu et al. 2024). Its final performance matches cosine (Hägele et al. 2024), but the stable phase does not depend on the total number of steps, so a decay can be attached to any stable-phase checkpoint to obtain a usable model, and training can simply continue when new data arrives. The decay phase is also a natural point to switch to high-quality data (see Chapter 4).
(2) Batch size: as large as possible up to the critical batch size, and increased gradually as training proceeds.
The larger the batch, the less noisy the gradient estimate, so one can use a larger learning rate, take fewer steps, and make better use of parallel hardware. However, there is a critical batch size (McCandlish et al. 2018): below it, doubling the batch roughly halves the number of steps needed to reach a given loss, wasting almost no compute; above it, doubling the batch reduces the steps only slightly, so the extra compute is largely wasted. The critical batch size grows as the loss falls, because the better the model, the weaker the useful signal in the gradient and the more samples are needed to average out the noise; research has also found that it grows mainly with data size rather than model size (Zhang et al. 2024). Many training runs therefore increase the batch gradually early on. In addition, batch size and learning rate are coupled, so increasing the batch usually calls for a correspondingly higher learning rate.
(3) Sequence length: 4K–8K for the main pretraining phase, with long context extended later.
Attention compute grows quadratically with sequence length, so the longer the sequence, the higher the cost per token; at the same time, the vast majority of training documents are short, and early in training the model mainly learns local grammar and knowledge. The main pretraining phase therefore usually uses 4K–8K sequences, packing several documents into each fixed-length sequence; in mid-training, the context is then extended specifically to 32K or even 128K (see Chapter 4).
In summary: the core idea of a pretraining recipe is to lower the loss as quickly as possible while staying stable, and to leave the expensive or flexibly decided parts (when to decay, long context) for later; the specific values of the peak learning rate and batch size are usually determined by small-scale experiments and scaling-law extrapolation (see 2.8), and optimizers and parallelism strategies are covered in Chapter 3.
Going deeper: published pretraining recipes and a few key numbers
(1) The cosine schedule.
where \(\eta_t\) is the learning rate at step \(t\), \(\eta_{\max}\) and \(\eta_{\min}\) are the peak and final learning rates, \(T_w\) is the number of warmup steps, and \(T\) is the total number of steps.
(2) Three published recipes: the peak learning rate falls as models get larger, and the batch is increased early in training.
| Model | Peak learning rate | Warmup | Decay | Batch size | Sequence length |
|---|---|---|---|---|---|
| Llama 2 70B | \(1.5\times 10^{-4}\) | 2,000 steps | Cosine to 10% of peak | 4M tokens | 4K |
| Llama 3 405B | \(8\times 10^{-5}\) | 8,000 steps | Cosine to \(8\times 10^{-7}\) over 1.2M steps | 4M tokens, raised to 8M after 252M tokens and to 16M after 2.87T tokens | 4K, raised to 8K after 252M tokens |
| DeepSeek-V3 | \(2.2\times 10^{-4}\) | 2,000 steps | Constant until 10T tokens, then cosine to \(2.2\times 10^{-5}\) over 4.3T tokens, and finally two lower constant stages over the last 500B tokens | Raised from 3,072 to 15,360 sequences (about 63M tokens) over the first 469B tokens | 4K |
(3) A few numbers on the decay phase and on sequence length.
- Decay length: Hägele et al. (2024) found that the benefit saturates once the decay phase reaches about 20% of total steps; the longer the run, the smaller the relative share needed.
- Decay shape: The same work found that a \(1-\sqrt{\cdot}\)-shaped decay outperforms linear decay; Bergsma et al. (2025) found that, at a well-tuned peak learning rate, linear decay to 0 outperforms cosine decay to 10% of the peak.
- The cost of sequence length: The ratio of attention compute to parameter compute per token is about \(n_{\text{ctx}}/(12d)\), where \(n_{\text{ctx}}\) is the sequence length and \(d\) is the hidden size. With \(d=4096\), it is about 17% for 8K sequences and about 270% for 128K sequences, which is one reason long context is left for later.
Follow-up questions
Follow-up 1: Why lower the learning rate late in training?
Because gradients are noisy, and with a large learning rate the parameters bounce back and forth near the valley floor. A mini-batch gradient is only a noisy estimate of the full-data gradient. With a large learning rate the model advances quickly, but near the valley floor the noise keeps bouncing the parameters from one side to the other and the loss stops falling; once the learning rate is lowered, the effect of the noise shrinks, the parameters can settle into the valley floor, and the loss drops noticeably further. The WSD loss curve shows this clearly: the loss falls slowly during the stable phase and drops quickly as soon as the decay begins.
Follow-up 2: When the batch size doubles, how should the learning rate change?
For SGD it is usually scaled linearly, for Adam closer to the square root; and beyond the critical batch size, a larger batch brings almost no benefit. The linear scaling rule (Goyal et al. 2017) multiplies the learning rate by \(k\) when the batch is multiplied by \(k\); Adam's update is already normalized, so theory and practice are both closer to square-root scaling (Malladi et al. 2022). In large-model training, the more common practice is to search for the optimal learning rate and batch size directly at several small scales, then fit power laws in compute and extrapolate (see 2.8).
Follow-up 3: If you want to extend training partway through, what do you do with cosine and with WSD?
Cosine requires raising the learning rate again, while WSD can simply continue from a stable-phase checkpoint. Late in a cosine run the learning rate is already very low, so to keep learning from new data it must be re-warmed, which first makes the loss rise and causes some forgetting (Ibrahim et al. 2024). A stable-phase WSD checkpoint is still at the peak learning rate, so training can simply continue, and the decay phase begins once the final budget is decided. This flexibility is the main reason WSD has been widely adopted.
Common mistakes
- Do not say WSD's final performance is clearly better than cosine's: The two end up about the same; WSD's advantage lies mainly in its flexibility.
- Do not say a bigger batch is always better: Beyond the critical batch size, increasing the batch mostly wastes compute.
- Do not discuss an LLM's batch size in terms of samples: LLM batches are usually counted in tokens, millions to tens of millions per step.
- Do not say warmup exists only for Post-LN: Even with Pre-LN, large-model training almost always keeps warmup, because it costs almost nothing and clearly lowers the risk of early divergence.
2.6 Are emergent abilities real? ★¶
One-sentence answer
Partly real and partly an illusion created by the evaluation metric. Wei et al. (2022) observed that certain abilities appear suddenly once a model passes a certain scale; Schaeffer et al. (2023) pointed out that such jumps largely come from discontinuous "all-or-nothing" metrics such as exact match, and that with continuous metrics the improvement is smooth. However, what users care about is often exactly the "all-or-nothing" outcome, and some tasks genuinely stay at chance level until the loss falls below a threshold, so from a user's point of view abilities can still appear abruptly and be hard to predict.
I will address three aspects: what the emergence claim is, what the rebuttal is, and what a fair conclusion looks like.
(1) The claim: some abilities are near chance in small models and appear suddenly beyond a certain scale.
Wei et al. (2022) called this phenomenon emergent abilities; typical examples include multi-digit arithmetic, some few-shot tasks in BIG-Bench, and chain-of-thought prompting (which helps clearly only in large enough models). The finding was influential because it implies that abilities cannot be extrapolated from small-model trends: larger models might bring unforeseeable new abilities, and possibly new risks.
(2) The rebuttal: many "sudden appearances" are caused by discontinuous evaluation metrics.
Schaeffer et al. (2023) pointed out that if the model's per-token accuracy is \(p\), which improves smoothly with scale, but the task counts an answer as correct only when all \(\ell\) tokens are right, the overall accuracy is about \(p^{\ell}\). This is a highly nonlinear function, close to 0 at first and then suddenly taking off, which looks like "emergence" on a plot. They showed that with continuous metrics such as token-level edit distance, the same models show smooth, predictable improvement. In addition, comparing too few model sizes or using too few test examples can also make a curve look like a jump.
(3) A fair conclusion: underlying abilities mostly improve smoothly, but "usable" abilities can still jump.
Du et al. (2024) took a different angle and looked at abilities through pretraining loss rather than model size: with the same data and tokenizer, models with the same loss perform about the same downstream; and on some tasks, even when measured with continuous metrics, performance only rises above chance once the loss falls below a threshold. A fair statement, therefore, is that many jumps really are metric artifacts, and continuous metrics or the loss allow better prediction; but what users actually care about is often exactly an outcome like exact match, and from that angle abilities can still appear abruptly.
In summary: emergence depends to a large extent on how it is measured; predictions should use continuous metrics or the loss, but this does not mean usable abilities cannot appear rapidly around some scale.
Going deeper: a numerical example, and how to predict emergence in advance
(1) Per-token accuracy improves smoothly, yet exact match "suddenly takes off".
Take an answer of length \(\ell=10\) tokens:
| Per-token accuracy \(p\) | 0.5 | 0.7 | 0.8 | 0.9 | 0.95 |
|---|---|---|---|---|---|
| Exact match \(\approx p^{10}\) | 0.1% | 2.8% | 10.7% | 34.9% | 59.9% |
As \(p\) rises steadily from 0.5 to 0.9, exact match jumps from 0.1% to about 35%, with almost no visible progress in the first half.
(2) Fine-tuning can be used to predict emergence in advance.
Snell et al. (2024) found that fine-tuning on the target task shifts the point of emergence toward smaller models; on this basis they fitted an "emergence law" that, using only small models, can in some cases predict whether a model trained with up to 4 times more compute will show the ability.
Follow-up questions
Follow-up 1: How can you predict in advance whether an ability will appear in a larger model?
Extrapolate continuous metrics or the loss rather than accuracy directly. For example, Llama 3 first predicts the negative log-likelihood of the correct answers on downstream tasks and then maps it to accuracy (see 2.3); Snell et al. (2024) first use fine-tuning to make emergence happen earlier and then extrapolate to larger models.
Follow-up 2: What does the emergence debate mean for safety evaluation?
If dangerous abilities can appear suddenly, watching small models' accuracy alone gives no early warning. A safer practice is therefore to track continuous proxy metrics (such as the probability of the correct answer) and to evaluate repeatedly on multiple checkpoints during training, rather than testing only the final model once.
Common mistakes
- Do not simply say "emergence has been debunked": Metrics explain many of the phenomena but not all of them; the loss-threshold phenomenon still exists.
- Do not draw conclusions from scaling curves plotted only with exact match: Report continuous metrics as well, and use enough model sizes and test examples.
2.7 How do you monitor pretraining and catch problems early? ★¶
One-sentence answer
Besides the training loss, monitor the gradient norm, spikes in the loss and the gradient norm, per-domain validation losses, the numerical scale of activations and logits, downstream evaluations of intermediate checkpoints, and throughput and hardware health. Many problems show up first in leading indicators, such as a slowly rising gradient norm or steadily growing attention logits; catching them early makes it possible to roll back or adjust at little cost.
I will address three aspects: whether optimization is healthy, whether abilities are growing as expected, and whether the system is running normally.
(1) Optimization health: the loss, the gradient norm and numerical scale are the signals to watch first.
- Training loss and per-domain validation losses: Normally the loss falls smoothly; watch for sudden loss spikes, long plateaus, and unusual changes in the validation loss of each domain, such as web, code, math and multilingual. For example, a sudden sharp drop in one domain's validation loss may mean that validation data has leaked into the training data.
- Gradient norm: Spikes in the gradient norm often precede loss spikes, and a gradient norm that rises slowly over the course of training is associated with more frequent spikes (OLMo et al. 2024); how often gradient clipping is triggered is also an important signal.
- Numerical scale of activations and logits: Steadily growing attention logits saturate the softmax, and drifting output logits cause numerical instability; both are common precursors of instability in large-model training (Wortsman et al. 2023). The ratio of the update size to the parameter size is also commonly used to judge whether the learning rate is too high.
(2) Abilities: regularly run downstream evaluations on intermediate checkpoints and compare them with the expected curves.
The loss does not directly reflect abilities, so few-shot evaluations need to be run regularly on intermediate checkpoints. Early in training, accuracy on many tasks is near chance and very noisy, so continuous metrics such as the negative log-likelihood of the correct answer or bits-per-byte are more suitable at that stage (Magnusson et al. 2025). Even more important is comparison with expectations: if the loss or downstream metrics deviate clearly from the curves predicted by small-scale experiments and scaling laws, there may be a problem with the data, the hyperparameters or the code.
(3) System: throughput, MFU and hardware failures also need continuous monitoring.
Hardware failures are very frequent in large clusters. For example, during a 54-day period of Llama 3 405B training there were 466 job interruptions, 419 of them unexpected, and about 78% of these were attributed to confirmed or suspected hardware issues (Dubey et al. 2024). It is therefore necessary to monitor throughput and MFU (model FLOPs utilization), locate slow nodes that drag down overall speed, and save checkpoints frequently so that training can resume quickly after a failure.
In summary: the principle of monitoring is to watch leading indicators rather than the loss alone, and to compare against the curves expected from small-scale experiments; how to handle a loss spike once it happens is covered in Chapter 3.
Going deeper: common signals and responses, and what OLMo 2 did
(1) Common signals, possible causes and responses.
| Signal | Possible cause | Common response |
|---|---|---|
| Loss spike that recovers quickly | An unusual batch, or data interacting with the parameter state | Log and watch; if frequent, check the data and the learning rate |
| Slowly rising gradient norm | Parameter or activation scale keeps growing | Check weight decay and logit magnitudes; intervene early |
| Steadily growing attention logits | Softmax heading toward saturation | QK-Norm (normalize q and k before the dot product) |
| Drifting output logits | The softmax normalizer \(\log Z\) drifting away from 0 | z-loss |
| Unusual drop in one domain's validation loss | Validation data leakage or duplicated data | Check the data pipeline and deduplication |
| Falling throughput | Slow nodes, network or storage bottlenecks | Locate and replace nodes |
(2) OLMo 2's monitoring and stability measures.
- Spike score: the percentage of values that are at least 7 standard deviations away from the rolling mean over a window of the previous 1,000 values, applied mainly to the training loss and the gradient norm.
- Repeated n-grams in the data: batches in which spikes occurred often contained very long sequences of repeated n-grams, so documents with 32 or more repeated n-grams were filtered out, and such sequences were masked when computing the loss.
- Numerical stability measures: adding a z-loss (\(10^{-4}\cdot\log^2 Z\), where \(Z\) is the softmax denominator), using QK-Norm, turning off weight decay on embeddings, and lowering AdamW's \(\epsilon\) from \(10^{-5}\) to \(10^{-8}\).
Follow-up questions
Follow-up 1: What do you do when a loss spike occurs during training?
First see whether it recovers by itself; if not, roll back and skip the nearby data. Many spikes recover on their own; if the loss does not recover or keeps diverging, the common practice is to roll back to a checkpoint before the spike, skip some nearby batches, or lower the learning rate and continue. PaLM, for instance, restarted from a checkpoint about 100 steps before the spike and skipped roughly 200 to 500 batches (Chowdhery et al. 2022). A more systematic analysis of the causes and preventive measures is given in Chapter 3.
Follow-up 2: What metrics should be used to evaluate abilities on early checkpoints?
Continuous likelihood-based metrics rather than accuracy. Early models are near chance on many tasks, and the differences between data or configurations are drowned in noise. DataDecide found that, by using continuous metrics such as the likelihood of the correct answer as proxies, one can decide with more than 80% accuracy which data is better at the 1B scale on tasks such as MMLU, ARC and HumanEval, using only about 0.01% of the compute (Magnusson et al. 2025).
Follow-up 3: How can you lower the risk of problems before large-scale training even starts?
Reproduce instabilities in small models with higher learning rates, and stabilize the configuration first. Wortsman et al. (2023) found that two kinds of instability seen in large models, attention logit growth and output logit divergence, can both be reproduced in small models at higher learning rates, and that the mitigations used at large scale work equally well at small scale; they also found that instability can be predicted in advance by watching how activation and gradient norms change with scale.
Common mistakes
- Do not watch only the training loss: Leading indicators such as the gradient norm and logit scale often raise the alarm earlier.
- Do not blame every spike on bad data: PaLM found that re-feeding the data that caused a spike at a different point in training did not cause another spike, which suggests that spikes often come from a particular combination of data and parameter state (Chowdhery et al. 2022).
- Do not compare configurations by accuracy early in training: The noise is too large; use continuous metrics.
2.8 How do you transfer hyperparameters tuned on a small model to a large model (e.g. μP)? ★¶
One-sentence answer
Under the standard parameterization, the optimal learning rate shifts with model width, so hyperparameters tuned on a small model cannot be used directly for a large one. μP (Maximal Update Parametrization) adjusts the initialization, per-layer learning rates and output-layer scaling according to width, so that the change caused by each layer's update does not depend on width, which keeps the optimal hyperparameters roughly constant across widths; the other route is to fit scaling laws for the optimal hyperparameters at several scales and extrapolate to the target scale.
I will address three aspects: why hyperparameters do not transfer directly, how μP works, and its limits and alternatives.
(1) The problem: under the standard parameterization, the optimal hyperparameters drift with model scale.
The standard parameterization (SP) refers to the common practice of initializing weights with variance \(1/\text{fan\_in}\) and using one global learning rate for all layers. In this setting, as the model gets wider, Adam's update to each weight element stays roughly the same size; but each neuron's output is a weighted sum of \(n\) inputs (\(n\) being the width), and these updates are correlated with the input direction, so they add up coherently, and the change in activations caused by one update grows with width. As a result, the wider the model, the smaller the learning rate it can tolerate, and the optimal learning rate drifts with scale. Since it is impossible to search hyperparameters repeatedly on a 70B model, this becomes a real difficulty in large-model training.
(2) μP: make the activation change caused by each layer's update independent of width.
μP was derived by Yang & Hu (2020) from the theory of infinitely wide networks, and its core is to adjust three things according to the width \(n\):
- Scale the learning rate of hidden-layer matrices by \(1/n\): This cancels the coherent accumulation of the update over \(n\) inputs, keeping the change in activations at constant order.
- Shrink the output layer further: Scale the output layer's initialization variance by \(1/n^2\) (or, equivalently, multiply the logits by a factor of \(1/n\)), so the logits do not blow up as width grows.
- Change the attention scaling from \(1/\sqrt{d}\) to \(1/d\): After training, q and k become correlated and their dot product grows linearly with the dimension, so dividing by \(d\) is needed to keep the logits at a stable scale.
As a result, hyperparameters such as the optimal learning rate stay roughly constant across widths, so one can search hyperparameters on a narrow small model and use them directly on a wide large model, a procedure called μTransfer. Yang et al. (2022) transferred hyperparameters from a 40M-parameter proxy model, and the resulting 6.7B model outperformed the published GPT-3 6.7B, with a tuning cost of only about 7% of the total pretraining cost. The meaning of "maximal update" is that, as the width goes to infinity, every layer's features are still updated at constant order, neither blowing up nor degenerating into barely moving.
(3) Limits and alternatives: μP mainly guarantees transfer across width, and in practice it is often combined with hyperparameter scaling laws.
The theory of μP guarantees transfer only along the width dimension. Transfer across depth additionally requires scaling the residual branches by \(1/\sqrt{L}\) (\(L\) being the number of layers; Bordelon et al. 2023), and for Transformers, whose blocks contain more than one layer, theoretical limitations remain (Yang et al. 2023); transfer across batch size and training length is supported only empirically, and research has found that the more training tokens there are, the smaller the optimal learning rate (Bjorck et al. 2024). Regularization hyperparameters such as weight decay and dropout do not transfer. Another common route, therefore, is to fit scaling laws for the hyperparameters directly: search for the optimal learning rate and batch size at several small scales, fit power laws in compute (or in parameters and data), and extrapolate to the target scale. For example, DeepSeek LLM found that the optimal learning rate decreases and the optimal batch size increases as compute grows (DeepSeek-AI 2024), and Qwen3 fitted scaling laws for the optimal hyperparameters of each pretraining stage (Yang et al. 2025). (MiniCPM and Cerebras-GPT used μP; the MetaP mentioned for Llama 4 is also used to set per-layer learning rates and initialization scales, but its details are unpublished.)
In summary: the key to hyperparameter transfer is choosing a parameterization under which the optimal hyperparameters do not drift with scale (μP), and then using hyperparameter scaling laws for the dimensions the parameterization does not cover (batch size, training length).
Going deeper: the concrete differences between SP and μP, and an example of a hyperparameter scaling law
(1) Why the hidden-layer learning rate is scaled by \(1/n\).
Let a hidden layer's output be \(h=Wx\), where the input \(x\) has \(n\) components, each of constant order. Each element of Adam's update \(\Delta W\) has a magnitude of about the learning rate \(\eta\), and the update direction is correlated with \(x\) (the gradient itself contains an outer product with \(x\)). Each component of \(\Delta h=\Delta W\,x\) is therefore a sum of \(n\) terms with the same sign, with magnitude about \(\eta n\), rather than the \(\eta\sqrt{n}\) one would get from adding independent random terms. To keep \(\Delta h\) at constant order, one needs \(\eta\propto 1/n\).
(2) How SP and μP scale with width \(n\) under Adam.
| Parameter type | Init variance (SP) | Init variance (μP) | Learning rate (SP) | Learning rate (μP) |
|---|---|---|---|---|
| Input layer (embedding) and biases | Constant order | Constant order | \(\eta\) | \(\eta\) |
| Hidden-layer matrices | \(1/n\) | \(1/n\) | \(\eta\) | \(\eta/n\) |
| Output layer | \(1/n\) | \(1/n^2\) | \(\eta\) | \(\eta/n\) |
In practice one usually picks a base width \(n_0\) and scales by the ratio \(n_0/n\), so that at the base width μP is identical to SP.
(3) An example of a hyperparameter scaling law.
DeepSeek LLM searched for the optimal hyperparameters at several compute budgets and fitted
where \(C\) is the training compute (FLOPs), \(\eta_{\text{opt}}\) is the optimal learning rate, and \(B_{\text{opt}}\) is the optimal batch size (in tokens). Li et al. (2025) trained more than 3,700 models and found that the optimal learning rate is a power law in both parameter count and data size, while the optimal batch size is determined mainly by data size and is largely independent of model size; this is consistent with the finding that the critical batch size grows mainly with data size (Zhang et al. 2024).
Follow-up questions
Follow-up 1: Which hyperparameters can μP transfer, and which can it not?
Hyperparameters related to optimization and initialization transfer; regularization hyperparameters do not. According to the summary in Yang et al. (2022), the learning rate, Adam's β, the learning-rate schedule, the initialization scale and the per-layer multipliers all transfer, whereas regularization hyperparameters such as dropout and weight decay do not. As for the dimensions of transfer, width has a theoretical guarantee, while depth, batch size, training length and sequence length have been validated only empirically on Transformers.
Follow-up 2: Without μP, how else does the field set the learning rate for large models?
Grid-search at several small scales, then fit power laws and extrapolate. Both DeepSeek LLM and Qwen3 take this approach. In addition, Everett et al. (2024) found that the standard parameterization can also achieve hyperparameter transfer as long as each layer is given an appropriate learning-rate scaling rule, and in their experiments this outperformed μP; they also pointed out that Adam's \(\epsilon\) must be scaled correctly with scale, otherwise it causes gradient underflow.
Follow-up 3: Why does μP divide attention by \(d\) rather than \(\sqrt{d}\)?
Because after training, q and k are no longer independent, and their dot product grows linearly with the dimension. The derivation behind dividing by \(\sqrt{d}\) assumes that the components of q and k are independent, which holds only near initialization (see the Model Architecture direction). Under μP every layer learns features fully, q and k become correlated, and the \(d\) product terms in the dot product tend to add with the same sign, so its magnitude grows linearly with \(d\); dividing by \(d\) is therefore needed to keep the scale of the logits independent of width.
Common mistakes
- Do not say μP makes every hyperparameter transfer along every dimension: In theory it guarantees only the width dimension, and regularization hyperparameters do not transfer.
- Do not say μP changes the model's architecture or expressiveness: It only changes how the initialization and per-layer learning rates scale with width, and at the base width it is identical to the standard parameterization.
- Do not assume that scaling the global learning rate is enough: μP requires different scaling rules for different types of layers.