Lecture 9 · Introduction to Pre-Training

Scalable AI: Bridging Theory, Understanding, and Practice · Lecture 09。个人学习讲义与配套实验,按主题整理并持续修订。

课程源码 ZIP ↓

个人整理的学习笔记,非官方讲义;课程来源与整理说明见课程介绍。配套示例未逐一运行验证。

本篇目录

Maps to: UC Berkeley EE 290/194 Scalable AI, Fall 2026 Lecture 8, Introduction to Pre-Training: objective, compute budgets, and training stability (slides lecture8.pdf), with material from Spring 2026 Lecture 6, Introduction to Pre-Training (the two loops, KPIs, FP8 formats, the stability dashboard). Recommended reading (as cited on the slides): the Llama 3 paper (arXiv:2407.21783) §3; OLMo 2 (arXiv:2501.00656) §3; the Marin 8B and 32B retrospectives; the Nemotron 3 Ultra report (arXiv:2606.15007) §2; Yang et al., Tensor Programs V (µP, arXiv:2203.03466); OLMES (arXiv:2406.08446). Code: code/lecture09/ contains three shared modules and eight demos. atlas_world.py is a toy “web” whose probabilities are known exactly. bpe.py is a byte-level BPE tokenizer. pretrain.py is a training stack with full telemetry. Every number labelled measured comes from these scripts on the author’s laptop (Apple M4 Pro, CPU). Every number labelled reported is the slides’ own. Reading time: ~2.5 hours for the prose; ~8 minutes to run all demos.


0. How to read this lecture

0.1 Learning goals

After this lecture you should be able to:

  1. State the objective. Write the causal language-modelling loss, explain why it needs no labels, and convert between loss per token, perplexity and bits per byte. Say why only the last of these compares models with different tokenizers.
  2. Read a training step. Account for tokens per step (R×B×L×AR \times B \times L \times A). Explain the learning-rate schedule, the optimizer settings, packing and mixed precision, and why each value is stored in the format it is.
  3. Plan a run in time and money. Go from 6NNtok6N N_{tok}, MFU and goodput to days and GPU-hours, as in the Llama 3 405B worked example. Choose a checkpoint interval from the failure rate.
  4. Keep a run healthy. Know which signals to log. Tell a data spike from a divergence. Know which recipe changes (QK-norm, z-loss, initialization, ε, data filters) address which instability.
  5. Plan with small runs. Explain how µP makes a small model’s learning rate transfer to a large one. Show how a ladder of small runs, fitted with a scaling law, predicts the loss of the final run before it starts.

0.2 Prerequisites and scope

  • Prerequisites: Lecture 1 (the Transformer as a graph, 6N6N FLOPs, Chinchilla, fleet goodput); Lecture 3 (MFU); Lecture 5 (data parallelism, gradient accumulation); Lecture 8 (what a checkpoint must hold).
  • Scope: the CLM objective and tokenization; the training step (batch, schedule, optimizer set-up, packing, number formats); compute and throughput; failures, monitoring and evaluation; loss spikes; planning with small runs (µP, ladders, loss prediction).
  • Not in scope today: where the data comes from (Lecture 10) and synthetic data (Lecture 11); why Adam and the schedules work (Lecture 12); Muon and other modern optimizers (Lecture 13); running the fleet itself (Lecture 14).

0.3 Section → code map

SectionIdeaCode in code/lecture09/
§1Atlas World: a corpus with a known flooratlas_world.py
§2the objective, perplexity, tokenizers, bits per bytebpe.py, 01_objective_and_bpb.py
§3a training step, loggedpretrain.py, 02_training_run_telemetry.py
§3.4packing, the document mask, silent label bugs03_packing_and_silent_bugs.py
§3.5number formats and mixed precision04_number_formats.py
§4FLOPs, MFU, goodput, failures, checkpoint interval, benchmark noise05_compute_and_kpis.py
§5spikes and divergence; QK-norm and z-loss06_spikes_and_stability.py
§6.2µP: learning rates that transfer across width07_mup_transfer.py
§6.3a ladder, a scaling-law fit, a pre-registered prediction08_ladder_prediction.py

0.4 Notation

  • NN = parameters (for an MoE, the active parameters per token); NtokN_{tok} = training tokens.
  • VV = vocabulary size; LL = sequence length; BB = micro-batch (sequences); AA = accumulation steps; RR = data-parallel replicas.
  • Losses are in nats (natural log) unless marked bits.
  • BPB = bits per byte. Floor = the entropy of the data source, the lowest loss any model can reach.
  • MFU and goodput are as defined in Lectures 1 and 3.

1. Why pre-training is an engineering problem, and the toy world we will use

1.1 Where pre-training sits

A modern model is trained in three stages. The Olmo 3 32B Think accounting on the slides gives the shares of GPU-hours:

StageWhat it isOlmo 3 32B Think (reported)
Pre-training (预训练)next-token prediction on a broad web-scale mixture5.5T tokens, 86% of GPU-hours
Mid-training (中期训练)continued pre-training on higher-quality data while the learning rate decays200B tokens, including long context: 4%
Post-training (后训练)instruction tuning (SFT), preference tuning, RLSFT + DPO 1.6%, RL 7.9%

The split is shifting: Olmo 3.1 ran RL three times longer, to about 16% of compute. Pre-training is still where most of the compute goes, and it is the most expensive to get wrong.

  • Frontier compute has grown about 5× per year since 2020.
  • Llama 3 405B used 30.8M H100-hours, roughly 60–90Mat60–90M at 2–3 per GPU-hour (Epoch AI’s estimate, quoted on the slides).

A run of this size cannot be repeated casually. So every decision is made in advance, with small experiments, and the run is watched closely.

The Spring slides put this as two loops you iterate on together:

  1. The systems loop (speed): step time, tokens/s, MFU, communication overlap, I/O.
  2. The learning loop (correctness): loss, gradients, numerics and data health; catch divergence or silent corruption early.

Their north star: maximize useful tokens per day, subject to stable learning. High throughput with unstable training “is just producing garbage faster”. Part I of the course was mostly the systems loop. This lecture adds the learning loop.

1.2 A world whose answer we know

On real web text, nobody knows the true probability of a document. A validation loss of 2.1 nats/token cannot be split into “what the model has yet to learn” and “what nobody can predict”. This lecture’s code therefore trains on Atlas World (atlas_world.py), a toy web in which every document comes from a known random process. AtlasWorld.logprob(text) recomputes any document’s exact probability. There are four domains, mixed 55/15/15/15 by default:

DomainExampleWhat makes it hard
storythe calm boat drifts near a reef . a old man sees the tide .a latent topic (sea, market, sky, machine) chosen per document; content words depend on it, so the model must infer it from context
wikithe same prose, but 40% of sentences are facts: the capital of velmora is ostrin .100 invented countries × 4 relations; countries are mentioned with Zipf frequency, so a few facts are common and most are rare
math12 + 7 = 19 . 30 - 4 = 26 .operands are random (unpredictable); the result is determined (learnable arithmetic)
codelet x = 4 ; let y = x + 3 ; y is 7 ;values must be tracked through the document: a long-range, in-context dependency

