Unit 7 of 10 · about 6 hours · implement
A bounded, tested change to a real training or post-training implementation
The contribution is a tested change in an actual execution path, not another standalone objective demo. Its boundary must be small enough that the experiment can identify what changed.
You'll be able to
- Modify one bounded mechanism in a real trainer without rewriting the surrounding pipeline.
- Check unchanged behavior against an independent frozen-batch oracle and changed behavior against a failing regression.
- Preserve numerical, resume and failure evidence for the modified path.
Covers
Read
In this order, only the parts listed
0 of 3 done
- nanoGPT: a CPU-sized real-code fallbacknanoGPT and TRL as Modifiable Code
Configuration overrides,
get_batch,estimate_loss, resume branch, checkpoint dictionary and training loopUse this deprecated but pinned implementation if Open Instruct is too heavy. Read
model.pyat the same revision forGPT.forwardand optimizer construction. Run tiny CPU fixtures with PyTorch 2.14.1 and NumPy 2.5.4; keep compilation, hosted logging and uploads disabled. Stock checkpoints omit RNG and scaler state and are not atomically published. - Open Instruct: inspect what existing tests actually assertOpen Instruct
TestMaskLabels:test_has_both_masked_and_kept_tokensandtest_boundary_maskingRead these assertions beside
mask_labels. They check presence of masked/kept tokens and selected prefix boundaries, not every label or an optimizer update. Do not download their default tokenizer merely to copy the test pattern. - Laboratory: correctness before extensionLLM Post-Training Laboratory
Correctness requirements, Milestone D and Milestone F
Focus on
- Choose one seam in the traced implementation: sampler isolation, mask validation, loss reduction or artifact acceptance. State the intended invariant and the smallest counterexample before editing.
- A concrete nanoGPT option is separating training and evaluation sampling RNGs. Its stock
get_batchuses the global torch RNG for both; changing evaluation frequency can change subsequent training batches even without an update. - Use an independent oracle for labels, loss or state, not a second call to the patched helper. Compare logits, loss, gradients and an update on the same frozen batch with declared tolerances.
- Reuse earlier resume and regression work. Save any newly introduced RNG or sampler state, reject incompatible old state explicitly, and keep the baseline revision available. Do not bundle unrelated performance changes into the patch.
Common mistakes · 3
- Calling a smoke test an independent oracle. Merely executing the new branch does not check its semantics.
- Saving a new generator's seed but not its current state. A seed restarts its stream rather than continuing it.
- Assuming the stock nanoGPT iteration cap counts updates as its name suggests. Inspect the post-update termination check and record actual completed updates in your comparison.
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.Why can evaluation change training even when it performs no backward pass?Answer
It can consume a shared RNG stream or mutate mode, buffers or other state. In this sampling example the validation draw advances the RNG used for later training positions.
2.What should the RNG-isolation patch preserve on an identical frozen batch?Answer
The model's forward, objective, gradients and optimizer update within the declared numerical contract. The patch changes sampling ownership, not the objective.
3.The new regression passes before the patch too. What is missing?Answer
It has not demonstrated sensitivity to the defect. Construct a counterexample or inject the old behavior and require the test to fail.
You're done when
The regression fails on the baseline and passes on the patch, unchanged frozen-batch behavior matches its oracle, and resumed execution preserves the new state contract.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 8 more in the section
- LLM Post-Training LaboratoryRoadmap-Final · primary
Complete the project through its baseline, SFT, preference or reward, RL or reasoning, evaluation, failure campaign, reproduction and extension gates. Keep one versioned artifact chain across the whole track.
- Open InstructAllen Institute for AI · required
Read one recipe path (
open_instruct/finetune.py,dpo.pyorgrpo_fast.py) with its tests and the chat-template and label-masking code indataset_transformation.py. Make a bounded tested change on a small model or fixture. Its native evaluations are unmaintained and its single-GPU smoke launcher needs Beaker, so evaluate with a separately pinned evaluator. - nanoGPT and TRL as Modifiable CodeAndrej Karpathy; Hugging Face · support
If OLMo-core or Open Instruct is too heavy for your machine, make the bounded tested change in nanoGPT (commit 3adf61e) or in a TRL 1.15.0 trainer or collator instead, with a frozen-batch oracle before and after.
Also in this section
- OLMo Fully Open Training StackAllen Institute for AI · required
Read Section 6 (clusters, Beaker, stability and operations, hardware utilization, environmental cost) and the evaluation appendices, then trace one released configuration from data and tokenizer through OLMo-core training code, checkpoints and evaluation. Reconstruct only the paths your modification touches and record what was measured versus inferred.
- CS336 Assignments 4 and 5 - Integration HandoffStanford University · support
Reuse the data and alignment artifacts already completed. Connect their versions through a single manifest and rerun one clean baseline before the extension.
- RLHF Book Companion CodeNathan Lambert · support
Use one complete module path (for example
direct_alignment/orpolicy_gradients/) as the small reference implementation, with model, context and sample sizes cut to fit your GPU. Trace one objective end to end, add resume and regression coverage, then compare the modified and unchanged paths. - The Turing Way - Reproducible ResearchThe Turing Way Community · support
Use the chapters on reproducible environments, testing, code review, research data management and research compendia (under
book.the-turing-way.org/reproducible-research/) to package the final artifact for an independent clean run. - NeurIPS Paper ChecklistNeurIPS · support
Answer Q1 (claims), Q4 to Q8 (reproducibility, code and data, settings, uncertainty, compute including failed runs) and Q11 to Q13 where you share artifacts, as the claim and evidence contract for the final report. Skip the submission rules.
- Tulu 3, Section 8.2 (Insights from the Unfruitful)Allen Institute for AI · support
Read Section 8.2 for how a team reports what did not work, then write your own negative results the same way.
- How to Scale Your ModelJAX ML Team · depth
Use the roofline, sharding, training, transformers, profiling and GPU parts (
/scaling-book/roofline,/sharding,/training,/transformers,/profiling,/gpus) only to defend the analytical distributed plan. Measured multi-device work belongs to the ML Systems track. - Machine Learning Engineering - Fault Tolerance and ReproducibilityStas Bekman · reference
Use
training/fault-tolerance/,training/reproducibility/README.mdandtraining/emulate-multi-node.mdfor the vocabulary of the analytical failure and retry plan.