B.11 Pass 9: Capstone Training
Every model so far has been small enough to train in minutes. The capstone is a Llama-family model of about ten million parameters trained on TinyStories, the first model in the course worth serving. Training it on a laptop takes the techniques that make training cheaper without changing what it learns: mixed precision, gradient accumulation, and activation checkpointing, which together match fp32 within 2% in less memory.
Concepts from other sections (11)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- gradient accumulation: summing the gradients of micro-batches weighted by to reproduce one large batch’s gradient. Read more: 17.1 Mixed precision, loss scaling, gradient accumulation, and activation checkpointing
- activation checkpointing: discarding a segment’s activations in the forward pass and recomputing them during backward. Read more: 17.1 Mixed precision, loss scaling, gradient accumulation, and activation checkpointing
- Model card: the model’s interface documentation: details, intended and out-of-scope use, evaluation with uncertainty, limitations, and data. Read more: 35.1 Datasheet and model card
- Hessian-vector product: , the derivative of the gradient along , computed without forming . Read more: 14.4 Hessian-vector products and the recompute-versus-memory schedule in Mathematics
- Hessian: the symmetric matrix of second partial derivatives, whose eigenvalues classify a critical point. Read more: 10.3 Calculus 3 problem set: vectors, gradients, the chain rule, Hessians, multiple integrals, Lagrange in Mathematics
- Burn rate: the error rate divided by the SLO’s error budget; a value of 14.4 spends a 30-day budget in about two days. Read more: A.1 Capstone: TinyStories, owned end to end
- Model eval: a held-out metric plus a regression rule, run on every change as a test. Read more: 3.8 Model evals as tests in Software Engineering
- Confidence interval: a procedure that, over repeated samples, produces intervals covering the fixed true parameter at the stated rate. Read more: 13.11 Probability problem set, part c: limit theorems and confidence intervals in Mathematics
- all-reduce: every rank ends with the elementwise reduction (sum or mean) of all ranks’ arrays. Read more: 17.2 Collectives over processes: ring all-reduce
- data parallelism (DDP): each rank holds a full model replica, computes the gradient of its batch slice, and all ranks average gradients before stepping. Read more: 17.3 Data parallelism and ZeRO stages 1 to 3
- ZeRO: sharding training state across ranks so that each piece is stored once instead of times. Read more: 17.3 Data parallelism and ZeRO stages 1 to 3
The capstone is then owned end to end: trained as a durable TrainRun, evaluated with seeded quality and safety evals, documented with a datasheet and a model card, and shipped through the ModelRelease workflow with gates and a canary before the gateway serves it.
Learning objectives
- Explain how Hessian-vector products and the recompute-versus-memory schedule underlie activation checkpointing.
- Explain why mixed precision, accumulation, and recompute together train like fp32.
- Explain what a datasheet, a model card, and bias and safety evals must contain.
- Explain how ModelRelease gates and canaries a new model before it replaces a working one.
Before you begin
Section titled “Before you begin”This pass needs Pass 8, whose TrainRun workflow trains the capstone and whose durable services ModelRelease runs on.
In this pass
Section titled “In this pass”- Hessian-vector products and the recompute-versus-memory schedule. Afterwards you can explain how a Hessian-vector product is computed without the Hessian and how the recompute-versus-memory schedule is chosen.
- Mixed precision, loss scaling, gradient accumulation, and activation checkpointing. Afterwards you can explain how mixed precision with loss scaling, gradient accumulation, and activation checkpointing train like fp32 in less memory.
- Datasheet and model card. Afterwards you can explain what the datasheet and model card report and why each section is there.
- Bias and safety evals. Afterwards you can explain what the bias and safety evals measure and how their results are reported.
- ModelRelease: gates, canary, burn check, and rollback. Afterwards you can explain how ModelRelease gates a model, runs a canary, checks the PromQL burn rate, and rolls back.
- Model evals as tests. Afterwards you can explain how model evals are written as tests with thresholds and confidence intervals.
- Capstone: TinyStories, owned end to end. Afterwards you can explain how the TinyStories model is trained, evaluated, released, and served end to end.
- What the System Does After Pass 9. Afterwards you can explain how the TinyStories model is trained with mixed precision, evaluated, released through ModelRelease, and served.
Going deeper
Section titled “Going deeper”Two optional sections explain what changes when training moves from one machine to many. The capstone does not need them:
- Collectives over processes: ring all-reduce. Afterwards you can explain how ring all-reduce over processes sums gradients with bandwidth-optimal traffic.
- Data parallelism and ZeRO stages 1 to 3. Afterwards you can explain how DDP and ZeRO stages 1 to 3 partition optimizer state, gradients, and parameters.
The stages are also in this pass’s manifest, path.tsv. Pass 10 puts an agent on top of the served system.
Stages
Section titled “Stages”Generated from path.tsv.
| Stage | Read | Done when |
|---|---|---|
| 1 | Hessian-vector products and the recompute-versus-memory schedule 14.4 Hessian-vector products and the recompute-versus-memory schedule | You can explain how a Hessian-vector product is computed without the Hessian and how the recompute-versus-memory schedule is chosen (M08.4). |
| 2 | Mixed precision, loss scaling, gradient accumulation, and activation checkpointing 17.1 Mixed precision, loss scaling, gradient accumulation, and activation checkpointing | You can explain how mixed precision with loss scaling, gradient accumulation, and activation checkpointing train like fp32 in less memory (L11.1). |
| 3 | Datasheet and model card 35.1 Datasheet and model card | You can explain what the datasheet and model card report and why each section is there (ethics.03). |
| 4 | Bias and safety evals 36.1 Bias and safety evals | You can explain what the bias and safety evals measure and how their results are reported (ethics.04). |
| 5 | ModelRelease: gates, canary, PromQL burn check, rollback 7.12 ModelRelease: gates, canary, burn check, and rollback | You can explain how ModelRelease gates a model, runs a canary, checks the PromQL burn rate, and rolls back (dur.12). |
| 6 | Model evals as tests (R8) 3.8 Model evals as tests | You can explain how model evals are written as tests with thresholds and confidence intervals (craft.22). |
| 7 | Capstone: TinyStories, owned end to end A.1 Capstone: TinyStories, owned end to end | You can explain how the TinyStories model is trained, evaluated, released, and served end to end (C1). |
| 8 | What the system does after Pass 9 B.11.1 What the System Does After Pass 9 | You can explain how the TinyStories model is trained with mixed precision, evaluated, released through ModelRelease, and served. |
| 9 | Collectives over processes: ring all-reduce 17.2 Collectives over processes: ring all-reduce | You can explain how ring all-reduce over processes sums gradients with bandwidth-optimal traffic (L11.2). |
| 10 | Data parallelism and ZeRO stages 1 to 3 17.3 Data parallelism and ZeRO stages 1 to 3 | You can explain how DDP and ZeRO stages 1 to 3 partition optimizer state, gradients, and parameters (L11.3). |