Every word belongs to exactly one category, and the domain is fixed by the first word. Each text therefore has a single derivation given its latent domain and topic, and logprob sums those two out exactly. The self-test re-parses 1,200 generated documents and checks the parser against the generator.

Three things follow, and the rest of Part II uses all three:

  • The floor (不可约损失) is known, per domain and in bits per byte. On the natural mix it is 0.719 bits/byte: story 0.749, wiki 0.627, math 0.895, code 0.575 (exact, demo 01).
  • A model’s excess loss = its loss minus the floor. It measures what is still learnable, comparably across domains and tokenizers.
  • Lecture 10’s filters, Lecture 11’s synthetic data and Lecture 12’s optimizers can be scored against the truth rather than against another model.

2. The objective, perplexity and tokenization

2.1 Causal language modelling

A language model factorizes the probability of a sequence autoregressively (自回归分解):

pθ(x1:L)=∏t=1Lpθ(xt∣x<t),p_\theta(x_{1:L}) = \prod_{t=1}^{L} p_\theta(x_t \mid x_{<t}),

and is trained by maximum likelihood, i.e. by minimizing the average cross-entropy (交叉熵) over all training tokens:

L(θ)=−1Ntok∑x1:L∼D∑t=1Llog⁡pθ(xt∣x<t).\mathcal{L}(\theta) = -\frac{1}{N_{tok}} \sum_{x_{1:L} \sim \mathcal{D}} \sum_{t=1}^{L} \log p_\theta(x_t \mid x_{<t}).

Why this is called “self-supervised” but is really supervised. Training pairs are (prefix, next token): every token is the label for the prefix before it. No annotation is needed, so the training set is as large as the text you can collect and filter. Everything you know about supervised learning still applies: label noise, distribution shift, data quality, instrumentation. The labels are just free.

Why one forward pass is enough. With a causal mask, position tt sees only tokens ≤t\le t. So one pass over a sequence of length LL produces all L−1L-1 predictions at once, and the labels are simply the input shifted left by one (demo 01, Part A, shows this on a real code document). This is also why a label-shift bug is so damaging (§3.4).

The Spring slides contrast CLM with masked language modelling (MLM, BERT-style). MLM predicts masked tokens from both sides. It is good for representations but does not generate left to right. GPT-style stacks use CLM because generation then follows directly from training.

2.2 Cross-entropy, perplexity and the floor

Per-token loss ℓt=−log⁡pθ(xt∣x<t)\ell_t = -\log p_\theta(x_t \mid x_{<t}); perplexity (困惑度) PPL=exp⁡(1Ntok∑tℓt)\text{PPL} = \exp\big(\frac{1}{N_{tok}}\sum_t \ell_t\big).

Intuitively, perplexity is the effective number of equally likely next tokens:

  • A uniform guess over a 128K vocabulary has loss ln⁡128,000≈11.8\ln 128{,}000 \approx 11.8 and PPL 128K.
  • A loss of 2.0 has PPL ≈ 7.4: as uncertain as a uniform choice among about 7 tokens.
  • In demo 01, an untrained model over V=512V = 512 starts at ln⁡512=6.24\ln 512 = 6.24 nats.

That number is the first sanity check of every run. Every run in demo 03 starts between 6.22 and 6.25.

How low can the loss go? Not to zero. Text has genuine uncertainty, and the minimum achievable cross-entropy is the entropy of the source. Atlas World tells us this floor exactly (demo 01, Part B):

domainfloor (bits/byte)floor (nats/token, V=512V=512)PPL at the floor
story0.7491.9006.69
wiki0.6271.2733.57
math0.8951.0532.87
code0.5750.8862.42

Math has the highest floor per byte because its operands are random digits; only the results are predictable. A model at 0.90 bits/byte on math may be perfect, or it may not have learned to add. Without the floor you cannot tell.

2.3 Tokenization

A tokenizer (分词器) maps text to a sequence of ids from a vocabulary of size VV. It decides how many tokens each document becomes, and therefore the compute per document. It decides how each language or domain is split (code whitespace, digits, rare scripts). And its vocabulary sets the size of the embedding and output layers. Most models use byte-level BPE (字节级 BPE), and they tokenize once, offline, so it costs nothing in the training loop.

bpe.py implements byte-level BPE from scratch:

  1. Start from the 256 bytes, so any text can be encoded.
  2. Repeatedly merge the most frequent adjacent pair into a new token.
  3. Never merge across a pre-tokenization boundary (“space + word”, or a newline).

The newline, which separates documents in the training stream, therefore stays token 10. Demo 01 Part C shows the trade-off on a width-64 model:

VVbytes per tokentokens per documentparametersembedding + output share
256 (bytes)1.00319127 K26%
5123.2399160 K41%
1,0244.2974226 K58%
1,4544.3374281 K66%

The last row is instructive. Asking BPE for 2,048 tokens stopped at 1,454: by then every word of this small world is a single token, and extra merges have nothing left to join. Real text never saturates like this. That is why Llama 3 could go from 32K to 128K tokens and still gain compression: 3.17 → 3.94 English characters per token, so the same text needs about 80% of the tokens (reported). The cost is a larger embedding and output layer. At 405B parameters that cost is small; at 160K parameters (our toy) it is most of the model.

2.4 Loss per token is not comparable across tokenizers; bits per byte is

Demo 01 Part D trains the same model for the same 400 steps with V=256V = 256 (bytes) and V=1,024V = 1{,}024:

VVval loss (nats/token)val bits/bytefloorexcessbytes trained on
2560.7861.1340.7190.415410 K
1,0242.3210.7820.7190.0631.76 M

Per token, the byte model looks 3× better, because each of its tokens is a single easy byte. Per byte, the order flips. The V=1,024V = 1{,}024 model also read 4.3× more text in the same steps. Hence the slide’s rule: loss values are only comparable with the same tokenizer and evaluation data. The tokenizer-free measure is bits per byte (每字节比特数):

BPB=NtokNbytes⋅ℓˉln⁡2,\text{BPB} = \frac{N_{tok}}{N_{bytes}} \cdot \frac{\bar\ell}{\ln 2},

where ℓˉ\bar\ell is the mean loss per token in nats. For example, loss 2.0 at 3.94 bytes/token (Llama 3, English) is 2.0/(3.94×0.693)≈0.732.0/(3.94 \times 0.693) \approx 0.73 bits/byte (demo 05). Paloma and OLMo 2 report per-domain validation loss this way.


3. The training step

3.1 The loop

The slides’ loop is short:

for step, batch in enumerate(dataloader):
    logits = model(batch["input_ids"])                   # [B, L, |V|]
    loss = cross_entropy(logits, batch["labels"], ignore_index=PAD)   # labels = inputs shifted by 1
    loss.backward()
    clip_grad_norm_(model.parameters(), max_norm=1.0)
    optimizer.step(); scheduler.step(); optimizer.zero_grad(set_to_none=True)
    if step % ckpt_every == 0:
        save_checkpoint(model, optimizer, scheduler, dataloader, step)

