Dive into Deep Learning · §11.7
Scaling laws and the modern recipe
count parameters and FLOPs · a scaling study, bend included · seven model families, one argument list
Boundary: §9’s Scaling Up transfers hyperparameters across size (muP); this section asks what size itself buys
Blocks scale as 12Ld^2 (4d^2 attention + 8d^2 FFN); embeddings as Vd — the embedding dominates when V \gtrsim 12Ld:
embedding 0.01M ( 0%), blocks 4.72M = 12.01 L d^2, total 4.73M
embedding 39.38M ( 32%), blocks 85.06M = 12.02 L d^2, total 124.44M
C \approx \underbrace{2ND}_{\textrm{forward}} + \underbrace{4ND}_{\textrm{backward}} = 6ND
Decode-time arithmetic (why a generated token costs 2N) was §11.3’s — the KV cache turns it into a memory bill.
2ND analytic: 7.743e+10 FLOPs, XLA forward: 8.480e+10 (ratio 1.10)
6ND analytic: 2.323e+11 FLOPs, XLA step: 2.547e+11 (ratio 1.10)
backward / forward = 2.00
Design: hold the diet fixed, move only the model.
d= 96, 3 blocks: 0.33M parameters, train 1.21, validation 1.21
d=128, 3 blocks: 0.59M parameters, train 1.17, validation 1.17
d=192, 4 blocks: 1.77M parameters, train 1.11, validation 1.12
d=256, 6 blocks: 4.72M parameters, train 1.06, validation 1.08
d=384, 8 blocks: 14.16M parameters, train 1.04, validation 1.07
No fitted exponents: five points and one seed would dress noise in decimals. The shape — line, then bend — is the finding.
L(N, D) = E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}} \qquad \textrm{(Hoffmann et al., 2022)}
| model | attention + cache | norm | FFN / experts |
|---|---|---|---|
| Mistral 7B | GQA 32:8, window 4096 | RMS pre | SwiGLU, dense |
| Llama 3 | GQA 32:8 | RMS pre | SwiGLU, dense |
| Qwen3 | GQA 64:8 dense, 64:4 MoE | RMS pre + QK | SwiGLU, dense & MoE 128/8 |
| DeepSeek-V3 | MLA: 512-d latent | RMS pre | SwiGLU, MoE 256+1/8 |
| Gemma 3 | GQA, local:global 5:1 | RMS pre+post + QK | GeGLU, dense |
| GPT-OSS | GQA 64:8, window 128 alt., sinks | RMS pre | SwiGLU, MoE 128/4 |
All: RoPE positions, no dropout — at trillion-token scale the corpus outweighs the parameters.
GPT-2 (2019) 5.26M pos='learned', norm='layer', act='gelu', pre_norm=True, bias=True, kv_heads=8
Mistral-7B 4.40M pos='rope', norm='rms', act='swiglu', pre_norm=True, bias=False, kv_heads=2
Llama-3 4.40M pos='rope', norm='rms', act='swiglu', pre_norm=True, bias=False, kv_heads=2
Qwen3 4.40M pos='rope', norm='rms', act='swiglu', pre_norm=True, bias=False, kv_heads=2
ffn_factory (§11.6).GPT class with different flags.