Pretraining Reliability
A small training run should already have the state, observability and failure discipline required at larger scale. This stage makes silent data, numerical, checkpoint and performance failures diagnosable.
Section 3 of 11 · 11 units · about 48 hours
By the end you can Resume a versioned run without an unexplained state or data discontinuity, diagnose one seeded data, numerical, checkpoint and throughput failure from stored evidence, and reconcile one memory and one compute prediction with measurements.
Units
- Token-weighted loss denominators, microbatches, accumulation and seen-token counts4h
- AdamW state, parameter groups, weight decay and update-to-weight ratios3h
- Warmup-stable-decay schedules, gradient noise and the critical batch6h
- Mixed precision, loss scaling, nonfinite handling and gradient-clipping placement4h
- Initialization transfer and muP width-scaling rules3h
- Versioned run contracts, deterministic smoke tests, overfit checks and stop rules4h
- Complete language-model checkpoint state, atomic publication and corrupted-state handling5h
- Exact and statistical resume equivalence, and data discontinuity diagnostics5h
- Loss spikes, divergence and delayed failure, with activation, gradient and update instrumentation5h
- Step timelines, tokens per second and memory and operation accounting6h
- Failed-run triage, all-attempt retention and hardware failure signatures3h
Build it
Mini project · about 18 to 24 hours
Restartable decoder training with retained failure evidence
Extend lmlab with a reliable single-device trainer for the tested decoder and versioned corpus. Use the pinned nanoGPT path and PyTorch from the units, prove updates and recovery before the bounded study, and retain numerical, data and performance incidents without claiming fleet reliability.
- 1Adapt the pinned nanoGPT trainer in
train/to your decoder. Check masked token accumulation against concatenated-batch gradients, including uneven, partial and empty windows; pass CS336 Assignment 1 AdamW tests and retain scalar-update, tied-group, moment-resume and actual update-ratio audits before training. - 2Save a decoder-specific muP worksheet, actual group multipliers and bounded initialization-transfer scales against the stated parameterization rules. Check accumulation, unscaling and clipping against full-precision updates; inject a nonfinite event and retain refused-update, unchanged-moment and precision-state restoration regressions with preceding diagnostics.
- 3Freeze the baseline contract in
registry/, binding code, dependencies, data, tokenizer, model, objective, optimizer, precision and evaluator. Gate launches on deterministic trace equality and a separate learnable-batch overfit diagnostic; retain fixed held-out evaluation and budget, identity-mismatch, stop and rollback tests. - 4Extend nanoGPT's checkpoint path with a state inventory covering model, moments, groups, schedule, scaler, counters, RNG, loader, prefetch and callbacks. Publish immutable payloads with integrity manifests; test killed writers and corruption against acceptance rules, retaining explicit last-good fallback without claiming power-loss durability.
- 5Compare uninterrupted training with killed-process continuation under dropout, checking batches, losses, updates and complete state against the deterministic CPU reference. Retain missing-RNG, repeated-shard and strict data/tokenizer/config fingerprint negative controls, first-discontinuity evidence and the declared numerical or statistical equivalence boundary.
- 6Fork stable-phase state into constant and cooldown schedules and compare token batches under equal learning-rate search budgets. Hold tokens, held-out evaluation and paired seeds fixed; retain losses, uncertainty, exposure, attempted/successful updates and shared, marginal and all-attempt costs. Reproduce the baseline from clean state.
- 7Instrument phase timelines, per-source losses and layer scales; localize injected numerical and input-wait incidents against unchanged-batch replays. Reconcile dtype-specific state-memory and operation predictions with profiles, retaining pre-event history, throughput, observer overhead, first-invalid evidence, repaired regressions, an incident index and bounded, single-device recovery claims.
What you hand in
- The
train/trainer, complete-state inventory, immutable checkpoints and objective, precision, publication and killed-process resume regressions. - Frozen baseline and schedule/batch studies with fixed evaluation, update ledgers, paired uncertainty and all attempts retained.
- Incident index, matched replays, profiling reconciliations and clean baseline reproduction instructions with explicit recovery and hardware-scope limits.
How to check it
- Self-grade with the rubric below
- CS336 Assignment 1 AdamW regression tests
Pass the optimizer regression; add masked accumulation, parameter-group, precision and complete-state continuation tests in your trainer.
How it's graded
Update and launch correctness
Pass: Your masked gradient and scalar AdamW oracles pass before training; group identities, width multipliers and precision state are audited. Deterministic launch, learnable-batch, stop and nonfinite-refusal tests pass.
Great: A wrong denominator or clipping order fails a targeted regression, and the repaired update agrees with the independent full-precision control.
Publication and continuation
Pass: Your killed-writer and corruption tests reject uncommitted state without live mutation. Dropout continuation matches the uninterrupted reference; missing-RNG, repeated-shard and fingerprint controls fail, with last-good recovery explicit.
Great: Fresh-process state comparisons localize the earliest differing owner, including a pending batch; a clean baseline rerun reproduces the documented recovery contract.
Measured reliability evidence
Pass: Matched schedule and batch studies retain paired-seed outcomes and all costs. Timeline and memory/operation reconciliations, incident histories, matched replays and regressions support bounded diagnoses rather than hardware-fault assertions.
Great: An input-wait repair preserves updates and resume behavior; separate clean timings expose observer overhead, and the negative regime changes the next experiment.
Resources
- OLMo-core and Official Training ScriptsAllen Institute for AI
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
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
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
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
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
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
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
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
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
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
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.
- Modern LLM Notebook - Training and AccountingWalking Labs
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
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
Use the existing training, resume and arithmetic contracts as the small controlled system. Add stored evidence for data, numerical, state and throughput failure injections.
- Mixed Precision Training (Micikevicius et al., 2018)NVIDIA and Baidu
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
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.
- PyTorch 2.14 - AMP Examples and ProfilerPyTorch
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
Read
os.replaceandos.fsyncfor the local single-file publication extension. Atomic visibility is not a power-loss durability guarantee. Page read 2026-10-16.