At scale the same loop adds gradient accumulation and collectives (Lecture 5), mixed precision (§3.5), activation checkpointing, checkpoint I/O (Lecture 8) and evaluation. pretrain.train_run is this loop with the telemetry a real run logs (§5.1). Its model is Lecture 1’s TinyTransformer, run by lm_logits, which adds a document mask, QK-norm, µP and monitoring hooks.

3.2 Tokens per step and the batch size

Btok=R⏟DP replicas×B×L⏟micro-batch×A⏟accumulation,tokens/s=BtokTstep.B_{tok} = \underbrace{R}_{\text{DP replicas}} \times \underbrace{B \times L}_{\text{micro-batch}} \times \underbrace{A}_{\text{accumulation}}, \qquad \text{tokens/s} = \frac{B_{tok}}{T_{step}}.

The batch size is a trade-off between the hardware and optimization:

  • Gradient accumulation raises BtokB_{tok} without more activation memory (Lecture 5).
  • Larger batches use the hardware better: fewer optimizer steps and less communication per token.
  • Past the critical batch size (临界批大小), more tokens per step give little extra progress, so tokens are wasted. The critical batch size grows as the loss falls, so runs start small and ramp up. Llama 3 405B went 4M → 8M → 16M tokens per step, with small batches early “to improve training stability” (reported).
  • Batch size and learning rate interact: change one and retune the other. Lecture 12 measures the critical batch size on a tiny LM.

Demo 02’s run is 1×16×64×1=1,0241 \times 16 \times 64 \times 1 = 1{,}024 tokens per step.

3.3 The learning-rate schedule and the optimizer set-up

Warm-up (预热) avoids large updates while the weights are poorly scaled; Llama 3 405B warmed up for 8,000 steps. Then the rate decays, in one of two shapes:

  • Cosine (余弦退火) decays over a fixed horizon (Llama 3). You must know the run’s length in advance.
  • WSD (warm-up, stable, decay; 预热-稳定-衰减) holds the rate constant, then decays it at the end. The decay phase is often called the cooldown (冷却期). Marin 8B and Nemotron 3 Ultra use it.

WSD lets you choose when to stop. Nemotron started its decay early, after a divergence (§5.4). Lecture 12 runs both schedules side by side.

The slides’ common AdamW settings: β1,β2=0.9,0.95\beta_1, \beta_2 = 0.9, 0.95; ϵ=10−8\epsilon = 10^{-8}; weight decay 0.1, not on embeddings; gradient clipping at 1.0; the peak learning rate tuned, because it depends on width. pretrain.make_optimizer follows this: decay only on 2-D matrices of attention, MLP and head, and none on embeddings or norms.

The key warning: many of the instabilities in §5 come from optimizer and parametrization settings (learning rate, ε, weight decay, initialization). These are far cheaper to get right before the run than to fix during it. OLMo 2 removed most of its spikes by changing exactly these. With the standard parametrization, a rate tuned on a small model is too large for the full model; µP fixes that (§6.2).

3.4 Sequence packing, the document mask, and silent label bugs

Packing (序列打包):

  • What it does. Documents are concatenated, separated by an end-of-document token, and cut into rows of exactly LL tokens.
  • Why it helps. No compute is spent on padding, and every batch has the same shape.
  • How much it saves. Atlas World’s documents are short and uneven (median 72 tokens; 10th–90th percentile 24–221). Padding to L=64L = 64 uses only 80.4% of the slots and still truncates 48.0% of the tokens of long documents. At L=256L = 256 it uses 36.3% (demo 03, measured).
  • Training cost of padding. In the same 400 steps, the packed run trained on 1.2× the real tokens and reached 0.795 bits/byte; the padded run reached 0.895.

The document mask (文档掩码) keeps attention inside one document of a packed row. Llama 3 found it mattered little in standard pre-training but helped for long-context training. Demo 03 measures it both ways:

evaluated without maskevaluated with mask
trained without mask0.7950.801
trained with the document mask0.8490.794

Evaluated the way each was trained, the mask changes nothing that matters (0.795 vs 0.794). Atlas World’s documents are independent, so cross-document attention is noise the model learns to ignore. The off-diagonal cell is the lesson. My first version of the demo evaluated every model without a mask and reported the masked model as 0.054 bits/byte worse. A train/eval mismatch looks exactly like a worse recipe. Evaluate the way you train.

Silent label bugs. These cost the most because nothing crashes (demo 03 Part D, 150 steps each):

pipelinetrain loss (last 20 steps)val bits/bytewhat it looks like
correct2.1880.962
labels not shifted (labels = inputs)0.0234.563“great” training loss, below the source entropy (1.585 nats/token)
labels shifted twice3.2842.309just a weak model
padding not ignored1.7261.081better training loss, worse model

Each has a cheap pre-launch test:

  • The step-1 loss must be ln⁡V\ln V.
  • A hand-inspected batch must show labels = inputs shifted by one.
  • The loss must be averaged over real tokens only, and those tokens counted.
  • A training loss far below any plausible value is a bug, not a breakthrough.

The slides’ checklist lists “tests for tokenization, packing, and label shift” first among the essentials.

3.5 Number formats and mixed precision

Formats. Fewer bits per value give more tensor-core throughput and more rounding error. On an H100 (dense): BF16 989 TFLOP/s, FP8 1,979 TFLOP/s. Exponent bits set the range; mantissa bits set the precision. Demo 04 recomputes the slide’s table by real rounding in PyTorch, and every entry matches:

formatexp. bitsmant. bitslargeststep near 10.3952 stored as
FP328233.4e381.2e-70.39520
BF16873.4e387.8e-30.39453
FP1651065,5049.8e-40.39526
FP8 E4M3434480.1250.40625
FP8 E5M25257,3440.250.375
FP4 E2M12160.50.5

Mixed precision (混合精度): each value gets the lowest precision it can tolerate.

  • BF16, where speed comes from: inputs to matrix multiplies; activations saved for backward.
  • FP32, where errors accumulate: accumulation inside each GEMM; master weights, Adam moments and the update; softmax, normalization and the loss; gradient accumulation and reductions.

Demo 04 shows why each FP32 item is there:

  • Master weights. Near 1.0, consecutive BF16 values are 2−7≈0.0082^{-7} \approx 0.008 apart, so 1.0+0.001=1.01.0 + 0.001 = 1.0. Typical updates change a weight by 10−410^{-4}–10−310^{-3} of its value. With weights stored in BF16, 9.1% of matrix entries were unchanged by the step-50 update, and 67.2% by the step-400 update, after the learning rate had decayed. The model ended at 0.810 vs 0.795 bits/byte.
  • Reductions. Adding 16,384 terms of about 0.001 one at a time: FP32 is exact to 0.000%; a BF16 accumulator is off by 94%. Once the running sum is large, each new term is below half a step and is dropped. Two reported cases: Llama 3’s loss differed across parallelism layouts until gradient accumulation and reduce-scatter ran in FP32, and Nemotron 3 Ultra diverged when it moved one reduction to BF16 (§5.4).
  • Range and loss scaling. With a mean-reduced loss, logit gradients shrink with the number of tokens per step. At 1M tokens per step, 99.8% of the nonzero entries underflow to 0 in FP16. A loss scale of 2162^{16} restores them all. BF16 loses none without any scaling, because it shares FP32’s exponent. This is why BF16 replaced FP16 and its loss scaling.

