Skip to content

7.2 Experiments and ablations

ready≈ 12 hoursNeeds: 7.1, 4.6Unlocks: 7.4
  1. 1 Learn
  2. 2 Bridge & derive
  3. 3 Explore (Ablation planner)
  4. 4 Do
  5. 5 Check

What an ablation is for. An ablation removes or changes one part of a system and measures the change in a metric, to find out what that part contributes. Most architecture papers have one, such as table 3 of Attention Is All You Need, which varies heads, key size, depth, width, dropout and positional encoding one at a time. Two decisions make or break it: which runs to do, and whether each difference beats the noise.

Noise first. Runs of one config with different seeds (initial weights, data order, dropout) differ. Measure that spread, σ, first, by running the baseline with a few seeds. A difference between two configs averaged over n seeds each has standard error σ√(2/n), so an effect δ needs n ≥ 2 (zσ/δ)² seeds per config to stand z standard errors clear. That makes the true effect z standard errors, so one study clears the bar only about half the time; for an 80% chance, use z + 0.84 in place of z. Bouthillier et al. 2021 measure each source’s variance in five benchmarks, find it comparable to published improvements (including the train/test split, which seeds alone don’t vary), and argue for randomising all of them.

One at a time or factorial. Changing one factor at a time from a baseline costs one config per alternative value, but each effect is measured only at the baseline, and interactions (one factor’s effect depending on another) are invisible. A full factorial runs every combination: it grows multiplicatively, but each main effect uses every run, averaged over the other factors, and every interaction is measured. With k two-level factors, 2^k configs; fractional factorials cut that down when the interactions a fraction confounds can be assumed negligible, for a resolution V fraction those of three or more factors (NIST handbook §5.3.3.4, §5.3.3.4.4).

Testing a difference. With few seeds, make no distributional assumptions you cannot check. An exact permutation test asks how often a random relabelling of the runs gives a difference at least as large as the observed one; it is valid for any distribution, but with n runs a side it can never give p below 2 / C(2n, n), which is 0.1 for 3 seeds (Dror et al. 2018 survey which tests suit which metrics). Report the mean difference with its standard error, the number of seeds, and whether the effect clears the noise; don’t report a single run.

How many seeds an effect needs, and the permutation floorstep 1 of 5
  1. aˉ−bˉ,aˉ=1n∑iai,  ai=μa+σεi\bar a - \bar b, \quad \bar a = \tfrac1n \textstyle\sum_i a_i,\; a_i = \mu_a + \sigma \varepsilon_i

Ablation planner

Experiment design

Static view on small screens. Open this page on a laptop to interact.

1. Design

factors
#learning ratelayerswarm-up steps
10.0032100
20.0012100
30.012100
40.0031100
50.0034100
60.00320
6 configs × 3 seeds = 18 runs, 3.0 GPU-hours. One at a time changes a single factor from the baseline (highlighted), so it cannot see interactions.

2. Is the difference real?

baselineablation
Observed difference -0.0000, standard error σ√(2/n) = 0.0122: 0.0 standard errors, inside the noise. With 3 seeds, a true effect of 0.020 clears 2 standard errors 36% of the time. To make it 2 standard errors on average you need 5 seeds per side.

Measure σ first: run the baseline with a few seeds before planning the rest. Then pick the effect size you care about and the seeds that make it visible; an ablation that changes loss by less than the seed noise, run with one seed, decides nothing.

Two panels. The first plans a study: checkboxes choose factors of a small GPT (learning rate, layers, warm-up, tied embeddings, norm), buttons choose a one-at-a-time or full factorial design, and sliders set the seeds and minutes per run; a table lists the configurations, with the baseline highlighted and changed values marked, and the readout gives the number of runs and GPU-hours. The second simulates seed noise: sliders set the true effect, the noise and the number of seeds, and a dot plot shows simulated losses for the baseline and the ablation with their means; the readout gives the observed difference in standard errors, the chance of clearing 2 standard errors, and the seeds needed. Keyboard: Tab to the checkboxes, buttons and sliders.
Experiments and ablations stubs/m7_2_ablations.py

Loading starter file…

Prefer your own editor? Edit exercises/stubs/m7_2_ablations.py and run mlc check 7.2. The tests are identical; import the results on the progress page.

Hints · permutation_test 0/3 revealed
Hints · main_effects 0/3 revealed

Then run the lab. Open notebooks/7.2-ablation-study.ipynb (about 3 minutes on a CPU) and paste in your 4.6 and 7.2 files. It measures your GPT’s seed noise, runs a 2 × 2 × 2 factorial over learning rate, depth and tied embeddings with three seeds each, estimates main effects and interactions with their standard errors, and tests each one-at-a-time comparison. Then design and run an ablation of your own and write it up.

1. Why measure the baseline's seed noise before running the ablations?
2. Seed noise is σ = 0.02 and you care about effects of 0.01. About how many seeds per config put such an effect 2 standard errors clear, on average?
3. What can a full factorial measure that one-at-a-time changes cannot?
4. With three seeds per side, an exact permutation test gives p = 0.1. What does that tell you?
  • not yet: All tests pass (0/?)
  • not yet: Checkpoint quiz ≥ 80%
Finish the items above first.
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.