Module 9. Pretraining: Data, Scaling Laws, and Optimizers
Try each exercise first. Expand worked answers or project guidance when needed; their open state is shared between RU/EN.
Download course files (.zip) 2588.1 KBThe archive preserves the source folder structure, both languages, and supporting files.
E1. Loss gap at a fixed training budget
Under the fitted law used in this module, evaluate the 8.03B-parameter, 15T-token scenario. Compare it with the analytic optimum at the same compute budget.
Show answer and solution
Solution. The budget is
The scenario gives
The fitted optimum is
with
Therefore
The difference uses unrounded loss values. This is arithmetic inside the stated approximation, not a claim about the realized quality of a particular 8B or 36B model. The notebook reproduces the calculation in “1. Scaling law and the exact compute-optimal split.”
E2. Inference-aware break-even
The 8.03B model from E1 used training FLOP. A 70B model reaches the same fitted loss with less training. If dense decoding costs approximately FLOP per generated token, find the lifetime output volume at which the smaller model becomes cheaper in total compute.
Show answer and solution
Solution. Solving
gives
and
The large model saves
in pretraining, while each generated token costs an extra
Thus
Below that volume, the 70B alternative wins in this simplified total-compute objective; above it, the smaller model does. See “2. Equal-quality break-even and a training-time scenario.”
E3. Training-state memory and the 1F1B bubble
Assume 16 bytes per parameter for a 7B model, 64 ranks, and ideal ZeRO-3. Then compute the pipeline bubble for eight stages with 32 and 128 microbatches.
Show answer and solution
Solution. The fully replicated state is
Ideal ZeRO-3 over 64 ranks gives
For the pipeline,
and
At least 134 microbatches are required to fall strictly below 5% under this formula. The notebook contains the full tables and negative tests.
E4 [project]
Start with the eight synthetic documents in Demo 1. Explain every retention or rejection decision and report survival relative both to the initial pool and to each stage’s input. Change the filter order and similarity threshold, then distinguish changes in rejection attribution from changes in the retained set. Language and quality labels are supplied. An optional extension uses a small pinned, licensed external sample with actual classifiers and timings; a 100 GB download is unnecessary.
Project demos and guidance
Project demo: English Module 9 project-demo notebook, section “Demo 1.” It supplies the starting experiment; the exercise asks you to change its conditions and explain the outcome.
E5 [project]
Run the CPU mechanism in Demo 2: gather a matrix from two owned shards, average equal-sized local-batch gradients, and update each shard. Check parity with an unsharded update over several steps. Separately tabulate a hypothetical 1B model under ZeRO stages 0–3 at 1, 2, and 8 ranks using the 16-byte policy. Add a specified gather buffer and activation reserve. Explain why total peak memory no longer scales as one number divided by rank count. No distributed runtime is required.
Project demos and guidance
Project demo: English Module 9 project-demo notebook, section “Demo 2.” It supplies the matrix experiment and a separate hypothetical memory ledger.