Scaling low-precision values. For FP8 and FP4, xlow=round(x/s)x_{low} = \text{round}(x/s) and x^=s xlow\hat x = s\, x_{low}: a scale ss maps a group of values onto the format’s small range.

schemevaluesvalues per scalescale format
FP8 per tensor (Hopper; Transformer Engine with delayed scaling from an amax history)E4M3 / E5M2 (“HYBRID”: E4M3 forward, E5M2 backward)whole tensorFP32
MXFP8 (Blackwell)E4M3 / E5M232power of two
NVFP4 (Blackwell)E2M116E4M3, plus one FP32 scale per tensor

An outlier sets the scale for every value that shares it (demo 04 Part E, 4 outliers among 4,096 values):

  • FP4, per-tensor scale. FP4 has only 2 exponent bits, so 60× outliers push the ordinary values off the grid: 0.97 relative error, with 98.7% of ordinary values rounded to 0.
  • NVFP4. With 16-value blocks, each with its own scale, the error is 0.11 (0.13 with 3,000× outliers).
  • FP8 E4M3. Its 4 exponent bits absorb even 3,000× outliers in RMS terms (0.027 error, set by the 3 mantissa bits), though 0.7% of the ordinary values do flush to 0 per tensor (0% with MXFP8).

So blocks are insurance for FP8 and indispensable for FP4. That is why Nemotron 3 Ultra could pre-train in NVFP4 on 20T tokens, keeping the last 15% of layers, attention projections and embeddings in higher precision, with its loss within 0.4% of BF16 runs branched from its checkpoints (reported).


4. Compute and throughput

4.1 FLOPs per token and time to train

For a dense Transformer, training costs ≈6NNtok\approx 6 N N_{tok} FLOPs: about 2N2N per token forward and 4N4N backward (Lecture 1). For an MoE, use the active parameters. Demo 05 checks the rule against reported totals:

  • Llama 3 405B: 6×405B×15.6T=3.79×10256 \times 405\text{B} \times 15.6\text{T} = 3.79 \times 10^{25} (reported 3.8×10253.8 \times 10^{25}).
  • Nemotron 3 Ultra: 6×55B×20T=6.6×10246 \times 55\text{B} \times 20\text{T} = 6.6 \times 10^{24}.

The rule undercounts long-context attention and activation recomputation. It is a planning number, not a measurement.

Time to train depends on how fast the cluster turns FLOPs into tokens:

tokens/s/GPU≈MFU⋅Cpeak6N,tokens/day≈G⋅goodput⋅MFU⋅Cpeak6N⋅86,400.\text{tokens/s/GPU} \approx \frac{\text{MFU} \cdot C_{peak}}{6N}, \qquad \text{tokens/day} \approx G \cdot \text{goodput} \cdot \frac{\text{MFU} \cdot C_{peak}}{6N} \cdot 86{,}400.

Goodput (有效训练时间占比) is the fraction of wall-clock time spent training. It is lost to data-loader stalls, checkpoint writes, evaluation, failures and restarts, and scheduling. As the Spring slides put it, “MFU tells you how fast you go when you are driving. Goodput tells you how often you are actually driving.”

4.2 Worked example: Llama 3 405B

From the reported numbers (16,384 H100s, 400 TFLOP/s per GPU, 15.6T tokens), demo 05 computes:

quantitycomputedslide
MFU400 / 989.4 = 40.4%38–43%
tokens/s16,384×400×1012/(6×405×109)=2.70×10616{,}384 \times 400 \times 10^{12} / (6 \times 405 \times 10^9) = 2.70 \times 10^62.7e6
time66.9 days≈ 67 days
GPU-hours26.3 M≈ 26 M
share of the reported 30.84 M GPU-hours that became model FLOPs85.4%≈ 85%

The other 15% is goodput loss and slower phases such as long-context training. One point of goodput (90% → 91%) is worth 0.8 days of 16,384 H100s on this run. Reliability work pays in the same currency as kernel work.

4.3 KPIs and triage

KPIs (关键绩效指标) are the handful of numbers a pre-training team reports every day:

  • throughput and MFU (the compute rate while running);
  • tokens/day (progress toward the target);
  • goodput;
  • failures per day and MTBF;
  • validation loss against the prediction from small runs (§6.3);
  • downstream evals;
  • researcher interventions: manual actions needed to keep the run going. The Spring slides call this “the real cost metric”.

Teams define these differently: write down the exact computation, especially for goodput.

When tokens/day drops, decompose it as tokens/day≈throughputrun×86,400×goodput\text{tokens/day} \approx \text{throughput}_{run} \times 86{,}400 \times \text{goodput}, and ask which factor moved:

  • Throughput dropped: a kernel or shape change, lost communication overlap, stragglers, slow data loading, a precision change.
  • Goodput dropped: more failures, slower restarts, slower checkpoints, preemption.
  • Validation loss off trend: an evaluation bug, a data-mixture change, a schedule not restored after resume.

First ask what changed: code, data, cluster or schedule.


5. Failures and stability

5.1 Three ways a run fails

the job stopsthe loss divergesnothing looks wrong
causesGPU, memory, network, software faultslearning rate, numerics, norm growth, bad datapacking, masking or label-shift bugs; wrong mixture; data repeated after a resume; silent data corruption
noticedimmediatelyfrom loss, gradient norm, auxiliary losses; can take hoursonly in evals and per-domain loss, sometimes after the run ends
recoveryrestart from the last checkpoint, usually automaticallyroll back, change something, continuefind the bug, then roll back to before it or restart

Silent failures cost the most because they are found late. Tests before launch (§3.4) and evals during the run catch them.

Signals to log, the slides’ minimal dashboard, all on the same step axis:

  • Optimization: training loss (raw and smoothed); validation loss per domain; downstream evals; the learning rate (the actual value, not the configured one); gradient norm; update size ∥Δθ∥\lVert\Delta\theta\rVert; auxiliary losses such as MoE load balancing.
  • Numerics: NaN/Inf checks; activation and logit norms per layer.
  • Data: token statistics (length, language ID); duplication and repetition rates; the source mix of each batch.
  • Systems: step time and tokens/s; data-loader wait; failure and restart events.

Demo 02 runs a 403K-parameter model for 800 steps with this dashboard. What it shows:

  • The logged learning rate equals the schedule at every step. After a resume, a wrong scheduler state shows up here first.
  • Training loss is noisy. Late in the run it moves by 0.115 nats from one step to the next, because every batch differs. Validation bits/byte on a fixed held-out set moves by 0.003 between evaluations. Watch trends on the smoothed or validation curve, and spikes on the raw one.
  • The average hides the structure. After 800 steps, the excess over the floor is +0.011 bits/byte on story but +0.406 on math (+0.151 on code, +0.067 on wiki). Story text is nearly solved. Math and code still hold most of what is learnable: the sums, and tracking values through the document. A regression on one domain could hide behind progress on another. Hence held-out sets per domain, fixed for the whole run. OLMo 2’s training loss rose when its mixture changed while the model improved; a fixed held-out set does not move like that.
  • Gradient norm and updates. The gradient norm starts at 1.56, peaks at 1.70 and ends at 0.42. 12% of steps were clipped at 1.0, all of them in the first fifth of the run. The update norm shrinks with the learning rate: about 8 × 10⁻³ of the weights’ norm per step at the peak.

