Unit 6 of 11 · about 4 hours · implement
Versioned run contracts, deterministic smoke tests, overfit checks and stop rules
The lmlab run is now an experiment, not just a training script. A frozen contract makes later changes to data, schedule, resume and evaluation visible rather than silently redefining the baseline.
You'll be able to
- Implement a versioned run contract binding corpus, tokenizer, model, objective, optimizer, precision and evaluator identity.
- Gate launches on deterministic smoke tests and a separate overfit-one-batch diagnostic.
- Declare budgets, validation cadence, stop triggers and rollback ownership before comparing configurations.
Covers
Read
In this order, only the parts listed
0 of 3 done
- Specify the comparison before launching itDeep Learning Tuning Playbook
Identifying scientific, nuisance, and fixed hyperparameters; Determining the number of steps for each training run; Saving checkpoints and retrospectively selecting the best checkpoint; Setting up experiment tracking
Skip batch-normalization guidance. Here compute-limited means budget-limited training, not evidence that GPU kernels are compute-bound.
- OLMo-core: a bounded CPU integration configurationOLMo-core and Official Training Scripts
build_configandtest_train_small_model_cpu:olmo3_30M, sequence length 64, five steps and model-merge/load checksRead as the reference contract. Running the OLMo test is optional: it needs extra dependencies and external data. Do not launch the official large-model scripts.
- CS336 Spring 2026 Assignment 1: launch and overfit checksCS336 Assignment 1 - Training and Serialization
Version 26.0.3, Section 5.3 Training loop and Section 7.2.3 Tips and tricks for debugging model architectures
Use your existing decoder on a small versioned corpus slice. Replace the assignment's full training and leaderboard budgets with minutes-long smoke runs; do not adopt its score targets or publish solutions.
Focus on
- The Deep Learning unit on objective checks covers tiny-set overfitting and shuffled-label controls. A smoke run checks finite state and reproducible execution; overfitting one batch tests whether the implementation can learn its targets, not generalization.
- Record code revision, dependency versions, data and tokenizer hashes, model shape, masks, groups, schedule units, RNG streams, checkpoint policy and the fixed held-out evaluation slice. Pin this training path to PyTorch 2.14.1.
- Use your decoder from the Architecture and Numerics section, at around 10M parameters, for the small study. If it does not fit your GPU, use shorter context and smaller microbatches; a two-layer, width-64 decoder with a small vocabulary on CPU suffices for contract and failure tests.
- Predeclare token and wall-time budgets, nonfinite refusal, identity-mismatch refusal, validation selection and rollback rules. A changed contract starts a named branch with a parent checkpoint, not an invisible continuation.
Common mistakes · 3
- Expecting every overfit-one-batch run to reach zero loss. Conflicting targets for identical available contexts can impose a nonzero optimum; choose a learnable diagnostic fixture.
- Selecting checkpoints on the final test set. Use a development slice for selection and reserve an untouched evaluation slice for the frozen result.
- Trusting nanoGPT's
max_itersas an update count. At the pinned revision its loop executesmax_iters + 1updates; test and fix your stop boundary.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.The batch overfit check passes. What has not been established?Answer
Generalization, correct data order over a full run, resume equivalence and fairness of later comparisons. A model can memorize a flawed diagnostic batch.
2.Why distinguish a budget stop from a numerical stop?Answer
The first completes the planned exposure; the second is a failed or interrupted attempt. Combining them hides instability and makes completed-run averages misleading.
3.You double the batch while leaving maximum steps fixed. Is that the same token-budget experiment?Answer
No. It roughly doubles data exposure. Recompute steps or explicitly change the comparison contract.
You're done when
A clean invocation reproduces the smoke trace at the declared equivalence level, the separate learnable fixture overfits, and an exceeded budget or identity mismatch triggers the declared stop with evidence retained.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 15 more in the section
- OLMo-core and Official Training ScriptsAllen Institute for AI · primary
Trace
src/examples/llm/train.pythroughnn/transformer/,optim/,train/train_module/,train/trainer.pyandtrain/callbacks/checkpointer.py. Note whatTrainer.state_dictsaves (loader, RNG and callback state) and how the data loader checks its fingerprint. The CPU integration testtest_train_small_model_cpuneeds extra packages and downloads external data, so point it at a small local fixture or treat the run as optional. - CS336 Assignment 1 - Training and SerializationStanford University · required
Revisit only the optimizer, schedule, gradient clipping, data loading, checkpointing, training-together and decoding problems. Add kill-and-resume, tokenizer mismatch and corrupted-checkpoint tests beyond the foundation implementation.
- Deep Learning Tuning PlaybookGoogle Research · required
Read
#a-scientific-approach-to-improving-model-performance(scientific, nuisance and fixed hyperparameters; incremental tuning),#determining-the-number-of-steps-for-each-training-run,#saving-checkpoints-and-retrospectively-selecting-the-best-checkpointand the FAQ entries on schedules and#how-can-optimization-failures-be-debugged-and-mitigated. Write the run and triage protocol before launching comparisons; skip the batch-norm material.
Also in this section
- Build a Large Language Model (From Scratch), Chapter 5 and Appendix DSebastian Raschka / Manning · support
Use Chapter 5 (the loss, training loop and saving weights, pp. 128-167) and Appendix D (warmup, cosine decay and gradient clipping, pp. 313-321) as the first correct tiny pretraining loop before the large-run recipe.
- nanoGPT Training LoopAndrej Karpathy · support
Read
train.pyandmodel.pyat commit 3adf61e and run the reduced CPU or small-GPU configuration. The repository is marked deprecated, its checkpoint holds no RNG, scaler or data-loader state, and the loop runsmax_iters + 1updates. Use those gaps for your kill-and-resume and atomic-save tests. - Machine Learning Engineering - Instabilities, Checkpoints and DebuggingStas Bekman · support
Read
training/instabilities/README.mdandtraining/instabilities/training-loss-patterns.md(spike types, resume and data-sampler spikes),training/checkpoints/README.md,debug/underflow_overflow.mdandtraining/dtype.md. Use the spike taxonomy to label the failure you inject. - The Smol Training Playbook - Preflight and Training MarathonHugging Face · support
Read the Preflight Checklist, the Training Marathon and the loss-spike stories for checks to run before and during a small pretraining run. The page has no stable anchors, so cite section names; its SmolLM numbers do not transfer to your model.
- 2 OLMo 2 Furious, Sections 2.3, 3.1 to 3.4 and 6.3Allen Institute for AI · support
Read the base training recipe (Section 2.3), the stability deep dive (repeated n-grams, initialization, norm and z-loss changes, embedding weight decay; Sections 3.1 to 3.4) and stability operations (Section 6.3) as the real narrative behind your tiny-run contracts.
- OPT: Open Pre-trained Transformer Language Models, Section 2.5 (Zhang et al., 2022)Meta AI · support
Read Table 1 and Section 2.5: at least 35 manual restarts, loss divergences handled by lowering the learning rate and restarting from an earlier checkpoint, and mid-run clipping changes. Use it as the failed-run case study when you write your own run log.
- Scaling Laws and Compute-Optimal Training Beyond Fixed Training Durations (Hagele et al., 2024) with MiniCPM Section 4EPFL; Tsinghua and ModelBest · support
Read Hagele Sections 2 and 3 (constant learning rate plus cooldown matches cosine and allows mid-run evaluation) and MiniCPM Section 4 (warmup-stable-decay with a short decay phase). MiniCPM is at https://arxiv.org/abs/2404.06395. Both use sub-billion or small models.
- Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfer (Yang et al., 2022)Microsoft and OpenAI · support
Read Algorithm 1 (muTransfer) and Table 1 (which hyperparameters transfer and which do not), then one transfer figure. Transfer holds within one architecture, optimizer and data family.
- Mixed Precision Training (Micikevicius et al., 2018)NVIDIA and Baidu · reference
Read Section 3: FP32 master weights, loss scaling and FP32 accumulation, and the rule to unscale gradients before clipping. It predates BF16, which needs little or no loss scaling.
- An Empirical Model of Large-Batch Training (McCandlish et al., 2018)OpenAI · reference
Read Section 2: the gradient noise scale, the critical batch size and the steps-versus-examples trade-off in Figure 1. The noise scale grows as loss falls, so measure it at more than one point.
- Modern LLM Notebook - Training and AccountingWalking Labs · support
Use
notebooks-en/part2-training/10-training-loss.ipynband the appendix notebooksB-flops-memory-accounting.ipynbandC-mixed-precision-training.ipynbfor the compact trainer, FLOP and memory accounting and mixed precision. Seed one numerical failure and reconcile the estimate with measurement. - TensorTonic - Training Reliability DrillsTensorTonic · support
Solve Mixed-Precision Training Memory Accountant (
cs336-l02-training-memory-accountant), Transformer Training FLOP Estimator (cs336-l02-training-flop-estimator), Gradient Accumulation Equivalence (cs336-l02-gradient-accumulation-step) and Generate a Warmup-Stable-Decay Schedule (cs336-l11-wsd-learning-rate). Validate each against your training harness. Public test cases check the listed edge cases, not gradients or the hidden grader, so keep your own tests beside each solution. - Decoder-Only Transformer Stack - Reliable TrainingRoadmap-Final · support
Use the existing training, resume and arithmetic contracts as the small controlled system. Add stored evidence for data, numerical, state and throughput failure injections.
- PyTorch 2.14 - AMP Examples and ProfilerPyTorch · reference
AMP examples: Gradient clipping and Gradient accumulation, including effective-batch scale updates and skipped optimizer steps. Profiler reference:
record_function,scheduleand memory capture. Use with PyTorch 2.14.1. - Python - Atomic Replacement and File SynchronizationPython Software Foundation · reference
Read
os.replaceandos.fsyncfor the local single-file publication extension. Atomic visibility is not a power-loss durability guarantee. Page read 2026-10-16.