5.4 Scaling laws
1. Learn
Section titled “1. Learn”- Stanford CS336: Language Modeling from Scratchlecture 9 "Scaling laws" (April 29) and lecture 11 "Scaling laws" (May 6, slides "Scaling details"), and the assignment 3 handout
- Hoffmann et al., Training Compute-Optimal Large Language Models (Chinchilla)sections 1–3 and figure 1
2. Bridge
Section titled “2. Bridge”Power laws. Train language models of many sizes on enough data and the test loss falls as a power law in the number of parameters, a straight line on log-log axes, over many orders of magnitude. The same holds for dataset size and for compute (Kaplan et al. 2020). A line fitted on small, cheap runs therefore predicts large, expensive ones.
Compute-optimal training. A budget of C FLOPs buys about C = 6ND (5.1): a bigger model must see fewer tokens. Hoffmann et al. trained over 400 models and found that parameters and tokens should grow at about the same rate, roughly 20 tokens per parameter. Their 70 B-parameter Chinchilla, trained on 1.4 T tokens, beat the 280 B Gopher that used the same compute (Hoffmann et al. 2022). One of their methods fits and minimises it along the constraint (below). Another trains several model sizes for each fixed budget: an IsoFLOP curve. The vertex of a parabola fitted in log N gives the best size, and the vertices lie on a power law in C.
Fit with care. Power laws are fitted as straight lines in log space, and small differences in the fit become large factors far from the data. A replication found that Chinchilla’s published parametric fit does not match its own data (Besiroglu et al. 2024). Report the range your runs cover.
Beyond compute-optimal. The optimum ignores inference. A model that will serve billions of requests is cheaper to run if it is smaller and trained on many more tokens than Chinchilla suggests. LLaMA trained a 7 B model on 1 T tokens (Touvron et al. 2023; Sardana & Frankle 2023).
3. Explore
Section titled “3. Explore”First, the fitting, in the browser or locally, on the IsoFLOP runs that come with CS336 Assignment 3 (the course gives its own students a training API instead; the method is the same).
stubs/m5_4_scaling.pyLoading starter file…
Prefer your own editor? Edit exercises/stubs/m5_4_scaling.py and run mlc check 5.4. The tests are identical; import the results on the progress page.
Then make your own curves. Open notebooks/5.4-isoflops.ipynb on Kaggle with a GPU and paste in your 4.6 GPT and your 5.4 functions. It trains six widths of your GPT at each of three compute budgets on TinyStories, each run for exactly C / 6N tokens with a learning-rate schedule fitted to its length. It then fits your IsoFLOP curves and power law and extrapolates them. The sweep takes about 15 minutes; without a GPU it runs a tiny smoke version on Shakespeare.
5. Check
Section titled “5. Check”- not yet: All tests pass (0/?)
- not yet: Checkpoint quiz ≥ 80%
Learner log: time spent and points of confusion
Every confusion you note becomes a fix before the module is marked stable. Export it from the progress page and attach it to an issue.