5.2 Hard failures and the checkpoint interval

Hard failures. In a 54-day window of Llama 3 405B pre-training there were 419 unexpected interruptions (reported Table 5). The largest causes:

  • faulty GPU: 148
  • GPU HBM3 memory: 72
  • software bugs: 54
  • network switches and cables: 35
  • unplanned host maintenance: 32
  • silent data corruption: 6

About 78% were confirmed hardware issues. Demo 05 turns the table into rates:

  • one interruption every 3.09 hours;
  • per-GPU MTBF ≈ 16,384×3.09≈50,70016{,}384 \times 3.09 \approx 50{,}700 GPU-hours, which is excellent hardware;
  • yet at 100,000 GPUs, still a failure every 30 minutes.

Automation kept goodput above 90%, and only 3 interruptions needed significant manual intervention (reported).

The checkpoint interval. Let failures come every τ\tau hours, let a checkpoint block training for δ\delta, and checkpoint every Δ\Delta. The overhead is

overhead≈δΔ⏟writing+Δ2τ⏟lost work  ⇒  Δ⋆≈2δτ\text{overhead} \approx \underbrace{\frac{\delta}{\Delta}}_{\text{writing}} + \underbrace{\frac{\Delta}{2\tau}}_{\text{lost work}} \;\Rightarrow\; \Delta^\star \approx \sqrt{2\delta\tau}

(Young’s formula, Lecture 1). With τ=3\tau = 3 h and δ=1\delta = 1 min: Δ⋆=19.0\Delta^\star = 19.0 min and an overhead of 10.5%. With τ=0.5\tau = 0.5 h and δ=5\delta = 5 min, the overhead is 57.7%, and the job barely makes progress. Asynchronous checkpointing shrinks δ\delta, and with it both terms.

A checkpoint holds the FP32 master weights, the optimizer state, the learning-rate scheduler state, the data-loader position and the RNG states (Lecture 8). For 405B parameters that is 12 bytes/param = 4.86 TB of state alone.

5.3 Gradient norms, spikes and the spike score

∥g∥2=∥∇θL∥2\lVert g\rVert_2 = \lVert\nabla_\theta \mathcal{L}\rVert_2, logged before clipping, globally and per parameter group (attention, MLP, embeddings, output). For a fixed recipe, a stable run keeps it in a characteristic range. What to watch:

  • sudden spikes, which often come before loss spikes;
  • drops to 0: underflow or a communication bug;
  • slow growth over the run, which preceded divergence in OLMo-0424.

OLMo 2’s spike score: the percentage of values more than 7σ from the rolling mean of the last 1,000 steps. In OLMo-0424 7B, gradient-norm spikes were more frequent than loss spikes and often came first. The norm grew slowly and the spikes became more frequent. After OLMo 2’s changes both curves were flat.

divergencedata spike
loss rises and does not recoverisolated spike that returns to trend
gradient norm stays high or explodes; NaN/Inf may appeargradient norm returns to its baseline
often follows a learning-rate, precision or code changetied to particular batches or sources
fixes: roll back, lower the LR, undo the change, change the recipefixes: inspect the batch, filter the data, skip the batches if it recurs

Demo 06, measured. A batch of repeated n-grams is the pattern OLMo 2 found at its spikes (“255, 255, 255, …”). Injected at steps 200 and 300, it produces a classic data spike:

  • the gradient norm jumps from 0.68 to 19.0, and the loss from 1.9 to 5.5;
  • both return to trend within a few steps, and the final model is unharmed (0.780 vs 0.780 bits/byte);
  • the spike score flags it at 0.57% of steps, against 0 for the clean run;
  • without clipping the spike’s gradient norm is 21.9, and the run ends at 0.783 (Adam’s normalization absorbed most of it).

OLMo 2’s repetition filter drops documents with ≥ 32 consecutive repeats of an n-gram. It would have caught the batch: the clean corpus never repeats an n-gram more than 3 times in a row, the injected text 100 times.

Data spikes are not deterministic, though. In OLMo 2 the same sequence spiked a larger model but not a smaller one, and only under some data orders. Curated corpora such as Nemotron-CC remove most repetitive text; Marin 8B, trained mostly on DCLM and Nemotron-CC, saw very few spikes.

5.4 Recipe instabilities and their fixes

What OLMo 2 changed. The slides’ table, where each row is a separate ablation against its own baseline:

componentchangegradient spike score
initializationdepth-scaled → N(0,0.02)N(0, 0.02)0.40 → 0.03
normalizationnormalize each sublayer’s output before the residual add; add QK-norm0.108 → 0.069
embeddingsno weight decay on embeddings0.16 → 0.092
AdamW ε10−5→10−810^{-5} \to 10^{-8}lower, steadier gradient norm
output logitsadd z-losskeeps softmax normalizers small

Two of these change the architecture:

  • QK-norm normalizes queries and keys before their dot product, so attention logits stay bounded.
  • z-loss adds a small penalty on (log⁡Z)2(\log Z)^2, where ZZ is the softmax normalizer of the output logits.

Most of these changes stop norms from growing without bound.

Marin across three runs:

  • Marin 8B (Llama architecture, no QK-norm, 12.7T tokens) saw very few spikes.
  • Marin 32B, with the same recipe, spiked frequently. Clipping, skipping steps and optimizer resets failed; switching to QK-norm removed them.
  • Marin 535B MoE (QK-norm and z-loss) has had no spikes so far.

Their explanation was growing attention logits, not the optimizer. The stable 8B run had made QK-norm look unnecessary.

Demo 06 Part B reproduces the mechanism in miniature. At 10× the tuned learning rate:

  • the largest ∣q⋅k∣/d|q \cdot k|/\sqrt{d} in a batch grows from 25 (tuned) to 1,428 by step 400, and the model ends at 0.865 vs 0.780 bits/byte;
  • at 33×, the logits reach 5,476 and the model ends at 1.297;
  • QK-norm bounds the logits at 23 and 28 and recovers most of the loss (0.804 and 0.872);
  • z-loss does not help here (attention logits 1,096, loss 0.861), because it constrains the output normalizer, not attention.

Each stabilizer fixes one specific norm. None of these toy runs diverged outright: the smoothed loss never rose by more than 0.08 nats, because clipping and Adam’s normalization held them. At this scale the instability shows as runaway logits and a worse plateau.

Nemotron 3 Ultra’s two divergences (reported):

  • At 8T tokens. The output layer’s gradient accumulation had been moved from FP32 to BF16 to save communication. The small gradients of the multi-token-prediction (MTP) heads were rounded away; this is demo 04’s “BF16 accumulator ignores small terms”. The MTP-2 loss rose before the main loss. The fix was to roll back and restore FP32.
  • At 16T tokens. No cause was found, and a BF16 rerun also diverged. The fix was to roll back to 15T and start the learning-rate decay early; pre-training ended at 20T. This is the flexibility WSD buys.

