Stanford CS336: Language Modeling from Scratch
Lecture 11 — Scaling in Practice: Case Studies, Optimizers & $\mu$P
From Chinchilla sweeps to late-2026 frontier pretraining Autumn 2026
Why Scaling in Practice Is Hard
Fitting a theoretical power law is easy. Choosing a schedule, batch size, learning rate, optimizer, and parametrization that survive a $100\times$–$1000\times$ extrapolation is not.
Does Chinchilla's scaling recipe actually work on real dense and MoE runs?
Can we cut sweep compute instead of retraining from scratch for every token horizon?
How do we set learning rate and batch size as $N$, $D$, and sparsity scale?
Which optimizers and parametrizations ($\mu$P) transfer cleanly and stay stable at frontier scale?
From Chinchilla (2022) to Late-2026 Scaling Practice
Scaling practice evolved from fitting $(N, D)$ on dense cosine runs to jointly predicting LR, batch, sparsity, architecture, and stability
Note: Kimi K2 is from July 2025 (historical milestone for Muon at 1T); current late-2026 frontier models are DeepSeek-V4, Kimi K3/K3.1, and Qwen3.8-Next
Problem: Cosine Schedules Make Scaling Sweeps $O(n^2)$
Chinchilla (2022) showed that cosine cycle length must match the target token count $T$
You cannot take intermediate checkpoints from one long cosine run as optimal data points
A $2\times$ or $5\times$ longer cycle keeps LR too high at $T_1$, leaving loss systematically worse
Retraining from scratch for each horizon $D_1, \dots, D_k$ turns sweep cost along the data axis from $O(n)$ to $O(n^2)$
How do modern scaling recipes break this horizon coupling?
Solution: Warmup–Stable–Decay (WSD) Schedules
MiniCPM WSD (2024): split training into Warmup, constant Stable, and short Decay (~10% of tokens)
Branch off decay runs from stable checkpoints ($10N \to 60N$)
Measures the entire data axis in linear cost $O(mC)$ instead of $O(n^2)$
DeepSeek LLM multi-step (2024):
2,000 warmup steps, then hold constant
Drop to 31.6% of max LR at 80% of tokens, and to 10% at 90% (grad clip 1.0)
Bonus: WSD also lets production teams keep pretraining past an initial token budget without restarting.
WSD Loss Dynamics: Slow Plateau, Rapid Decay
During the stable phase, WSD stays noticeably above the Cosine loss curve
During the ~10% decay phase, loss plummets and matches (or slightly beats) Cosine at $40N$, $60N$, and $80N$
MiniCPM tested $2N$ vs. $4N/6N/8N$ decay lengths: ~10% decay is needed to close the gap
DeepSeek LLM confirmed multi-step schedules (80/10/10, 70/15/15, 60/20/20) all match cosine final loss
Takeaway: never judge a WSD run mid-plateau—evaluate only after annealing.
Case Study 1: MiniCPM (2024) — Setup & Sweep
Historical dense-model case study (1.2B & 2.4B) combining $\mu$P + WSD + Chinchilla fits.
Name
$N$ (B)
$d_m$
$d_{ff}$
$d_h$
$n_h$
$L$
9M
0.009
320
800
64
5
8
30M
0.036
512
1280
64
8
12
70M
0.066
640
1600
64
10
14
0.1B
0.109
768
1920
64
12
16
0.17B
0.166
896
2240
64
14
18
0.2B
0.241
1024
2560
64
16
20
0.5B
0.499
1344
3360
64
21
24
Fix aspect ratio and head dimension ($d_h = 64$), scale $d_m$ and $L$ together
Gap from largest sweep model (0.5B) to target model (2.4B) is only ~5$\times$
Stabilize LR transfer via $\mu$P, then fit optimal batch size and token-to-parameter ratio empirically
MiniCPM was not SOTA even in 2024, but it published one of the cleanest end-to-end scaling recipes.
MiniCPM: $\mu$P Operations & Stable Optimal LR
Hyperparameters held across widths: scale_emb = 12, scale_depth = 1.4, init_std = 0.1, lr = 0.01
Operation
Exact Rule in MiniCPM
Embedding Output Scaling
Multiply embedding output by $\text{scale\_emb}$
Residual Scaling
Scale each layer's residual increment by $\text{scale\_depth} / \sqrt{L}$
Tensor Initialization
Set 2D tensor init std to $\text{init\_std} / \sqrt{d_m / d_{\text{base}}}$; other parameters to $0.1$
LR Scaling of Tensors
Scale 2D tensor LR by $1 / (d_m / d_{\text{base}})$ relative to base LR
LM Head Scaling
Scale output logits by $1 / (d_m / d_{\text{base}})$
Across 0.04B, 0.1B, 0.3B, 0.5B, and 2.1B, validation loss vs. LR curves share the same minimum around $\eta \approx 10^{-2}$
Minimal LR drift eliminates per-scale learning-rate grid searches
MiniCPM: Optimal Batch Size & High Data-to-Model Ratio
Optimal batch size:
Swept $(B, D)$ across 9M, 30M, 170M; traced minimum-loss ridge at each token budget
Direct empirical scaling laws for $\eta_{\text{opt}}$ and $B_{\text{opt}}$ as functions of $N$, $D$, architecture, and pretraining stage
Qwen 2.5 swept dense (44M–14B) and MoE (44M–1B active) across 0.8B–600B tokens
Used scaling laws to match MoE configs to dense parity (e.g. 14B & 72B dense)
Qwen 3 extended the same hyper-scaling framework across three pretraining stages (36T tokens)
MiniMax-01 (2025) — Architecture Scaling
Used Chinchilla Method 1 (lower envelope) across 70M to 7B models to compare architectures before scaling up:
Softmax Attention
Lightning Attention
Hybrid-Lightning Attention
Derives optimal model size and token count per architecture as a function of compute budget
Shows scaling laws are now standard for architecture selection, not just $(N, D)$ sizing
Current late-2026 frontier models (e.g., MiniMax-M3, Qwen3.8-Flash-Next, DeepSeek-V4) all pair sparse/hybrid attention with sparse MoE chosen via such sweeps.
Two Dominant Scaling Recipes in Practice
Axis
Direct Empirical Fitting (DeepSeek LLM, Qwen 2.5/3, Llama 3, Hunyuan)
Next: zoom in on LR & batch scaling laws—what is the right functional form, and when do fits fail?
Part 2: Competing LR & Batch-Size Scaling Laws
What are the right predictors—model size $N$, tokens $D$, compute $C$, or loss $L$?
Law
Data Recipe
Sparsity
Learning Rate ($\eta_{\text{opt}}$)
Batch Size ($B_{\text{opt}}$)
Rel. Err.
Kaplan / OpenAI (2020)
✗
✗
$3.239\times 10^{-3} - 1.395\times 10^{-4}\log N$
$2\times 10^8\, L^{-4.76}$
9.51‰
Microsoft Law
✗
✗
$1.3192\times 10^{-5}\, N^{-0.23} D^{-0.32}$
—
9.25‰
DeepSeek LLM (2024)
✗
✗
$0.3118\, C^{-0.1250}$
$0.2920\, C^{0.3271}$
9.26‰
Porian Law
✗
✗
$3.7\, N^{-0.36}$
$0.7576\, N^{0.703}$
3.71‰
MiniCPM (2024)
✗
✗
— (fixed via $\mu$P)
$1.21\times 10^9 / L^{6.24}$
—
MeiTuan Law
✗
✓
$\lambda L^{-\alpha}$
$\lambda_B L^{-\alpha_B^{-1}}$
—
Step Law (StepFun)
✓
✓
$\mathbf{1.79\, N^{-0.713} D^{0.307}}$
$\mathbf{0.58\, D^{0.571}}$
0.94‰
Coefficients are taken from the primary papers (Kaplan et al. 2020, DeepSeek LLM 2024, MiniCPM 2024), correcting transcription typos in the Step Law comparison table.
Step Law: Convex Loss Basin & Scaling Trends
Observation 1 — Convexity: pretraining loss slices in $\log \eta$ and $\log B$ are smooth and convex → global optima are cleanly identifiable
Observation 2 — Batch depends on $D$: across $N \in [59\text{M}, 1\text{B}]$, optimal batch collapses onto one line in $D$: $B_{\text{opt}} = 0.58\, D^{0.571}$
Observation 3 — LR vs. $D$ caveat: Step Law finds higher $\eta_{\text{opt}}$ with larger $D$ ($D^{0.307}$) under cosine decay
Fragile under WSD: InternLM scaling study (Zhou et al., 2026) shows the $D$-exponent shifts when swapping cosine for WSD
Step Law: Generalization to MoEs & Data Mixtures
Transfer Across MoE Sparsity
Evaluated on ~2.1B MoE models ($D = 8.0\text{B}$) across active-parameter ratios $N_a / N$:
125B total / 6B active; 512 experts (10 active + 1 shared)
3:1 Gated DeltaNet + QSA; backed by Qwen3.8-Next's Muon + gated residual / GatedNorm stability study
Across all three frontier families, matrix orthogonalization (Muon) + residual/norm gating replaced vanilla AdamW + pre-norm
Contrast with earlier milestones: DeepSeek-V3 (Dec 2024) and Llama 3 (July 2024) used AdamW before MuonClip (July 2025) unlocked trillion-scale Muon
Distributed Muon in Practice
The challenge: AdamW is elementwise (trivially sharded), whereas Newton–Schulz needs whole 2D matrices
Standard solution: assign each parameter matrix to an owner rank that runs Newton–Schulz in parallel across different matrices
Throughput: NVIDIA reports distributed Muon within a few percent of AdamW throughput on GB300 (vendor-reported)
Compressed variants: Dion2/Dion3 and MuonBP orthogonalize only part of each matrix or synchronize less frequently
Part 4: Maximal Update Parametrization ($\mu$P)
Scaling width by factor $r$ ($M \to M'$):
Hyperparameter
$M$
$M' \sim r$
AdamW LR (matrix-like)
$l$
$l / r$
AdamW LR (others)
$l$
$l$
Init variance (matrix-like)
$\sigma$
$\sigma / r$
Init variance (others)
$\sigma$
$\sigma$
Multiplier (output / LM head)
$\tau$
$\tau / r$
Multiplier (others)
$\tau$
$\tau$
"Matrix-like" = 2D tensors whose both dimensions grow with width (embeddings count as "others").
Empirical Motivation: Cerebras-GPT with $\mu$P
Cerebras-GPT trained 0.1B–13B dense models with the Chinchilla recipe
Under standard parametrization, loss oscillated by roughly $\pm 1\%$ around the fitted power law across scales
Tuning a 40M $\mu$P proxy and transferring to 2.7B produced a markedly smoother, more predictable trajectory
Next: derive why $\mu$P works from two simple spectral conditions.
What Is $\mu$P? A Spectral Condition for Feature Learning
Yang, Simon & Bernstein: parameterize a width-$n_l$ network so features and feature updates stay $\Theta(1)$ per coordinate.
A1 (Initialization): Each coordinate of $h_l$ is $\Theta(1) \iff \|h_l\|_2 = \Theta(\sqrt{n_l})$. A2 (One gradient step): Each coordinate of $\Delta h_l$ is $\Theta(1) \iff \|\Delta h_l\|_2 = \Theta(\sqrt{n_l})$.
Deriving $\mu$P: Condition A1 (Initialization)
Consider a deep linear network $h_l = W_l h_{l-1}$ with $W_l \sim \mathcal{N}(0, \sigma^2 I_{n_l \times n_{l-1}})$
By random matrix concentration, the spectral norm concentrates as:
$$\|W_l\|_* \to \sigma\left(\sqrt{n_{l-1}} + \sqrt{n_l}\right)$$
Bounding the forward propagation norm via $\|h_l\|_2 \approx \|W_l\|_* \|h_{l-1}\|_2$ and assuming inductively $\|h_{l-1}\|_2 = \Theta(\sqrt{n_{l-1}})$:
To keep $\|h_l\|_2 = \Theta(\sqrt{n_l})$, we need $\|W_l\|_* = \Theta\!\left(\sqrt{n_l / n_{l-1}}\right)$
Note: this is a worst-case (upper-bound) spectral derivation; $\sigma$ shrinks below $1/\sqrt{n_{l-1}}$ whenever fan-out $n_l <$ fan-in $n_{l-1}$.
Deriving $\mu$P: Condition A2, Part 1 (Weight Update Norm)
For SGD on a linear layer, one gradient step is a rank-1 outer product:
$$\Delta W_l = -\eta_l \left(\nabla_{h_l}\ell\right) h_{l-1}^\top \implies \|\Delta W_l h_{l-1}\|_2 = \|\Delta W_l\|_* \|h_{l-1}\|_2$$
After the step, the activation shifts by:
$$\Delta h_l = W_l \Delta h_{l-1} + \Delta W_l (h_{l-1} + \Delta h_{l-1})$$
Assuming leading terms do not cancel:
$W_l \Delta h_{l-1} = \Theta(\sqrt{n_l})$ by induction and Condition A1
$\|\Delta W_l h_{l-1}\|_2 = \|\Delta W_l\|_* \sqrt{n_{l-1}}$ must also be $\Theta(\sqrt{n_l})$
With Adam, entries of $\Delta W_l$ are $\Theta(\eta_l)$, so $\|\Delta W_l\|_* = \Theta(\eta_l\sqrt{n_l n_{l-1}})$; matching $\Theta(\sqrt{n_l/n_{l-1}})$ forces $\eta_l = \Theta(1/n_{l-1})$.
Adam LR shrinks as $1/n_{l-1}$ for hidden and output matrices instead of staying constant
Initialization shrinks further when fan-out $n_l <$ fan-in $n_{l-1}$ (most importantly at the unembedding / LM head, where $n_{\text{vocab}}$ is fixed while $n_{l-1}$ grows)
$\mu$P Scaling Rules for Transformers
Lingle (A Large-Scale Exploration of $\mu$-Transfer): width $M$, base width $P$, MLP width $F$, $H$ heads of dim $D$, base LR $\alpha$.
Parameter
Role
Init Var ($\Theta$)
Adam LR ($\Theta$)
Init Var (Exact)
Adam LR (Exact)
$W^E$
Embedding
$1$
$1$
$1$
$\alpha$
$W^{AQ}, W^{AK}, W^{AV}$
Attention QKV
$1/M$
$1/M$
$1/M$
$\alpha P/M$
$W^{AO}$
Attention output
$1/(HD)$
$1/(HD)$
$1/M$
$\alpha P/M$
$W^{FI}$
MLP input
$1/M$
$1/M$
$1/M$
$\alpha P/M$
$W^{FO}$
MLP output
$1/F$
$1/F$
$0.25/M$
$\alpha P/M$
$W^U$
LM head (unembed)
$1/M^2$
$1/M$
$1/M^2$
$\alpha P/M$
Attention logit scale: $\mu$P uses $\tau^{-1} = \mathbf{1/D}$ instead of the standard $1/\sqrt{D}$ — even when $D$ is fixed, $\tau^{-1}$ has a major impact on both transfer and quality.
Does $\mu$P Transfer in Practice? (Lingle Replication)
Standard Parametrization (SP): LR drifts & blows up
Width
$2^{-10}$
$2^{-8}$
$2^{-6}$
$2^{-4}$
$2^{-2}$
128
3.841
3.757
3.706
3.879
4.030
512
3.013
2.967
2.987
3.383
7.403
2048
2.738
2.902
7.247
7.477
7.314
Baseline $\mu$P: locked at $2^{-6}$ across 16$\times$ width
Tune baselines across scale & Chinchilla ratio; adopt Muon with QK-Clip / gated residuals / GatedNorm and owner-rank or compressed distributed Muon (Dion2/3, MuonBP)
Hyperparameter transfer
Use $\mu$P (controlling $\|W\|_*$ and $\|\Delta W\|_*$, $\tau^{-1}=1/D$, dropping RMSNorm gains) plus 2026 extensions: $1/\text{width}$ WD for Muon, HyperP, and MLA+Muon MoE $\mu$P