Unit 3 of 11 · about 6 hours · derive, measure

Warmup-stable-decay schedules, gradient noise and the critical batch

A stable-phase checkpoint can support several cooldown experiments, but those branches still cost tokens and compute. This unit makes that reuse explicit instead of treating a paper's schedule as a universal recipe.

You'll be able to

  • Specify warmup, stable and decay phases with unambiguous step and token boundaries.
  • Explain the critical batch as an optimization trade-off, not a memory-capacity limit.
  • Compare schedule and batch interventions under fixed tokens, held-out evaluation and recorded seed variation.

Covers

Warmup, stable training, decay and stop schedulesGradient noise, critical-batch vocabulary and batch-size limits
1

Read

In this order, only the parts listed

0 of 3 done

  1. Constant learning rate plus cooldownScaling Laws and Compute-Optimal Training Beyond Fixed Training Durations (Hagele et al., 2024) with MiniCPM Section 4

    Sections 2 and 3, especially 3.1 The Advantages and 3.2 Experimental Comparison, Figures 3 to 6

    Stop before stochastic weight averaging. Treat the 210M SlimPajama comparisons as the authors' evidence, not a target for your decoder.

  2. MiniCPM: the WSD contractScaling Laws and Compute-Optimal Training Beyond Fixed Training Durations (Hagele et al., 2024) with MiniCPM Section 4

    Section 4.2 WSD LRS, Equation 1; Section 4.3 and its decay-stage experiments

    Read the schedule and branch-reuse argument only. Do not reproduce MiniCPM's model-scale runs.

  3. Noise scale and the useful-batch frontierAn Empirical Model of Large-Batch Training (McCandlish et al., 2018)

    Figure 1; Sections 2.1 to 2.3, especially Equations 2.2, 2.8 and 2.12

    Stop after the steps-versus-examples trade-off. Full noise-scale estimation and large-batch theory are depth, not the exit gate.

2

Focus on

  • Write which learning rate is used by each attempted update and whether the schedule advances on attempted or successful updates. Record both counters and the consumed-token position.
  • WSD names phases, not one decay function. The TensorTonic drill uses endpoint-inclusive cosine decay; MiniCPM permits a decreasing decay function and Hagele studies linear and square-root cooldowns.
  • The paper's inverse-batch covariance law assumes independent samples. Adjacent language-model tokens are correlated; report your batch unit and do not call a token count an independent-sample count.
  • At fixed tokens, a larger batch gives fewer updates. Retune learning rate with the same small search budget, and compare held-out loss after cooldown, not an unannealed branch against an annealed one.
Common mistakes · 3
  • Counting a reused prefix once in every branch's independent-run cost, or counting all cooldown branches as free. Report shared cost, marginal branch cost and total study cost separately.
  • Calling the largest batch that fits memory the critical batch. One is a system limit; the other concerns diminishing optimization returns.
  • Transferring a source's decay fraction without checking your budget, data and optimizer. Tiny-scale evidence supports only the tested regime.
3

Try it yourself

Closed-book, before checking anything

Derive the free WSD drill's six rates for total steps 6, warmup steps 2, stable steps 2, peak rate 1 and final ratio 0: [0.5, 1, 1, 1, 1, 0]. Explain why its one-step decay uses the final rate immediately. In lmlab, fork one saved stable-phase state into constant and cooldown branches with identical next tokens and held-out evaluation; keep both outcomes rather than requiring cooldown to win.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Why can a stable-phase checkpoint be more useful for continued training than its cooled-down descendant?Answer

    It preserves the high-rate trajectory. Continuing the cooled-down state at a high rate introduces a rewarming intervention whose stability and forgetting need separate testing.

  2. 2.Why can doubling batch size reduce steps without reducing total tokens to a given loss?Answer

    Larger-batch gradients are less noisy but have diminishing per-step benefit. The step saving may be smaller than the doubled examples per step.

  3. 3.If the token batch doubles at a fixed token budget, what happens to the number of optimizer opportunities?Answer

    It roughly halves, with rounding and the final partial batch handled explicitly. This changes the optimization horizon even before considering skipped steps.

5

Practice

  • TensorTonic: Generate a Warmup-Stable-Decay Schedule

    Implement wsd_learning_rate; public cases Warmup stable and two-step decay, No warmup and One-step decay

    The free cases check specific rate vectors, not learning quality. The section mini-project adds a fixed-token schedule fork and a small batch-size comparison on your decoder, using three paired seeds and a fixed held-out slice. On CPU, shorten context and the common token budget for every arm equally.

You're done when

The boundary cases pass, and your branch ledger accounts for all consumed tokens, successful updates and shared versus marginal cost, with held-out outcomes and seed spread for the small comparisons.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 16 more in the section

Also in this section

  • OLMo-core and Official Training ScriptsAllen Institute for AI · primary

    Trace src/examples/llm/train.py through nn/transformer/, optim/, train/train_module/, train/trainer.py and train/callbacks/checkpointer.py. Note what Trainer.state_dict saves (loader, RNG and callback state) and how the data loader checks its fingerprint. The CPU integration test test_train_small_model_cpu needs 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-checkpoint and 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.py and model.py at 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 runs max_iters + 1 updates. 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.md and training/instabilities/training-loss-patterns.md (spike types, resume and data-sampler spikes), training/checkpoints/README.md, debug/underflow_overflow.md and training/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.

  • 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.

  • Modern LLM Notebook - Training and AccountingWalking Labs · support

    Use notebooks-en/part2-training/10-training-loss.ipynb and the appendix notebooks B-flops-memory-accounting.ipynb and C-mixed-precision-training.ipynb for 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, schedule and memory capture. Use with PyTorch 2.14.1.

  • Python - Atomic Replacement and File SynchronizationPython Software Foundation · reference

    Read os.replace and os.fsync for the local single-file publication extension. Atomic visibility is not a power-loss durability guarantee. Page read 2026-10-16.