When you see a spike, diagnose then recover:

  1. Did the loss return to trend? Record it and continue.
  2. Check the gradient norm, update norm and auxiliary losses.
  3. What changed: code, precision, data, cluster?
  4. Inspect the batches around the spike.

To recover: roll back and skip the batches; lower the learning rate; undo the recent change (Nemotron at 8T); if spikes keep coming, change the recipe (Marin 32B: QK-norm); late in the run, start the decay (Nemotron at 16T). For the next run, most of these fixes are chosen in advance and tested with small runs.

5.5 Evaluating a base model

Validation loss per domain, held out and fixed for the whole run (web, code, math, each language), in bits per byte.

Benchmarks. Scoring formats matter:

  • Multiple choice by log-probability. Score each answer given the question and pick the highest, normalizing by answer length.
  • Cloze vs letter format. Cloze scores the answer text itself. Letter format lists the options and scores “A”–“D”.
  • Generative. GSM8K and HumanEval generate an answer, then check it or run the tests.

Small models are at chance on the letter format; it only starts to work after enough training. Compare small models with the cloze format. HellaSwag, ARC-Easy and PIQA rise above chance early. MMLU (letter format) and GSM8K stay near chance much longer.

Reading the numbers. A benchmark score is a sample, with standard error p(1−p)/n\sqrt{p(1-p)/n}. Demo 05 computes these at 50% accuracy:

  • HellaSwag: 0.5 points;
  • MMLU: 0.4;
  • ARC-Easy: 1.0;
  • PIQA: 1.2;
  • ARC-Challenge: 1.5.

The difference between two models on ARC-Challenge therefore has a 95% band of about ±4.1 points, so a 2-point gap is noise. Average several tasks, or compare validation loss. Shots, prompt format and normalization move scores by several points: fix them and record the configuration. Check for contamination when the data changes (Marin 32B found GSM8K in its cooldown data). And read samples, looking for repetition and broken formatting.


6. Planning with small runs

6.1 Most decisions are made before the run

In Olmo 3, 82% of GPU-hours went to development runs, not the final model (reported). A ladder (模型阶梯) is a set of models of increasing size trained with the same recipe; Llama 3 used 40M to 16B parameters to plan its 405B run.

decisionhow small runs decide it
learning rate, initializationtune on small models; µP makes them transfer (§6.2)
batch sizesweep on small runs; the best size grows with compute
model size, token countfit a scaling law to the ladder (§6.3)
data mixtureablations and anneals (Lecture 10)
stability fixesrun the ladder at the planned learning rate and batch size
expected final lossextrapolate from the ladder; compare against it during the run

6.2 µP: hyperparameters that transfer across width

The problem. With the standard parametrization (SP), the best learning rate shrinks as the model gets wider. A rate tuned on a small model is too large for a wide one: updates grow with width, logits grow, and the loss spikes.

Why it happens. Adam’s update is sign-like: every entry of ΔW\Delta W has about the same size, η\eta. A hidden layer’s output change ΔWx\Delta W x sums dd such terms. Because the update was built from the same inputs xx that it is now applied to, the terms add up coherently rather than cancelling, so the change grows with dd.

Demo 07 measures one Adam step at a fixed rate on a hidden layer’s actual inputs:

widthSP: ∥ΔWx∥/∥Wx∥\lVert\Delta W x\rVert / \lVert W x\rVertµP
320.9090.909
641.4570.728
1282.4300.607
2564.3840.547

The SP change grows 4.8× for an 8× wider layer. It is not exactly 8×, because a batch’s gradient is not exactly rank one. Under µP it stays of the same order.

µP (maximal update parametrization, 最大更新参数化) for Adam, with width multiplier m=width/base widthm = \text{width}/\text{base width}, as on the slide:

  • hidden-weight learning rate ÷ mm;
  • output logits × 1/m1/m;
  • attention scores scaled by 1/dhead1/d_{head} instead of 1/dhead1/\sqrt{d_{head}}.

Each layer’s update then changes its output by the same amount at any width. In demo 07 the head size is fixed at 16, so the attention rule is a constant.

The sweep (demo 07, measured; validation bits/byte after 200 steps, * = best in the row):

width2⁻¹²2⁻¹⁰2⁻⁸2⁻⁶2⁻⁴
SP322.4601.7840.9530.833*0.860
SP642.2091.3700.836*1.0461.322
SP1281.8330.9670.921*1.0371.557
SP2561.3370.852*0.8571.3211.334
µP322.4601.7840.9530.833*0.860
µP642.4681.8330.9490.820*1.036
µP1282.4831.8460.9360.810*0.887
µP2562.4871.8450.9230.813*0.836

In SP the optimum moves from 2−62^{-6} to 2−102^{-10} as width grows 8×. In µP it stays at 2−62^{-6}. The transfer test (tune at width 32, train at width 256) costs +0.469 bits/byte in SP and +0.000 in µP. Under µP the wider model is also simply better at the shared rate (0.813 vs 0.833), as a ladder should be.

In the original paper, settings tuned on a 40M model beat the published 6.7B GPT-3, at 7% of its pre-training compute (reported). µP covers width; depth, batch size and training length need extensions. Lecture 12 derives the 1/din1/d_{in} scaling from the geometry of Adam’s update.

6.3 A ladder, a scaling law, and a pre-registered prediction

How to split a budget. A compute budget C≈6NNtokC \approx 6 N N_{tok} fixes the product of parameters and tokens. Chinchilla found that, for one dataset, about 20 tokens per parameter is compute-optimal. Models meant for cheap inference are trained far past that (demo 05):

modeltokens per parameter
Gopher1
Chinchilla20
Llama 3 405B39
OLMo 2 7B571
Marin 8B1,588

Llama 3’s ladder predicted 402B parameters and 16.55T tokens (reported).

Demo 08 does the whole procedure in miniature, with one advantage over real life: Atlas World’s irreducible loss EE is known exactly. The steps:

  1. The ladder. Three widths (23.7K–390K non-embedding parameters) × three token budgets (205K–819K tokens), every run with µP at demo 07’s rate.
  2. The fit. excess(N,D)=AN−α+BD−β\text{excess}(N, D) = A N^{-\alpha} + B D^{-\beta} fits all nine runs to within 6.7% of their excess loss (α=1.05\alpha = 1.05, β=0.63\beta = 0.63). Doubling the data cuts the excess far more than quadrupling the width: most of what is left (sums, code values, rare facts) needs data.
  3. The prediction, written down before training. For a 2.3× wider model trained on 1.5× the largest budget: 0.7481 bits/byte.
  4. The run. 0.7524 bits/byte. The error is 0.6% of the loss but 12.6% of the excess. The target lies outside the ladder on both axes, so this is extrapolation error.
  5. The split. Minimizing the fit under C=6NDC = 6ND gives N⋆∝C0.37N^\star \propto C^{0.37}, with 130–420 tokens per parameter over 101310^{13}–101510^{15} FLOPs, far from Chinchilla’s 20.

