B.11.1 What the System Does After Pass 9
Pass 9 trains at scale and runs the capstone. Mixed precision, gradient accumulation, and activation checkpointing train like fp32 in less memory. Then a Llama of about 10M parameters is trained on TinyStories, with core ablations and the zoo table, evaluated with safety evals, released through the ModelRelease workflow, and served. Everything from earlier passes keeps working: the engine still streams the Pass 1 bigram, and the earlier models still train.
Concepts from other sections (12)
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
- 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
- Eigenvector / eigenvalue: a non-zero and scalar with . Read more: 9.4 Eigenvalues, power iteration, and the spectral radius in Mathematics
- Byte-level: the base alphabet is the 256 bytes (through the byte map), so every text encodes and there is no unknown token. Read more: 7.2 Byte-level BPE
- BF16: a 16-bit float with float32’s sign and exponent and 7 mantissa bits; the top half of a rounded float32. Read more: 6.7 Safetensors for every dtype, atomic checkpoints, and the token stream
- Subprocess activity: one attempt at one activity, run as a child process of a Go worker, whose interface is files, environment variables, signals, and an exit code. Read more: 7.9.4 Failure tests and integration in Systems Engineering
- Bits per byte (bpb): , total information divided by the UTF-8 length; comparable across tokenizers. Read more: 17.2 Perplexity, bits per byte, NLL accumulator in Mathematics
- 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
- Architecture decision record (ADR): a short, numbered, append-only file recording one hard-to-reverse decision with its context, consequences, and rejected alternatives. Read more: 12.1 Architecture decision records in Software Engineering
- Release gate: a check that passes a row only when its interval bound clears the limit, and fails missing rows. Read more: 36.1 Bias and safety evals
- Standard deviation: , the typical distance of a random variable from its mean, in the same units as the variable itself. Read more: Chapter 13: Probability and Statistics in Mathematics
The training techniques are Mixed precision, loss scaling, gradient accumulation, and activation checkpointing. The capstone is Capstone: TinyStories, owned end to end, with ModelRelease, model evals as tests, the datasheet and model card, bias and safety evals, and Hessian-vector products and the recompute-versus-memory schedule. The optional collectives and data parallelism and ZeRO sections, and the optional curvature diagnostics (the Newton step, the top Hessian eigenvalue, and the edge of stability) and Muon optimizer outlined in Optimization in Mathematics, are depth the capstone does not need.
Mixed precision, accumulation, and recompute train like fp32 in less memory
Section titled “Mixed precision, accumulation, and recompute train like fp32 in less memory”The training techniques run through the system’s own entry point on a real model: a byte-level Llama of about 1.6M parameters (a llama-2m config) trains on Tiny Shakespeare twice, with the same windows in the same order. The first run is fp32 with one batch of 32 per step. The second uses 4 micro-batches of 8 (gradient accumulation), emulated bf16 matmuls, and checkpointing of every decoder layer but the last. The second run reaches the first one’s held-out loss within 2% and uses less memory. A 60-step run takes about 40 seconds; the full comparison trains 300 steps.
Why this matters: accumulation decouples the effective batch from what fits in memory, bf16 halves activation memory and doubles matmul throughput on real hardware, and activation checkpointing trades recomputation for memory. Showing that the combination matches fp32 within 2% is what justifies using it for the capstone.
The train llama verb of the tinyllm role is specified under “Verbs of later passes” in cli-roles.md. It keeps the rules of that page: exit 2 on a usage error, and the last stdout line is one JSON object.
{tinyllm} train llama --cfg <config.json> --data <text file> [--steps S] [--seq-len T] [--micro-batch B] [--accum K] [--bf16] [--checkpoint-activations] [--lr LR] [--seed S] [--baseline <run.json>] [--out <run.json>] A Llama from config.json (tl_tokenizer "bytes": ids are the file's bytes); the last tenth of the file is held out. Each step draws K x B windows of T + 1 bytes from the first nine tenths with PCG32 (seed S), in micro-batch order, and makes one optimizer step with train_step_mixed: AdamW, clipping at 1.0, precision bf16 with --bf16, else fp32; --checkpoint-activations runs the decoder layers through checkpoint_sequential. Python's tracemalloc measures the peak of the training loop. Final line: {"loss": the fp32 cross-entropy on 16 seeded held-out windows, "train_loss", "first_loss", "steps", "tokens", "precision", "micro_batch", "accum", "recompute", "peak_mem" (bytes), "params", and with --baseline <run.json>: "loss_rel_diff" = |loss - base loss| / base loss, "peak_mem_ratio" = peak_mem / base peak_mem}; --out writes the same object to a file.Drawing the same windows in the same order for both runs is what makes the comparison fair: the only differences are precision, accumulation, and recompute.
The capstone: trained, evaluated, released, and served
Section titled “The capstone: trained, evaluated, released, and served”The capstone model runs end to end through the system’s own entry points. It trains under the subprocess activity contract of subprocess activities, reaches the held-out bits per byte calibrated for its size, and writes samples that pass its own seeded quality suite. It trains again as a durable TrainRun whose trace reaches train.step, ships through the ModelRelease workflow with its gates and canary, and is served by the gateway. The artifacts (specs, report, zoo table, samples, model card, ledger, and ADRs) are under docs/capstone and docs/MODEL_CARD.md. The model-card section covers the model card and datasheet, and the safety-evals section covers the safety rows the release gates on.
The verbs are specified in cli-roles.md:
{tinyllm} train --spec <file> --progress <file> The subprocess activity verb (spec/subprocess-activity.md): the run goes under TL_ARTIFACTS/runs/<TL_IDEMPOTENCY_KEY or spec name>/, its checkpoints in ckpt/ with LATEST (formats/checkpoint.md). Final line: {"steps", "final_loss", "ckpt"}.
{tinyllm} eval ppl --model <ckpt dir or model dir> --data <tokens.bin> Pass 5's verb; a run's ckpt/ directory means its LATEST step. The final line holds "bpb" (and "ppl", "tokens").
{tinyllm} eval --suite quality --model <dir> --seed S --samples N N seeded samples (seeds S to S + N - 1) from "Once upon a time", scored with the model-evals-as-tests suite. Final line: {"samples": N, "repeat8": mean repeated word 8-gram rate, "distinct1": mean distinct word fraction}.
{ctl} release --spec <release.json> --id <workflow id> [--approve] [--wait] [--json] Starts ModelRelease on a release spec; --approve sends the approve signal right after the start (unattended runs); with --wait the final line is {"workflow_id", "status", "outcome", "served"}.
{ctl} train --spec ... --id ... --wait --json as in Pass 8.The training specs are in specs/c1: tinystories-10m.json (the capstone), tinystories-short.json (a shorter run of the same model), smoke.json (about 1M parameters, for a quick end-to-end check), and release.json (the release spec). The held-out bar for each size is the mean plus three standard deviations of five seeded runs. The release uses the durable services of Pass 8 (durable and worker) for the TrainRun, and the kind deploy of Pass 7 for release, serving, and traces.
Why this matters: this is the first model the course trains that is worth serving. Training it as a durable workflow makes the long run restartable, the quality suite and safety evals are what a release must pass, and ModelRelease with a canary is how a new model reaches users without blindly replacing a working one. Pass 10 puts an agent on top of it.