A.1 Capstone: TinyStories, owned end to end
Every part of the system has passed its own tests by now. None of them has had to work with all the others for hours, on data you did not choose, with numbers nobody gave you in advance. That is where the remaining bugs live: a tokenizer whose vocabulary disagrees with the model config, a checkpoint whose data cursor resumes one window late, an eval that reads the wrong split, a release spec the gateway cannot route. This capstone runs the whole system on one goal, a model that writes small stories, and defends each choice with a measurement. There is no oracle for the result. The report is the evidence, and a correct capstone is one whose evidence agrees with itself and with the runs that produced it.
Concepts from other sections (28)
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.
- Bitwise resume: resuming from a checkpoint that holds weights, optimizer moments, RNG state, and data cursor, so the final loss equals the uninterrupted run’s exactly. Read more: 7.11 Platform workflows: TrainRun and EvalSuite in Systems Engineering
- 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
- 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
- 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
- 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
- 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
- Negative log-likelihood (NLL): , the surprise of the true token under the model, in nats. Read more: 17.2 Perplexity, bits per byte, NLL accumulator in Mathematics
- Perplexity: , the geometric mean of ; the effective number of choices per token. Read more: 17.2 Perplexity, bits per byte, NLL accumulator in Mathematics
- Decoupled weight decay (AdamW): multiplying the weights by outside the gradient path. Read more: 16.3 Adam and AdamW: bias correction and decoupled weight decay in Mathematics
- Warmup-stable-decay (WSD): warmup, a long constant phase at the peak, and a short final decay. Read more: 16.4 Learning-rate schedules (cosine, WSD, Noam) and gradient clipping in Mathematics
- Grouped-query attention (GQA): query heads share key/value heads, each serving a contiguous group of query heads. Read more: 13.5 Grouped-Query Attention with a Cache Hook, Windows, and Sinks
- Multi-head latent attention (MLA): attention whose keys and values are rebuilt per head from a cached low-rank latent of each token. Read more: 13.6 Multi-Head Latent Attention and Weight Absorption
- SwiGLU: the gated MLP with silu on the gate (Llama, SmolLM2). Read more: 13.2 Gated MLPs: SwiGLU and GeGLU
- Mixture of experts (MoE): a layer of many expert MLPs of which a router picks per token. Read more: 13.8 Mixture of Experts
- Tied embeddings: one Tensor shared by generator and discriminator, trained by both losses. Read more: 12.3 ELECTRA: replaced-token detection
- RMSNorm: divides a vector by its root mean square plus eps (inside the root) and multiplies by a learned gain; no mean subtraction, no bias. Read more: 13.1 Pre-LN and RMSNorm
- KV cache: per-layer storage of past keys and values, so each decode step processes only the new token. Read more: 21.2 The KV cache, incremental decoding, and generate
- Bytes per token: total UTF-8 bytes over total tokens; the compression ratio. Read more: 7.6 Tokenizer metrics
- Active parameters: parameters participating in the computation for a particular token. Read more: 20.9 Architecture choices and performance limits
- Variance: the expected squared distance from the mean; its square root is the standard deviation. Read more: 13.1 Random variables, expectation, variance, and normal draws by Box-Muller in Mathematics
- percentile bootstrap: an interval read off the sorted means of resamples at exact indices. Read more: 29.1 Eval runner
- 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
- Weight absorption: folding into the query and into the output so decoding never builds per-head keys or values. Read more: 13.6 Multi-Head Latent Attention and Weight Absorption
- Error budget: the per-output bound a quantized layer must stay within. Read more: 21.5 Quantization: int8, int4 groups, fp8, and the KV cache
- Service Level Objective (SLO): a target for a defined measure of service behavior over a specified window. Read more: Chapter 13: Engineering Acronyms in Software Engineering
- paired bootstrap: a bootstrap that resamples whole pairs, so the two arms are never drawn independently. Read more: 29.4 Paired A/B experiments
- Scaling laws: empirical power laws relating loss to compute, data, and parameter count. Read more: Chapter 2: Deep Learning
Concretely, the system does one real job end to end. Clean data flows through the CorpusBuild workflow, a tokenizer is trained and ablated, a Llama-family model trains as a durable TrainRun with mixed precision and bitwise resume, the result is evaluated against the model zoo, released through the gated ModelRelease workflow with a model card and data ledger, and served by your engine behind your gateway. Nothing new is added to the library here: the system runs, and the write-up records what it measured. Reading the section takes about three hours; reproducing it takes 4 to 12 hours of laptop training for the full configuration, under an hour for the short configuration, and minutes for the smoke tier.
The capstone draws on everything before it. It ships through the model release workflow from Systems Engineering, whose preflight it must pass; its full and short training specs use the bf16 emulation, gradient accumulation, and activation recompute of mixed precision, accumulation, and checkpointing; and its release report carries the safety suite from bias and safety evals in AI Engineering. The sections it leans on most are named where they matter below, above all tokenize and pack and the licensing ledger and datasheet from Data Engineering.
Learning objectives
- Size a training run from a compute budget with and count a Llama config’s parameters and KV bytes by hand.
- Design an ablation that changes one thing at an equal budget, pair it by document, and read its verdict from a bootstrap confidence interval.
- Reproduce a log-log least-squares scaling fit and a zoo table from the report’s own numbers.
- Explain how ADRs, the model card, the ledger, and the release gates turn measurements into a shippable decision.
- Check a capstone report for internal consistency without rerunning the training.
How the reference run is produced
Section titled “How the reference run is produced”The capstone uses only verbs the system already has. In the listing below, <system> is the deployed workflow CLI and {tinyllm} the Python CLI:
<system> data build --dataset tinystories --version v1 # CorpusBuild (data.09){tinyllm} tok train --algo bpe --vocab 4096 --sample 16MB # and --algo unigram, for the ablation<system> train --spec specs/c1/tinystories-short.json # TrainRun (dur.11); the full spec when there is a night to spare<system> train --spec specs/c1/abl-mla.json # one short run per ablation arm, same seed<system> eval --suite zoo # EvalSuite (dur.11) over every family trained# write docs/capstone/c1/report.json from the runs' outputs, then the two ADRs<system> release --spec specs/c1/release.json # ModelRelease (dur.12); then send it the `approve` signal # through the durable server's SignalWorkflow RPC from a gRPC client (dur.08)The data step is the CorpusBuild durable workflow; training and evaluation are the TrainRun and EvalSuite workflows; the final approval is a signal of the kind described in signals, cancellation, and sagas.
The inputs are staged by {tinyllm} capstone prepare, implemented in cli_c1_data.py:
# Full and short tiers: use the inputs produced by the corpus pipeline.{tinyllm} capstone prepare --spec specs/c1/tinystories-short.json --inputs artifacts --out runs/c1-inputs --seed 0# Smoke tier: the course's synthetic stories file.{tinyllm} capstone prepare --spec specs/c1/smoke.json --fixture <small reference corpus>/sources/stories.jsonl --holdout 32 --license CC0-1.0 --out runs/c1-smoke-inputs --seed 0The two tiers prepare differently. The smoke preparation fits BPE on the first 130 documents only, scrubs the fixture’s seeded redaction examples, and keeps the last 32 documents for evaluation; token manifests and separate corpus ledgers record the files, hashes, counts, and license. The full preparation instead checks and copies the completed CorpusBuild and tokenizer outputs under artifacts/ into the run directory, without fitting another tokenizer or changing the split, and a missing input is an error. Both write a run-local train-spec.json with the run’s seed, so a five-seed calibration really trains five independent initializations. The smoke tier then trains the smoke config (about 0.8M parameters, 200 steps), measures held-out bpb, and scores 20 seeded samples. The durable training, release, trace, and serving steps need the full system and its cluster.
The quantities the report is built on
Section titled “The quantities the report is built on”Before following the pipeline, fix the notation. Every claim in the report is phrased in terms of these quantities.
| Symbol | Meaning | Type |
|---|---|---|
| trainable parameters of the model | int | |
| training tokens | int | |
| training compute in FLOP (2 for the forward pass, 4 for the backward) | float | |
| held-out bits per byte: total NLL in bits over the held-out bytes | float | |
| a paired unit: one held-out document | ||
| the ablation’s paired difference on document | float | |
| , | the mean difference and its 95% bootstrap CI | float |
| , | the scaling fit | float |
The pipeline, stage by stage
Section titled “The pipeline, stage by stage”The capstone is a pipeline through parts of the system you built in many different chapters. The table maps each stage to what runs and where you built it.
| Stage | What runs | Where it was built |
|---|---|---|
| Data | CorpusBuild: fetch, filter (with the KN perplexity filter), dedup, decontamination, PII, shards; the tokenizer trained on a fixed 16 MB sample; encode to uint16 .bin | the corpus pipeline in Data Engineering, byte-level BPE, the Unigram LM tokenizer, Rust fast BPE, Kneser-Ney n-grams |
| Model | LlamaConfig(vocab=4096, d=320, layers=8, heads=8, kv_heads=4, d_ff=864, ctx=512, tied) | the modern decoder block, from pre-LN and RMSNorm to the Llama-family model; counting params, FLOPs, and KV bytes |
| Train | AdamW, WSD, clipping, bf16 emulation, accumulation, recompute; TrainRun segments with resume | Adam and AdamW, schedules and clipping, mixed precision, checkpoints and token streams, subprocess activities, TrainRun |
| Ablations | tokenizer, attention, MLP, one short run per arm | Unigram LM, multi-head latent attention, mixture of experts, hypothesis tests |
| Evaluate | held-out bpb with a CI, seeded samples, the scaling fit, the zoo table | the evaluation harness and model zoo, least squares, bits per byte, model evals as tests |
| Release | export, eval gates, model card, ledger, canary | ModelRelease, ledger and datasheet |
| Serve | the Rust engine behind the gateway | serving in this book, the gateway in AI Engineering |
Three tiers of the same run
Section titled “Three tiers of the same run”One config family comes in three sizes, so the same pipeline can be exercised at three costs. Only the first two produce a model result.
| Tier | Model | Tokens | Laptop time (estimate) | What it shows |
|---|---|---|---|---|
| full | about 10.4M parameters | about | 4 to 12 h | the capstone result: beats every zoo baseline |
| short | about 2.4M | about | under 1 h | the capstone result at a looser bar |
| smoke | about 0.8M, 200 steps | about | minutes | that the pipeline runs end to end; not a model result |
The rule sizes the run before it starts. The full tier is FLOP. At an effective 0.2 to 0.4 TFLOP/s for numpy with Accelerate on an M-series laptop, that is 4 to 9 hours. The throughput figure is uncertain, so measure your machine on a short run first.
Ablations are paired experiments
Section titled “Ablations are paired experiments”An ablation changes one thing and holds the budget equal; otherwise the comparison measures the budget rather than the idea. The capstone runs three:
- Tokenizer: BPE against Unigram at the same vocabulary size on the same sample. Compare in bits per byte, never per token: a tokenizer that splits text into more, easier tokens has a lower per-token loss and is no better a model.
- Attention: GQA against MLA at equal KV bytes per token. GQA caches values per token; MLA caches the latent plus the shared rope key , so . In bf16 each value is 2 bytes.
- MLP: dense SwiGLU against a mixture of experts at equal active parameters per token (the router plus experts, not all ).
Both arms are measured on the same held-out documents and paired by document, so the per-document difference removes how hard each document is. The verdict follows the 95% bootstrap CI of : b wins when , a wins when , and otherwise it is a tie. A tie is a result, not a failure.
The scaling fit and the zoo
Section titled “The scaling fit and the zoo”Three sizes of the short family give three points . In log space the power law is a line, , fitted by least squares with the lstsq from SVD, low rank, and least squares. Three points do not prove a law; they say whether the next size is worth training.
The model-zoo suite from the evaluation harness and model zoo, run by EvalSuite, scores every family the system trained on the same held-out text: KN-4, NPLM, LSTM, GPT, and the capstone Llama in bits per byte, plus the seq2seq (EM), classification (accuracy), and word-similarity (Spearman) rows. At the full and short tiers the capstone must beat every baseline.
Working the numbers by hand
Section titled “Working the numbers by hand”With the definitions in place, you can size the full config without running anything. Its shape is , , 8 layers, 8 heads of , 4 KV heads, SwiGLU width , and tied embeddings. The parameter count adds up as follows.
| Part | Count |
|---|---|
| embedding (shared with the output) | |
| per layer: , ( each) | |
| per layer: , ( each) | |
| per layer: gate, up, down () | |
| per layer: two RMSNorm gains | |
| 8 layers | |
| final norm | |
| total | 10,409,280 |
The KV cache costs, in bf16, bytes per token. An MLA arm at equal KV bytes therefore needs , for example and . The compute is FLOP.
Reading an ablation verdict is just as mechanical. In the reference smoke report (report.json), Unigram minus BPE is bits per byte over 32 documents, with CI . The CI excludes zero and , so a (BPE) wins. MLA minus GQA is with CI : the interval includes zero, so it is a tie. The walkthrough below recomputes the same quantities for the reference smoke-tier model and checks them against its report.
The artifacts and what they must satisfy
Section titled “The artifacts and what they must satisfy”A capstone is judged by its artifacts. The reference artifacts are smoke-tier: the specs in specs/c1/ (full, short, smoke, and release), the report and its companions in docs/capstone/c1/, and two ADRs, 0002-c1-vocabulary-size.md and 0003-c1-architecture.md. The CLI glue lives in cli_c1.py, cli_c1_data.py, and cli_c1_eval.py. The formats they follow are the contracts formats/train-spec.schema.json, formats/eval-results.schema.json (the zoo table), and formats/ledger.schema.json, the templates templates/ADR.md and templates/MODEL_CARD.md, and the report format tl.capstone-report.v1, whose fields the walkthrough below covers.
| Artifact | Content |
|---|---|
specs/c1/tinystories-10m.json, specs/c1/tinystories-short.json | train specs (formats/train-spec.schema.json) of the two tiers; the reference also has specs/c1/smoke.json |
specs/c1/release.json | the ModelRelease spec of the capstone model (see the release-spec design in the model release workflow): suites, a quality and a safety gate, the route, the canary, the burn query of <model_id>-<version> |
docs/capstone/c1/report.json | the report (tl.capstone-report.v1): tier, spec, tokenizer, model config and parameters, the training run, held-out bpb with its CI, the three ablations, the scaling points and fit, and the paths below |
docs/capstone/c1/zoo.json | the zoo suite’s report (formats/eval-results.schema.json) |
docs/capstone/c1/samples.jsonl | 20 samples, seeds 0 to 19: {"seed", "prompt", "text", ...} |
| the model card and ledger the release spec names | MODEL_CARD.md from the template (see datasheet and model card), the release’s LEDGER.jsonl |
two ADRs in docs/adr/ | the vocabulary (citing the tokenizer ablation) and the architecture (citing the attention and MLP ablations) |
The report is written by tooling from the runs’ outputs, a few lines of Python over the progress files and eval reports, never by hand.
What a correct capstone must satisfy
Section titled “What a correct capstone must satisfy”Every check below can be recomputed from the artifacts alone, which is what makes the report evidence rather than a claim.
| Case | Checks |
|---|---|
| parameter count | the hand count above, and the report’s parameter count recomputed from its own config |
| capstone train specs | both specs validate, are Llamas of the tier’s size, and train on enough tokens |
| a complete report | the report’s fields; a full or short tier (a smoke report is only a pipeline check); its spec, zoo, samples, and release exist; bpb inside its CI |
| fair, paired ablations | three ablations; equal vocabulary, KV bytes, active parameters (recomputed); mean inside its CI; the verdict follows the CI |
| a reproducible scaling fit | three or more sizes; the log-log least-squares fit of the points is the reported fit |
| the zoo table | the zoo report validates; KN-4, NPLM, LSTM, GPT, Llama on one text; the other tasks scored or skipped with a reason; the Llama row is the report’s bpb; the capstone wins at full and short |
| sample quality | 20 seeds; at least 20 words; repeated 8-grams at most 0.25 per sample and 0.10 on average; at least 30% distinct words |
| ADRs cite the ablations | the two ADRs, their sections, and the cited mean differences |
| the release passes the system’s own preflight | the Go ReleaseSpec decodes the release spec strictly, Validate and Preflight pass on its card and ledger; quality and safety gates; the burn query selects the served model |
The reference capstone, step by step
Section titled “The reference capstone, step by step”Before reading each step of the walkthrough, try to predict what the report must contain. The reasoning chain comes first, because each design choice in the reference run follows from it.
The reasoning from first principles
Section titled “The reasoning from first principles”- Size the run before training it. The goal fixes a compute budget (a laptop night), and turns that budget into a model size and a token count. The full config’s 10.4M parameters and tokens are what fits in 4 to 12 hours at 0.2 to 0.4 TFLOP/s; the smoke config is the same architecture shrunk until it trains in seconds.
- Make every reported number derivable. The parameter count must follow from the config, bpb must lie inside its own CI, and the zoo’s Llama row must equal the report’s bpb. If any one of these disagrees, the report describes a different model from the one that was trained.
- An ablation changes one thing at an equal budget. Otherwise the comparison measures the budget. So each arm’s budget quantity (vocabulary size, KV bytes per token, active parameters) is computed and recorded next to the result.
- Pair by document and bootstrap the mean difference. Documents vary in difficulty far more than the arms differ, so the per-document difference removes that variance, and resampling documents gives a CI for . The verdict is mechanical: a winner only when the CI excludes zero.
- Decisions follow from the verdicts. A measured winner is adopted; a tie keeps the option that costs less in engine work and memory. The ADR records the numbers so the decision can be revisited when the full tier reruns the ablation.
- The scaling fit is a least-squares line in log space, so it can be reproduced from the points; three points are a planning signal, not a law.
- Ship only through the release workflow. The model’s release spec must pass the same strict decoding, validation, and gates as any other release, and the canary’s burn query must select this model, or a bad release would be judged by another model’s error rate.
The spec
Section titled “The spec”The smoke spec (smoke.json) trains the smoke config with the same optimizer and schedule family as the full tier:
{ "name": "c1-smoke", "tokenizer": {"id": "c1-bpe-512", "path": "tokenizers/c1-bpe-512/tokenizer.json"}, "optimizer": {"name": "adamw", "lr": 0.003, "betas": [0.9, 0.95], "weight_decay": 0.1}, "schedule": {"name": "wsd", "warmup_steps": 20, "decay_frac": 0.2, "min_lr_ratio": 0.1}, "precision": {"dtype": "fp32"}, "batch": {"micro_batch": 16, "accum": 1, "seq_len": 128}, "steps": 200, "ckpt_every": 100, "seed": 0}That is tokens and FLOP. The report’s wall_s is 7.4 s, an effective 0.26 TFLOP/s, inside the tier estimate above, so the same machine would need roughly hours for the full tier. The short spec (tinystories-short.json) adds "precision": {"dtype": "bf16", "recompute": true} and "accum": 2, the features of mixed precision, accumulation, and checkpointing.
Before any run, check_spec in cli_c1.py rejects what the trainer cannot honour:
def check_spec(spec: dict) -> list[str]: errors = [] model = spec["model"] if model.get("tl_tokenizer") not in ("bytes", "file"): errors.append("llama requires tl_tokenizer bytes or file") if model.get("tl_tokenizer") == "file" and not spec.get("tokenizer", {}).get("path"): errors.append("file tokenization requires tokenizer.path") # vocabulary must match a file if spec.get("precision", {}).get("dtype", "fp32") not in ("fp32", "bf16"): errors.append("capstone precision must be fp32 or bf16") schedule = spec["schedule"] # ... schedule name in constant, cosine, wsd warmup = schedule.get("warmup_steps", 0) if not isinstance(warmup, int) or not 0 <= warmup < spec["steps"]: errors.append("warmup_steps must be an integer in [0, steps)") # else lr never peaks # ... decay_frac in (0, 1], min_lr_ratio in [0, 1], keep_ckpts and ckpt_every positive return errorsReturning a list of every problem, rather than raising on the first, means one failed submission reports everything wrong with the spec.
The parameter count
Section titled “The parameter count”The reference smoke model is , , 4 layers, 4 heads of , 2 KV heads, , tied. Following the same table as the full config: the embedding is ; each layer is ; four layers make 726,016; the final norm adds 128. The total is 791,680, which is the report’s "params".
The headline number
Section titled “The headline number”From report.json:
"eval": {"val_bpb": 0.500221, "ci95": [0.448999, 0.597273], "n": 32, "val_loss": 0.993277}The CI is a bootstrap over the 32 held-out documents, not over tokens: tokens within a document are correlated, and resampling them would give a CI that is too narrow. bpb lies inside its CI, as it must.
The ablations
Section titled “The ablations”Each ablation records both arms, their configs, the paired mean difference, its CI, the verdict, and the equal-budget quantity:
{ "id": "attention", "question": "GQA or MLA at equal KV bytes per token", "metric": "bpb", "unit": "held-out document", "n": 32, "seed": 0, "a": {"name": "gqa", "config": {"...": "the smoke config"}, "value": 0.500221}, "b": {"name": "mla", "config": {"...": "plus", "tl_attention": "mla", "tl_mla_rank": 112, "qk_rope_head_dim": 16, "qk_nope_head_dim": 32, "v_head_dim": 32}, "value": 0.499284}, "mean_diff": -0.011246, "ci95": [-0.042154, 0.00765], "winner": "tie", "kv_bytes_per_token": {"a": 1024, "b": 1024}}Recompute the budgets. GQA caches values per token, 1,024 bytes in bf16. MLA caches values, also 1,024 bytes: the rank 112 was chosen to make them equal. The MoE arm (4 experts, top-1, expert width 344) has 793,728 active parameters against 791,680; the 2,048 difference is the router, experts. The tokenizer arms share vocabulary 512 and the same 65,840-byte sample.
Notice that mean_diff is the mean of the per-document differences, not of the pooled values (). Pooled bpb weights documents by their byte count; the paired mean weights each document equally, which is what the bootstrap over documents resamples.
The CI comes from the course’s percentile bootstrap, bootstrap_ci in prob/stats.py, applied to the 32 differences with stat = mean:
def bootstrap_ci(x, stat, n_boot, alpha, rng): a = _sample(x, 1) # ... alpha in (0, 1), n_boot a positive integer n = a.size thetas = np.empty(int(n_boot), dtype=np.float64) for b in range(int(n_boot)): idx = np.empty(n, dtype=np.int64) for i in range(n): # One uniform per index, in order: the same seed resamples the same # rows in Python and in Go (ag.12). idx[i] = min(int(rng.uniform() * n), n - 1) thetas[b] = float(stat(a[idx])) # the statistic of one resample return ( float(stat(a)), # the point estimate on the real data quantile(thetas, alpha / 2.0), # 2.5th percentile quantile(thetas, 1.0 - alpha / 2.0), # 97.5th percentile )The one-uniform-per-index rule is what lets the Go implementation in paired A/B experiments reproduce the same resamples. The verdict rule is then mechanical: "b" if the upper bound is below 0, "a" if the lower bound is above 0, else "tie". Applied to the reference, the tokenizer interval excludes zero with , so BPE (a) wins; the attention interval and the MLP interval include zero, so both are ties. The MLP interval is a useful lesson: its lower bound is almost exactly zero, and the rule still calls it a tie.
The decisions
Section titled “The decisions”The ADRs turn the verdicts into choices. ADR-0002 adopts byte-level BPE because it won:
On the paired held-out documents, Unigram’s bits per byte minus BPE’s is 0.032 on average, 95% CI (0.014, 0.059): BPE is better and the interval excludes zero.
ADR-0003 keeps GQA and a dense MLP although neither alternative lost, because a tie is decided by cost:
Both intervals include zero: neither alternative is measurably better at this tier, and both cost engine work.
It lists the cost precisely: MLA needs the latent cache of the KV cache and generate and weight absorption in the engine, and the MoE holds four times the MLP weights for the same active compute. Both ADRs record the evidence’s limits (one seed, smoke tier) as a consequence, so the full tier knows to rerun them.
The scaling fit
Section titled “The scaling fit”The report’s three points are , , and , and the fit is , . You can reproduce it: regress on by least squares; the intercept is and the slope is . That gives exactly the reported values. An exponent of is almost flat: at 200 steps every size is data-limited, so a bigger smoke model buys nothing. The model card says so, and that is the right reading. The smoke tier proves the pipeline, not the model.
The zoo
Section titled “The zoo”zoo.json scores every family on the same ts-val text:
| Model | Parameters | bpb (95% CI) |
|---|---|---|
| KN-4 | (counts) | 0.646 (0.599, 0.725) |
| NPLM | 230,208 | 0.602 (0.544, 0.707) |
| LSTM | 592,384 | 0.496 (0.453, 0.578) |
| GPT | 875,264 | 0.943 (0.877, 1.065) |
| c1-llama | 791,680 | 0.500 (0.449, 0.597) |
The Llama row is the report’s val_bpb. At the smoke tier the LSTM edges it out, inside overlapping CIs, which is allowed: only the full and short tiers must beat every baseline. The seq2seq, classification, and word-similarity rows are "skipped" with a reason, which is how a report says “not measured here” without leaving a hole.
The samples
Section titled “The samples”The 20 samples in samples.jsonl (prompt “Once upon a time”, temperature 0.8, 64 tokens, seeds 0 to 19) are scored with the word-level scorers of model evals as tests by quality in cli_c1_eval.py. The reference samples have at least 34 words each, no repeated 8-gram in any sample, and at least 60% distinct words (70% on average), well inside the thresholds listed earlier.
The release
Section titled “The release”The last artifact is release.json:
{ "model_id": "c1-smoke", "version": "v1", "from": "runs/c1-smoke/ckpt", "dtype": "f32", "quant": "none", "model_card": "docs/capstone/c1/MODEL_CARD.md", "ledger": "docs/capstone/c1/LEDGER.jsonl", "suites": ["quality", "safety"], "eval_seed": 0, "gates": [ {"suite": "quality", "task": "ts-val", "metric": "bpb", "op": "<=", "value": 0.6}, {"suite": "safety", "task": "refusal", "metric": "score", "op": ">=", "value": 0.9} ], "route": "tinystories", "canary_weight": 0.1, "canary_wait_s": 600, "approve_timeout_s": 86400, "burn": { "query": "sum(rate(http_server_request_duration_seconds_count{model=\"c1-smoke-v1\",http_response_status_code=~\"5..\"}[5m])) / sum(rate(http_server_request_duration_seconds_count{model=\"c1-smoke-v1\"}[5m])) / (1 - 0.99)", "max": 14.4 }}Each field earns its place. The quality gate (bpb at most 0.6) is set above the measured 0.500 and its upper CI bound 0.597, so the release passes on this evidence and a regressed retrain would not. The burn query selects model="c1-smoke-v1", the <model_id>-<version> of this release, so the canary is judged on its own errors: the ratio is the 5xx rate over the error budget of a 99% SLO, and 14.4 is the standard fast-burn threshold, the rate that would spend a 30-day budget in about two days. The model card (MODEL_CARD.md) carries the evaluation table with CIs and states the out-of-scope uses; the ledger records the one data source with its license, hash, and allowed uses (train, eval), which Preflight checks against the release.
Why this design
Section titled “Why this design”The reference run makes a handful of choices that deserve defending.
Cost comes first. The full tier is one laptop night, plus one short run (under an hour) per ablation arm and per extra size of the scaling fit. The smoke tier reproduces the whole report in minutes, which is what makes it a usable regression check for the pipeline.
A paired bootstrap beats a t-test on pooled numbers. Two arms’ pooled bpb differ by less than the spread between documents, so an unpaired comparison would call almost everything a tie; pairing removes the document effect. The bootstrap also makes no normality assumption about per-document differences, which are skewed because a few hard documents dominate.
Equal budgets beat “the default config of each”. An MLA arm that caches more, or an MoE that computes more per token, would win for a reason that has nothing to do with the architecture. Holding the budget equal and recording it makes the comparison mean what the question asks.
A tie is decided by cost. When the evidence cannot separate two options, the cheaper one to build and run is the right default, and the ADR keeps the door open by naming what would change the decision.
Finally, some tradeoffs are accepted openly: one seed per arm (so seed variance is not in the CI), 32 evaluation documents at the smoke tier, and a three-point scaling fit. Each is stated in the ADRs or the model card rather than hidden.
What can go wrong
Section titled “What can go wrong”Most capstone failures are not crashes. They are reports that look fine and mean something other than what they say. The table lists the ones the reference run is built to avoid.
| Pitfall | Symptom | How the solution avoids it |
|---|---|---|
| an ablation at unequal budget | MLA “wins” because it caches more; the MoE “wins” because it computes more | each ablation records its budget (kv_bytes_per_token, active_params, equal vocabulary), and the arms are sized to match |
| a winner declared inside the noise | an ADR built on a CI that includes zero | the verdict follows the CI; the attention and MLP ablations are recorded as ties |
| comparing tokenizers per token | the tokenizer with more, easier tokens looks better | every ablation’s metric is bpb |
| a report that describes another model | parameters, config, and zoo row disagree | the parameter count follows from the config, and the zoo’s Llama row is val_bpb |
| a scaling fit drawn by eye or in linear space | and that no least-squares fit gives | the fit is least squares on against , reproducible from the points |
| baselines scored on different text | a zoo table whose rows cannot be compared | every zoo row is scored on ts-val |
| a looping or degenerate sampler | the same 8-gram again and again; a handful of words | samples are scored for repeated 8-grams and distinct words; the reference has no repeats |
| decisions without evidence | ADRs that state a choice and cite nothing | ADR-0002 and ADR-0003 quote each mean difference and CI |
| a release the system’s own workflow refuses | a template placeholder in the card, a non-train source, a burn query of another model | the card is filled from the report, the ledger allows train and eval, and the burn query names c1-smoke-v1 |
| a smoke run presented as the capstone | 200 steps of a 0.8M model reported as “the model” | the report says "tier": "smoke", and the model card scopes it to a pipeline test |
Warning: The smoke tier is a pipeline test. Its numbers prove that every stage connects and that the report is internally consistent; they say nothing about how good a TinyStories model the system can train. Only a full or short report is a capstone result.
Where this leads
Section titled “Where this leads”Looking back, the capstone is the end-to-end result of everything up to the capstone training stage of the course path: it ships through ModelRelease, trains with the features of mixed precision, accumulation, and checkpointing, and reports the safety rows of bias and safety evals. Nothing in the system calls it. Looking forward, two things build on its release. The optional second capstone post-trains the released model into an instruction follower, and the data incident drill in Systems Engineering revokes a source of this model’s data and drives the retrain decision through ModelRelease.
Each piece also has a production counterpart worth studying. Karpathy’s nanoGPT and llm.c (see llm.c/train_gpt2.c) run the same loop on GPUs with careful throughput accounting. The DeepSeek-V2 and Mixtral reports run MLA and MoE ablations at scale with compute-matched baselines. Chinchilla’s three approaches fit scaling laws over hundreds of runs with isoFLOP profiles (Hoffmann et al., section 3). HELM (crfm-helm) and the Open LLM Leaderboard extend the zoo table to many tasks with standardized prompts and seeds.
Further reading
Section titled “Further reading”- Eldan and Li, TinyStories (2023, free).
- Kaplan et al., Scaling Laws for Neural Language Models (2020, free).
- Hoffmann et al., Training Compute-Optimal Large Language Models (2022, free).
- DeepSeek-AI, DeepSeek-V2 (MLA, free).
Key terms
Section titled “Key terms”- Compute budget: the training FLOP available, , which fixes the trade between parameters and tokens .
- Bits per byte (bpb): total held-out negative log-likelihood in bits divided by the number of held-out bytes, comparable across tokenizers.
- Ablation: a paired experiment that changes one component while holding its budget (vocabulary, KV bytes per token, or active parameters) equal.
- Paired difference: the per-document difference between two arms, which cancels how hard each document is.
- Percentile bootstrap CI: an interval from the 2.5th and 97.5th percentiles of a statistic recomputed on resampled documents.
- Scaling fit: the least-squares line through measured sizes.
- Model zoo: the table that scores every model family the system trained on the same held-out text.
- 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.
Summary
Section titled “Summary”- The capstone runs the whole system on one goal and treats the report as evidence that must agree with itself and with the runs.
- sizes the run: the full tier is 10,409,280 parameters, tokens, and about FLOP.
- Ablations change one thing at an equal budget, pair by held-out document, and name a winner only when the 95% bootstrap CI excludes zero; a tie is decided by cost.
- Every reported number is derivable: parameters from the config, the scaling fit from its points, the zoo’s Llama row from
val_bpb. - ADRs record decisions with their evidence, and the model ships only through the system’s own gated release workflow, judged by a burn query on its own traffic.
Review questions
Section titled “Review questions”-
Why compare tokenizers in bits per byte rather than per-token loss?
Answer
Per-token loss depends on how text is cut. A tokenizer that produces more, smaller tokens has easier predictions per token and a lower per-token loss without modelling the text any better. Bits per byte divides the total information by the number of bytes, which is the same for both tokenizers on the same text.
-
The reference MLA arm uses rank 112 and a rope dimension of 16. Where do those numbers come from?
Answer
From equal KV bytes per token. GQA in the smoke config caches values per token. MLA caches , so gives ; with , .
-
The MLP ablation’s CI is . Why is the verdict a tie and not “dense wins”?
Answer
The rule names a winner only when the 95% CI of the paired difference excludes zero. , so it does not, however close the bound is. Declaring a winner on a CI that includes zero would build an ADR on noise.
-
Why is the release’s quality gate 0.6 and not, say, 0.55?
Answer
The gate must pass the model that is being released, on the evidence the release evaluation produces, and fail a regression. The measured bpb is 0.500 with a CI up to 0.597; a gate of 0.55 sits inside the CI, so the same model could fail it on a different evaluation seed. 0.6 is just above the upper bound.
-
Why must the burn query name
c1-smoke-v1exactly?Answer
The canary is promoted or rolled back on the burn rate of its own traffic. A query that matched another model (or every model) would let a broken release ride on a healthy model’s error rate, or roll back a good one because of someone else’s errors.
-
The attention ablation’s
mean_diffis , but the two arms’ pooled values differ by only . Which one does the verdict use, and why?Answer
The verdict uses
mean_diff, the mean of the 32 per-document differences. Pooled bpb weights documents by their byte count, while the paired mean weights each document equally, which is exactly what the bootstrap over documents resamples. Mixing the two would pair a CI from one statistic with a point estimate from another. -
Why is the bootstrap done over documents rather than over tokens?
Answer
Tokens within a document are correlated, so they are not independent samples. Resampling tokens would treat them as if they were and produce a confidence interval that is too narrow; resampling whole documents respects the unit at which the data are independent.