Unit 8 of 11 · about 5 hours · measure
Exact and statistical resume equivalence, and data discontinuity diagnostics
A smooth loss curve is weak evidence of correct resume. Token exposure can repeat or skip without a conspicuous spike, so continuation must be checked against an uninterrupted trace at the same logical position.
You'll be able to
- Specify exact, tolerance-based and statistical continuation criteria before running a restart test.
- Compare next-batch identities, RNG-dependent computation, optimizer state and held-out loss across a process restart.
- Localize a data discontinuity to corpus, shard, tokenizer, mixture, sequence-length or sampler-state changes.
Covers
Read
In this order, only the parts listed
0 of 3 done
- OLMo-core: loader fingerprint and consumed positionOLMo-core and Official Training Scripts
NumpyDataLoaderBase.state_dictandload_state_dict:dataset_fingerprint_version,dataset_fingerprint,batches_processed,tokens_processed,seedandepochNotice that a fingerprint-version mismatch only warns, while a same-version fingerprint mismatch normally raises. Make lmlab's strict acceptance policy explicit rather than assuming both cases fail closed.
- OLMo-core: RNG restoration boundaryOLMo-core and Official Training Scripts
Trainer.load_state_dict: loader restoration, callback state, matching-world-size RNG restore and library-version warning - Recognize resume and repetition patternsMachine Learning Engineering - Instabilities, Checkpoints and Debugging
Resume-related spikes: DataSampler related issues and Impacts of repeat data
Treat the historical framework anecdotes as cases, not current universal defaults. Use batch lineage to test your loader directly.
Focus on
- Compare the resumed run with the uninterrupted suffix, including the first consumed batch, valid-target count, learning rate, scaler, moments and parameter tensors. Evaluation must not perturb the training RNG stream unnoticed.
- Exact equivalence means bitwise state and trace agreement within a frozen deterministic environment. Tolerance-based numerical agreement is a different claim; cross-release or cross-device identity is not promised by PyTorch.
- For an explicitly nondeterministic path, compare paired multi-seed held-out results and diagnostics against a prespecified practical margin. An insignificant difference or one similar curve is not proof of statistical equivalence.
- Log source, shard, token offsets, tokenizer hash, packing version, sequence length and batch digest. A corpus fingerprint alone does not certify every tokenizer or packing choice.
Common mistakes · 3
- Treating statistical equivalence as permission for repeated or missing documents. Logical data identity remains testable even when kernels are nondeterministic.
- Restoring RNG before constructing the model. Initialization consumes draws and shifts the resumed stochastic stream.
- Ignoring a fingerprint mismatch because the validation curve seems healthy. That turns a continuation into an undocumented data intervention.
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.Batch hashes match after resume, but dropout outputs differ immediately. What do you inspect first?Answer
The relevant RNG state and restoration order, train/eval mode and deterministic execution settings. Matching data does not imply matching stochastic computation.
2.Why can a reset sampler initially improve the training loss?Answer
It can replay already-learned examples. Lower replay loss is not evidence of better generalization or correct exposure.
3.Three seeds show no statistically significant loss difference. Have you proved equivalence?Answer
No. Failure to detect a difference can reflect low power. Specify a meaningful equivalence margin and report the uncertainty relative to it, while checking deterministic state and lineage directly.
You're done when
A real restart passes the declared equivalence contract, and the omitted-RNG, reset-sampler and changed-identity controls fail at the expected boundary with the earliest differing evidence preserved.
Only when you can do this without notes.
Leads to
Notes
Resources · 2 for this unit, 16 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. - 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.
Also in this section
- 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. - 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. - 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.