Lab 01 — IsoFLOPs Ladder, Law Fitting & the Forecast
Build the machine that turns a few cheap experiments into a defensible prediction about an experiment you can only run once.
The problem
You have a flagship budget of 1e25 FLOPs and one shot. Before spending it you must state
what you will train and what loss you expect, and defend both. The only tool is a ladder of
small runs and a fitted curve — so the whole job reduces to: fit well, extrapolate honestly,
and know how wrong you might be.
This lab builds that machine end to end, and along the way reproduces the Kaplan → Chinchilla correction from scratch — because the lesson there is not a fact to memorize, it is a failure mode to recognize in your own work.
What you build
| Group | Functions | The idea |
|---|---|---|
| Numerical spine | fit_line, fit_power_law, fit_quadratic, parabola_vertex | A power law is a straight line in log-log; the IsoFLOPs minimum is a parabola vertex |
| Loss model & ladder | parametric_loss, loss_decomposition, schedule_bias, synthetic_ladder | L = E + A/N^α + B/D^β, plus an injectable measurement bias |
| IsoFLOPs | isoflop_optimum, isoflops_ladder, fit_scaling_exponents | The six-step method, ending in the a + b ≈ 1 check |
| Surface fit | residuals, squared_loss, huber_loss, fit_parametric | Log-space, robust, deterministic multi-start |
| Optimum | analytic_optimum, optimum_exponent | The closed form, and why Chinchilla's exponent is ~0.5 |
| Uncertainty | bootstrap_forecast, compute_multiplier_for_loss_delta | Error bars, and how to read them in dollars |
| Design | extrapolation_variance, design_ladder, extrapolation_risk | Where to spend your next ablation |
| Decision | loss_at_budget, compare_recipes, decision_is_supported | Compare laws at the target; report the crossover |
Key concepts
| Concept | Why it is in this lab |
|---|---|
L = E + A/N^α + B/D^β | Irreducible + capacity + data. At frontier scale ~87% is irreducible. |
| The IsoFLOPs U | At fixed C, too-small underfits and too-large starves. Flat bottom. |
a + b ≈ 1 | Falls out of C = 6ND. A free bug detector on any fitted pair. |
| Non-uniform bias | A constant offset is absorbed into E; only a varying one tilts exponents. |
| Huber on log residuals | One diverged run costs least-squares ~4,000× what it costs Huber. |
| Bootstrap CI | The model is nonlinear and the noise model unspecified — so resample. |
| 0.01 nats ≈ 33% compute | The conversion that makes a confidence interval interpretable. |
| Extrapolation variance | Spread beats density: 26× lower variance from placement alone. |
| The crossover | "Candidate wins above 3e24" is actionable; "candidate is better" is not. |
Files
| File | What it is |
|---|---|
| lab.py | Your implementation. Signatures, docstrings and validation contracts given. |
| solution.py | Reference. python solution.py runs the full eleven-part story. |
| test_lab.py | 64 tests: happy path, validation, boundaries, invariants, determinism. |
| requirements.txt | pytest only. Pure stdlib otherwise. |
Run
pytest test_lab.py -v # your lab.py — red until you implement
LAB_MODULE=solution pytest test_lab.py -v # the reference — must be green (64 passed)
python solution.py # the worked example
Where to start
Work top to bottom; each group depends on the one above.
- The spine.
fit_line→fit_power_law→fit_quadratic→parabola_vertex. Gettest_fit_power_law_recovers_exponentandtest_fit_quadratic_recovers_exact_parabolapassing before anything else. parametric_lossandsynthetic_ladder. Note the budget constraint: every point on an IsoFLOPs curve satisfiesC = 6ND, and a test checks it.- The IsoFLOPs method, ending at
test_exponents_sum_to_one. fit_parametric. Deterministic multi-start coordinate descent.test_fit_parametric_is_deterministicis not optional garnish — a fit that moves between runs cannot support a nine-figure decision.- The rest.
The money test is test_nonuniform_bias_tilts_the_fitted_exponent, paired with its control
test_uniform_offset_is_absorbed_into_E_and_changes_nothing. Together they are the
Kaplan → Chinchilla lesson: a uniform measurement error changes nothing, a non-uniform one
changes your flagship recommendation.
The traps:
fit_quadraticon collinearxvalues → must raiseValueError, notZeroDivisionError.- A downward-opening parabola has a maximum → must raise, because it means your sweep is wrong.
- Bootstrap resamples can be degenerate → skip them, and fail loudly if too few succeed.
- Do not recompute
C = 6NDto regroup a ladder. Floating-point rounding will split one budget into two groups. Carry the budget label. (A test comment calls this out.) - Everything random goes through a seeded
random.Random(seed).
Success criteria
-
LAB_MODULE=solution pytest test_lab.py -v→ 64 passed. -
Your
lab.pyreaches 64 passed. -
python solution.pyruns, and you can explain all eleven sections. - You can explain why a uniform loss offset changes nothing and a non-uniform one changes everything.
-
You can state why
a + b ≈ 1must hold and what it catches. - You can produce a forecast with a CI and say whether it is tight enough to decide on.
- You can justify a ladder design in terms of extrapolation variance and dollars.
How this maps to the real stack
| This lab | The real thing | Where the miniature lies |
|---|---|---|
synthetic_ladder | Actual training runs on a cluster, days each | Real losses have autocorrelated noise, run-to-run seed variance, and occasional divergence. Ours is i.i.d. Gaussian. Real ladders also vary the recipe imperfectly across scales. |
fit_parametric | scipy.optimize.minimize with L-BFGS-B, or JAX + optax | Real fits use gradients and converge faster. Ours is hand-rolled so it is deterministic and inspectable — and so a library upgrade cannot silently move your recommendation. |
isoflop_optimum | The same parabola fit, on real measured losses | Identical in spirit. Real practice uses more sizes per budget (6–10) and often fits in log-loss space. |
bootstrap_forecast | Bootstrap or Bayesian posterior over law parameters | Real work often uses a hierarchical model that shares information across budgets. Ours treats points as exchangeable, which understates correlation within a budget. |
compare_recipes | An internal go/no-go memo and a review meeting | The arithmetic is the easy part. The real version also carries downstream eval deltas, serving-cost deltas, and stability risk — see the six-point checklist in WARMUP Chapter 12. |
CHINCHILLA constants | Hoffmann et al. Table 3 | These published values have been contested; see Besiroglu et al. Use them as a plausible ground truth for the simulator, not as gospel. |
What is not a lie: the IsoFLOPs procedure, the a + b = 1 identity, the analytic optimum
derivation, and the extrapolation-variance formula. Those are exact, and they are what you will
be asked about.
Extensions
- Fit against published data. Pull the
(N, D, loss)table from any open model report (Llama 3's scaling section is unusually complete) and fit your law to it. Compare your extrapolation to what they actually shipped. - Add a hierarchical noise model. Points within one budget share a run's seed and infrastructure; model that correlation and see how the confidence interval widens. This is Feinberg's "formal stats model" suggestion, at a tractable scale.
- Implement true optimal design. Instead of scoring fixed candidate designs, search for
the next
Cthat minimizes posterior predictive variance at the flagship. That is the "active learn" bullet on his slide, and it is a publishable exercise. - Add a third axis. Extend to
L(N, D, U)with unique tokens, then compare against Phase 02's data-constrained law. - Compare estimators properly. Run a simulation study: generate 1,000 ladders from known truth, fit with each estimator, and report bias and variance of the recovered exponents. That is a real, small, honest paper.
Interview / resume bullets
- "Implemented the full IsoFLOPs scaling-law methodology from scratch — parabola fitting for
per-budget optima, power-law regression for
N_opt(C)andD_opt(C)with ana + b = 1consistency check, and robust (Huber-on-log) fitting of the parametricL(N, D)surface — producing flagship forecasts with bootstrap confidence intervals." - "Reproduced the Kaplan→Chinchilla correction from first principles by simulating a schedule-mismatch measurement bias, demonstrating that a uniform loss offset is absorbed into the irreducible term while a non-uniform one tilts the fitted exponents and shifts the compute-optimal recommendation."
- "Built optimal-experimental-design tooling for scaling ladders, showing ~26× lower extrapolation variance from point placement at identical cost, and sized a ladder at under 2% of flagship budget for 5.2 decades of coverage."
- Interview-ready: "I would not train both and compare. I would fit a law for each recipe over a shared ladder, evaluate both at the target FLOP count, and report the delta with confidence intervals plus the crossover — because curves cross, and 'better' silently assumes a scale."