The ladder cost 0.67× the target run’s FLOPs. The slides’ advice: budget the ladder, ablations and anneals first, then size the final run with what is left. Exponents belong to a dataset and model family. DeepSeek LLM refit them on three datasets and found that better data shifts the optimum toward larger models (Lecture 10). And a pre-registered loss is a monitor: Marin pre-registers the full run’s expected loss from its ladder, and during the run, loss above the prediction is a reason to investigate. Llama 3 likewise predicted ARC-Challenge accuracy across four orders of magnitude of compute, and the final model scored slightly above the prediction.

Ladders also test stability:

  • Marin’s ladder for its 535B run showed gradient-norm growth, and adding z-loss fixed it before launch.
  • OLMo 2 reproduced its spikes in short small runs to compare initializations.

But small runs do not catch every data spike: OLMo 2’s repeated n-grams spiked a larger model but not a smaller one.

6.4 Checklists

essentialbeneficial
tests for tokenization, packing and label shifta ladder for model size and a predicted final loss
short runs to pick the learning rate (with µP so it transfers) and batch sizebenchmarks and samples at checkpoints
throughput measured and tuned before launchspike scores and per-layer norms
a checkpoint-and-resume testthe same loss across parallelism layouts
training loss and gradient norm at every stepversioned data builds
validation loss per domain on a fixed held-out setgoodput and failures tracked against the plan

7. Summary

  1. Pre-training is causal language modelling on trillions of tokens. The labels are the inputs shifted by one. The loss has a floor, the source’s entropy; Atlas World knows it exactly (0.719 bits/byte), so excess loss is measurable.
  2. Compare models in bits per byte. Loss per token depends on the tokenizer (per token, a byte model looked 3× better and was worse).
  3. The training step: Btok=R×B×L×AB_{tok} = R \times B \times L \times A; warm-up then cosine or WSD; AdamW (β2=0.95\beta_2 = 0.95, ϵ=10−8\epsilon = 10^{-8}, weight decay 0.1 but not on embeddings, clipping at 1.0); packing; mixed precision with FP32 where errors accumulate. BF16 storage froze 67% of updates late in a run; a BF16 accumulator lost 94% of a sum.
  4. Time to train = 6NNtok6 N N_{tok} / (MFU × peak × goodput). Llama 3 405B: ≈ 67 days on 16K H100s, with 85% of its GPU-hours going into model FLOPs.
  5. Failures are routine at scale (one every 3 hours on 16K GPUs). Checkpoint every ≈2δτ\approx\sqrt{2\delta\tau}.
  6. Silent bugs cost the most. A shifted-label bug gave a training loss below the source entropy. A train/eval mask mismatch looked like a worse recipe. Test before launch, and evaluate per domain during the run.
  7. Spikes come from data (repeated n-grams: a spike that returns to trend) and from the recipe (norm growth). Gradient norms warn first. QK-norm, z-loss, initialization, ε and data filters each address a specific norm; QK-norm removed attention-logit runaway in demo 06.
  8. Plan with small runs: µP so learning rates transfer (+0.469 vs +0.000 bits/byte penalty); a ladder and a scaling law for size, tokens and a pre-registered final loss (predicted within 0.6%).

8. Common pitfalls

  • Comparing loss per token across tokenizers or across evaluation sets.
  • Trusting a training loss that looks too good. Below the plausible floor means a label bug.
  • Padding instead of packing, or computing the loss over padding.
  • Evaluating with a different mask, context length or format than training used.
  • Storing weights, or summing gradients, in BF16.
  • Logging the configured learning rate instead of the actual one.
  • Reading one benchmark’s 2-point gap as a win.
  • Tuning the learning rate on a small model under SP and using it on the big one.
  • Treating “no spikes on the 8B” as evidence that the 32B recipe is stable (Marin).
  • Spending the whole budget on the final run, leaving none for the ladder, ablations and anneals.

9. Exercises

  1. Perplexity and bits. A model has validation loss 1.8 nats/token with a tokenizer averaging 4.2 bytes/token. What are its perplexity and its bits per byte? Another model, with a byte tokenizer, reports 0.45 nats/token. Which is better?
Answer

PPL = e1.8e^{1.8} ≈ 6.05. BPB = 1.8/(4.2×0.693)1.8/(4.2 \times 0.693) = 0.618. The byte model: BPB = 0.45/(1×0.693)0.45/(1 \times 0.693) = 0.649. The first model is better per byte, despite its higher loss per token.

  1. Tokens per step. 512 GPUs in data parallel, micro-batch 2 sequences of 8,192 tokens, 4 accumulation steps. How many tokens per optimizer step? If the step takes 9 s, what are tokens/s and tokens/day at 95% goodput?
Answer

512×2×8192×4=33.6M512 \times 2 \times 8192 \times 4 = 33.6\text{M} tokens per step. Tokens/s = 33.6M/9 = 3.73M. Tokens/day = 3.73M×86,400×0.95=3.06×10113.73\text{M} \times 86{,}400 \times 0.95 = 3.06 \times 10^{11}.

  1. Time to train. A 70B dense model, 15T tokens, 4,096 H100s at 45% MFU (BF16 peak 989 TFLOP/s), goodput 92%. How many days?
Answer

FLOPs = 6×70B×15T=6.3×10246 \times 70\text{B} \times 15\text{T} = 6.3 \times 10^{24}. Effective rate = 4096×0.45×989×1012×0.92=1.68×10184096 \times 0.45 \times 989 \times 10^{12} \times 0.92 = 1.68 \times 10^{18} FLOP/s. Time = 3.76×1063.76 \times 10^6 s ≈ 43.5 days.

  1. Checkpoint interval. Failures every 2 h; a synchronous checkpoint takes 3 min. What interval and overhead? Asynchronous checkpointing cuts the blocking time to 20 s: what now?
Answer

Δ⋆=2×0.05×2=0.447\Delta^\star = \sqrt{2 \times 0.05 \times 2} = 0.447 h ≈ 27 min; overhead = 0.05/0.447+0.447/4=0.112+0.112=22%0.05/0.447 + 0.447/4 = 0.112 + 0.112 = 22\%. With δ = 20 s = 0.00556 h: Δ⋆=0.149\Delta^\star = 0.149 h ≈ 9 min; overhead = 0.0373+0.0373=7.5%0.0373 + 0.0373 = 7.5\%.

  1. Which bug? A new data pipeline gives a training loss that drops to 0.3 within 200 steps, while the previous pipeline plateaued around 2.0 with the same model. Validation loss is terrible. What do you check first?
Answer

The label shift. A loss far below what the model achieved before, with useless validation, is the signature of labels that equal the inputs: the model copies the token it is reading. Inspect one batch by hand (decode inputs and labels side by side), and add the test “labels[t] == inputs[t+1]”.

  1. BF16 updates. A weight of value 0.75 stored in BF16 receives an update of −4×10−4-4 \times 10^{-4}. What value is stored after the update? What is the smallest update that would change it?
Answer

In [0.5, 1), BF16’s spacing is 2−1×2−7=2−8≈0.00392^{-1} \times 2^{-7} = 2^{-8} \approx 0.0039. An update of 4×10−44 \times 10^{-4} is below half the spacing (0.001950.00195), so the stored value stays 0.75. An update needs magnitude above about 0.00195 to round to the next value. With FP32 master weights the update is kept and accumulates.

  1. Spike or divergence? At step 41,000 the loss jumps from 1.92 to 2.60; by step 41,050 it is back at 1.93, and the gradient norm is at its usual 0.3. A week later the gradient norm has drifted from 0.3 to 0.6 and spikes come every few hundred steps. Which is which, and what do you do?
Answer

The first is a data spike: an isolated jump that returns to trend with a normal gradient norm. Record it, and inspect and filter the batch if it recurs. The second is a recipe instability building up: slow norm growth with increasingly frequent spikes, the OLMo-0424 pattern. Roll back to before the growth, and lower the learning rate or change the recipe (QK-norm, z-loss, ε, initialization). Test the fix on a short, small run at the planned learning rate first.

  1. µP transfer. You tuned AdamW’s learning rate to 3×10−33 \times 10^{-3} on a width-512 proxy. The final model has width 8,192. Under µP, what learning rate do the hidden matrices get? What about the embeddings, and the output logits?
Answer

m=8192/512=16m = 8192/512 = 16. Hidden matrices: 3×10−3/16=1.9×10−43 \times 10^{-3}/16 = 1.9 \times 10^{-4}. Embeddings keep 3×10−33 \times 10^{-3} (one dimension, the vocabulary, does not grow with width). The output logits are multiplied by 1/161/16. Under SP you would instead have to re-tune at the final width, or extrapolate a drifting optimum.

  1. Benchmark noise. Model A scores 54.0% and model B 56.5% on a 1,200-question benchmark. Is B better?
Answer

SE per model ≈ 0.55×0.45/1200=1.44\sqrt{0.55 \times 0.45/1200} = 1.44 points; the SE of the difference ≈ 2.03 points. 2.5 points is about 1.2 standard errors: not significant. Compare on more tasks, or on validation loss.

Fall 2026 Assignment 2 (released Sep 28) asks each group to pre-train a model from scratch on one 8×H100 node for two weeks. The slides’ advice applies directly:

  • decide which ablations you want before the final run, and reserve compute for them;
  • tune the learning rate on small proxies, with µP so it transfers;
  • pick the size and token count from a small ladder;
  • test packing, label shift and resume before launch;
  • log the dashboard of §5.1;
  • evaluate per domain in bits per byte, with cloze-format benchmarks read against their standard error.

In Spring 2026 the best student runs on one node rivalled a recent 1B model trained on about 68× more data (course site). No assignment solutions are given here; pretrain.py is independent of the course’s starter code.

11. Research directions

  • Predicting the final loss earlier and better. Ladders fit to small models extrapolate; how far, and with what error bars, when the irreducible loss is unknown? Atlas World (known EE) is a test bed.
  • Stability by construction. QK-norm, z-loss, and normalized or fixed-norm weights (Lecture 13) each bound one norm. Is there a parametrization that bounds them all, making spikes impossible rather than rare?
  • Low-precision training. NVFP4 pre-training at 20T tokens kept some layers in higher precision. Which tensors must stay high, and can the choice be made automatically from statistics?
  • µP beyond width. Depth, batch size, training length, MoE sparsity and schedules all change the optimal hyperparameters. Unified transfer rules would cut the cost of planning.
  • Cheap detection of silent failures. Statistical tests on per-domain loss, data statistics and gradient norms that flag a data or label bug within hours rather than after the run.

12. Further reading

  • Llama 3 (arXiv:2407.21783): §3.2 (scaling laws and the ladder), §3.3 (infrastructure, reliability, Table 5), §3.4 (the training recipe).
  • OLMo 2 (arXiv:2501.00656) §3: stability, the spike score, the recipe changes.
  • Marin 8B, 32B and 535B retrospectives (marin.readthedocs.io), with code and W&B logs.
  • Nemotron 3 Ultra (arXiv:2606.15007): NVFP4 pre-training, the two divergences.
  • Yang et al., Tensor Programs V: Tuning Large Neural Networks via Zero-Shot Hyperparameter Transfer (arXiv:2203.03466).
  • McCandlish et al., An Empirical Model of Large-Batch Training (arXiv:1812.06162).
  • Hoffmann et al., Training Compute-Optimal Large Language Models (Chinchilla, arXiv:2203.15556).
  • OLMES (arXiv:2406.08446) and Paloma (arXiv:2312.10523) for evaluation.
  • NVIDIA Transformer Engine FP8 primer (delayed scaling, MXFP8, NVFP4).

13. Next lecture

Lecture 10 · Data for Pre-Training. This lecture treated the data as given. Real pre-training data starts as a web crawl that is mostly unusable. Lecture 10 follows it through extraction, language ID, heuristic filters, learned quality classifiers, exact and fuzzy deduplication, repetition and epochs, and mixture search, scoring each step against Atlas World’s known quality labels and training small models on the results.


术语表 (Glossary, English → 中文)

English中文
pre-training / mid-training / post-training预训练 / 中期训练 / 后训练
causal language modeling (CLM) / masked language modeling (MLM)因果语言建模 / 掩码语言建模
autoregressive factorization自回归分解
cross-entropy / perplexity交叉熵 / 困惑度
source entropy / irreducible loss / excess loss信源熵 / 不可约损失 / 超额损失
bits per byte (BPB)每字节比特数
tokenizer / byte-level BPE / merge / vocabulary分词器 / 字节级 BPE / 合并规则 / 词表
shifted labels / teacher forcing右移一位的标签 / 教师强制
tokens per step / micro-batch / gradient accumulation每步词元数 / 微批次 / 梯度累积
critical batch size临界批大小
warm-up / cosine decay / WSD / cooldown预热 / 余弦衰减 / 预热-稳定-衰减 / 冷却期
weight decay / gradient clipping权重衰减 / 梯度裁剪
sequence packing / padding / document mask序列打包 / 填充 / 文档掩码
silent failure / label-shift bug静默故障 / 标签错位错误
mixed precision / master weights / loss scaling混合精度 / 主权重 / 损失缩放
exponent / mantissa / underflow / subnormal指数位 / 尾数位 / 下溢 / 次正规数
per-tensor scaling / block scaling (MXFP8, NVFP4)按张量缩放 / 按块缩放
goodput / MTBF / failures per day有效训练时间占比 / 平均故障间隔 / 每日故障数
KPI / researcher interventions关键绩效指标 / 研究员人工干预次数
checkpoint interval / asynchronous checkpointing检查点间隔 / 异步检查点
gradient norm / update norm / spike score梯度范数 / 更新量范数 / 尖峰分数
loss spike / divergence / rollback损失尖峰 / 发散 / 回滚
QK-norm / z-loss查询-键归一化 / z 损失
repetition filter (repeated n-grams)重复 n 元组过滤器
cloze format / letter format / standard error完形填空格式 / 字母选项格式 / 标准误差
contamination测试集污染
ladder / scaling law / pre-registered prediction模型阶梯 / 缩放定律 / 预先登记的预测
µP (maximal update parametrization) / standard parametrization最大更新参数化 / 标准参数化
hyperparameter transfer超参数迁移
tokens per parameter / compute-optimal每参数词元数 / 计算最优
← 返回课程目录