| Objective and data | |
|---|---|
| a training row, a sequence of tokens cut from the concatenated web text | |
| vocabulary size, the number of distinct tokens (4096) | |
| the model's next-token distribution, , the probability it gives each possible next token after the prefix | |
| the model's parameters, all of its weights (about 35M for d8) | |
| cross-entropy per prediction target in nats, the mean of over a row's 1023 targets (about 2.93 at the end of a d8 run) | |
| Model | |
| number of blocks of the ladder model d (8 for d8) | |
| width, the length of each token's vector in the residual stream, on the ladder (512 for d8) | |
| number of attention heads per block, on the ladder (8 for d8) | |
| head width, the length of each head's query, key and value vectors (64) | |
| MLP inner width, the length of the SwiGLU MLP's inner vector, (1792 for d8) | |
| non-embedding parameters, the attention and MLP weights of all blocks, (30.4M for d8) | |
| input width of a weight matrix, the length of the vectors it multiplies ( for most matrices, for ) | |
| the standard normal table both embeddings start from, for the input embedding and for the output matrix | |
| input of block , the residual stream as block reads it | |
| sum of the attention and MLP outputs of block , so the default block computes | |
| Optimizer | |
| peak learning rate (0.003), reached at the end of warmup | |
| learning rate at step , rising linearly from 0 to over the first 1% of steps, then falling linearly to 0 | |
| weight-decay coefficient (0.1), so each step multiplies a decayed matrix by | |
| Adam's averaging coefficients (0.9, 0.95), the weight each running average keeps on its old value at every step, for the gradient and for its square | |
| small constant added to Adam's denominator, , which keeps the division safe when is near zero | |
| bias-corrected running average of the gradient at step , with and . Adam moves each weight along it | |
| bias-corrected running average of the squared gradient at step , coordinate by coordinate, with and . Adam divides by , so a weight whose gradient keeps a steady size and sign moves by about whatever its gradient's scale | |
| batch size, 64 rows (65,536 tokens) per step | |
| number of optimizer steps, 600,000 rows divided by (9,375) | |
Context. Deep learning runs modern language models, self-driving stacks, protein-structure predictors, and Go engines. Yet no general theory predicts what a change to a training run will do. Classical intuition often misleads. The U-shaped bias-variance curveexpected squared test error split into bias squared, variance, and irreducible noise; classically U-shaped in model capacity as bias falls and variance rises gave way to double descenttest error peaking near the interpolation threshold (where the model just fits the training data exactly) and falling again at larger capacity (Belkin et al., 2019). Reading note: Double descent. Lecture 1 of Hashimoto and Kotha's Stanford course CS 312 (Deep Learning Alchemy) opens with data-limited pre-training runs from Kim et al. (2025). In those runs, loss stops improving with model size until weight decay is tuned, and then follows a clean power law. This note covers Lecture 1 and the supplementary LLMs 101 session and handout, which set out the course's training setup.
In the course's view, understanding a training phenomenon means predicting an experiment's outcome before running it. Students build that skill by running many experiments on one small, fully specified model organism called d8an 8-block, width-512 transformer with about 35M parameters, pre-trained on 614.4M tokens of web text. The opening d8 experiments already yield two lessons that carry beyond this setup. First, an architecture ablation means little at one shared learning rate. Removing pre-norm diverges at the default rate. At a lower rate, it trains nearly as well as removing RoPE and changes the ranking of five ablations. Second, d8's final loss varies by about 0.003 across random seeds. Smaller gaps, such as the one from averaging two earlier block inputs in the skip path, cannot be read off a single run of each variant.
Lecture 1 grounds this predictive stance in science, where theories earn credit through predictions, and in next-token prediction itself. The targets are validation loss and internal statistics such as activation, gradient, and parameter norms. Most of the course studies pre-trainingtraining a model from scratch to predict the next token of a large text corpus for three reasons. Validation loss predicts downstream usefulness with little noise, scaling laws: empirical fits of final loss against model size , data, or compute used to extrapolate from small runs to large ones. Reading notes: Chinchilla scaling, Hyperparameters, scaling, noise and debugging let small runs stand in for large ones, and every run starts from scratch with no inherited state.
The default recipe: objective and data. Write a training row as tokens of length , drawn from a vocabulary of subwords. The autoregressive model predicts each token from the prefix before it, giving targets per row. The objective is cross-entropy per target in nats: natural-log loss units, where one nat equals bits, the mean negative log-probability of each true next token:Training uses teacher forcingeach position conditions on the true prefix rather than the model's own predictions, so all 1,023 targets in a row compute in parallel. The corpus is DCLMDataComp for Language Models, a filtered corpus of web text web text, tokenized with SentencePiecea subword tokenizer trained on raw text to a fixed vocabulary (here ) (Kudo and Richardson, 2018), concatenated, and sliced into 1,024-token rows that can cross document boundaries. A default run makes one pass over 600,000 rows (614.4M tokens) and evaluates on 1,000 fixed held-out rows. It finishes near 2.93 nats, a perplexity: the number of equally likely tokens that would give the same loss of about 19.
Architecture. d8 is a Llama-style decoder-onlya single stack of transformer blocks with no encoder or cross-attention; here attention is causal (position attends only to positions ), whereas a prefix LM lets the prompt attend bidirectionally (Raffel et al., 2020) transformer. An embedding tablea learned matrix () that maps each vocabulary token to its row vector maps each token to a vector of widththe length of each token's vector in the residual stream (512 for d8); attention matrices are , MLP matrices are or , and embedding tables are . Eight pre-norm: each branch reads a normalized copy of the residual stream and adds its output back, leaving the skip path unnormalized. Reading note: Signal propagation in depth blocks with RMSNorm with learned per-coordinate scale ; unlike LayerNorm it drops mean subtraction and bias on the hypothesis that rescaling alone steadies training, matching LayerNorm at lower cost (Zhang and Sennrich, 2019) each add an attention branch and an MLP branch to the residual stream, then : the -dimensional vector carried from block to block by skip connections (named after ResNets, He et al., 2016); each branch adds to it rather than overwriting it, and it is the thick line in the figure below. Reading note: A Mathematical Framework for Transformer Circuits. A final norm and an output matrix then produce the next-token logits. Attention uses heads of width with RoPErotary position embeddings: pairs of query and key coordinates rotated by angles proportional to token position so dot products depend on relative offset and QK-normRMSNorm applied to each head's query and key vectors after RoPE and before their dot product, preventing score growth with incoming vector size while learned scales preserve adaptability. Reading note: Small-scale proxies for large-scale Transformer training instabilities. The MLP is SwiGLU with , , and (Shazeer, 2020) with inner width (). The architecture omits biases and dropout, and keeps the input and output embeddings separate. Each block holds four matrices (query, key, value, output), about 1.05M parameters; each head uses a -wide slice with attention weights and three matrices of size or , about 2.75M parameters MLP weights. Across all eight blocks, non-embedding parameters total M attention and MLP weights across all eight blocks, excluding norm scales, alongside 4.2MM across the separate input embedding and output matrices in the two embedding tables.
Initialization. Every weight matrix starts from a normal distribution with standard deviation , truncated at three standard deviationsnormal draws conditioned to lie in , cutting off about 0.3% of draws and shrinking the standard deviation slightly (by about 1.3%, computed here); the handout notes the shrinkage without giving a reason, though truncation is usually used to rule out outsized starting weights, where is its input width. Scaling by keeps outputs about as large as inputsfor independent weights of variance , each output has variance , matching the input's mean square at any width; the handout presents this as a scale argument only, with no guarantee about training dynamics at any width. Both embedding tables come from one standard normal table . The input embedding is entries of size ; the course gives no reason for this scale, but it starts token vectors far smaller than block outputs so Adam's steps (up to ) quickly learn the embedding almost from scratch, and the output matrix is entries of size , so initial logits have size about 1 and starting loss sits about half a nat above nats (computed here). The two tables therefore start aligned in direction, though the course does not explain why.
The scaling ladder. Larger and smaller models come from one preset family. Model dpreset with blocks, width , heads of width 64, and MLP inner width . Reading note: Hyperparameters, scaling, noise and debugging has blocks, attention heads, and width , so depth and width grow together at a fixed aspect ratio for every preset (called a convention in the handout); Lecture 9 reports Kaplan et al.'s (2020) finding that at fixed parameter count, varying this ratio by a factor of 40 changes the loss only slightly. Reading note: Depth, width and expressivity. Each block holds weights with , so non-embedding parameters scale as . That gives about 3.8M for d4, 30.4M for d8, and 243M for d16. Switching presets changes nothing else. Learning rate, batch size, token count, and step count all stay at their defaultsthe course gives no reason for holding them fixed; Lecture 2 shows the optimal learning rate shifts with model size and Lecture 4 derives width-scaling rules, and with fixed tokens a larger preset sees fewer tokens per parameter (about 20 for d8 vs. 2.5 for d16). Reading notes: Hyperparameters, scaling, noise and debugging, Parametrization across width and depth.
Optimization. Training uses AdamW: Adam with decoupled weight decay, where decay shrinks weights directly instead of passing through the gradient averages (Loshchilov and Hutter, 2019). Reading note: Noisy quadratics and weight norms with , , and . Each batch holds rows (65,536 tokens), so one pass over 600,000 rows takes steps. The learning rate rises linearly from zero over the first 1% of steps (93 steps of warmupan opening phase where the learning rate ramps linearly from zero to its peak. Reading note: Hyperparameters, scaling, noise and debugging) to a peak , then decays linearly back to zero. Decoupled weight decay applies to attention, MLP, and output matrices, excluding embeddings and norm scales. Write and for Adam's bias-corrected running averages and , where and start from 0 (coordinatewise squares); dividing by corrects the zero-start pull over the first ~50-100 steps. A weight whose gradient keeps a steady size and sign has and moves by about , while sign-flipping gradients average down of the gradient and its coordinatewise square. Each decayed matrix updates asBecause each step shrinks decayed weights by a fraction , weight decay fades to zero alongside the learning rate. Before each update, gradient clipping caps the global gradient norm across all parameters at 1. Weights and optimizer state stay in fp32 while matrix products run in bf16. One d8 run takes 10 to 15 minutes on a single H100 GPU, costing about fifty cents of rented compute.
How the course tests prediction. Each quiz problem supplies a diffa patch to the course codebase that completely specifies the modified runs and asks for a measured outcome, such as a loss gap, a ratio bin, or a ranking. Staff settle the answer by running the experiment. Assignment 1 lays out five rules for clean experiments. Change one thing at a time, use the smallest scale that shows the effect, and measure run-to-run variation. Sweep across a range of settings instead of comparing two points, and match parallel runs to available compute.
Learning-rate sensitivity. A peak learning rate within a factor of 3 of the optimum costs little on d8. The default 0.003 wins across six peak rates from to , spaced roughly by factors of 3. Moving a factor of 3 either way adds only 0.03 to 0.05 in final loss. The basin is lopsided. A rate ten times too small costs 0.22, while a rate ten times too large costs 0.09. Low-rate loss curves are still falling steeply when the fixed 9,375 steps expire; high-rate runs train stably and finish only moderately worse. A rate tuned for one model is therefore a reasonable starting guess for a nearby variant.
| Variant | At the default rate | At its best rate |
|---|---|---|
| A, the baseline | 2.9267 | 2.9267 |
| F, without RoPE | 3.0671 | 3.0671 |
| B, without pre-norm | not finite | 3.0766 at |
| D, without the MLP branches | 3.2199 | 3.2199 |
| E, without the attention branches | 4.8641 | 4.8641 |
| C, without residuals (skip connections) | 6.8747 | 6.8745 at 0.03 |
The residual path tolerates large changes. Write for the input to block and for the sum of its attention and MLP outputs, so the default block computes . At the default rate, halving the skip term hurts substantially, raising loss from 2.9267 to 3.2269. Doubling , or adding Gaussian noise of standard deviation 0.1 or 1 to the skip path, costs at most 0.04 at the default rate. At rate 0.03, all three match or beat the baseline. A mixed skip averages the two previous block inputs:Block 1 stays unchanged, and gradients flow through both skip inputs. Across all six rates, this variant lands within 0.01 of the default. Its best loss differs by . That gap is about a third of d8's seed-to-seed standard deviation (0.0029 over ten seeds), so a single pair of runs cannot separate the two architectures.
Limits. The d8 setup is narrow, using about 35M parameters, one corpus, 9,375 steps, and language alone. The course plans a later switch to another modality, such as DNA. Assignment 1 warns that lessons from d8 are far from universal and will often disagree with published results, yet asks students to master d8 anyway. The experimental habit transfers to any domain, and d8 intuitions give a rough first guess when no better evidence exists. Because the comparisons above come from single runs, gaps under about 0.003 fall inside seed noise.
Terms
- prediction as understanding
- the course's stance: understanding a phenomenon means predicting an experiment's outcome before running it
- d8
- 8 pre-norm blocks, width 512, 8 heads of 64, RoPE, QK-norm, SwiGLU (1792), untied embeddings; about 35M parameters
- default data
- DCLM web text, 4,096-token vocabulary, rows of 1,024 tokens, 600,000 rows (614.4M tokens), one pass
- default optimizer
- AdamW (0.9, 0.95), peak 0.003, 1% warmup, linear decay to 0, weight decay 0.1 on matrices, clip at 1, 64 rows per step, 9,375 steps
- mean next-token negative log-probability per target, in nats; about 2.93 for default d8
- ladder d
- width , heads, ; hyperparameters unchanged
- decoupled decay
- : the decay fades with the schedule
- learning-rate basin
- best 0.003; a factor 3 off costs 0.03 to 0.05; 10 times too small 0.22, 10 times too large 0.09
- ablation ranking
- A < F < B < D < E < C with each variant at its own rate; without pre-norm the run diverges at 0.003
- mixed skip
- : , a third of the seed-to-seed standard deviation
Sources
Lecture 1, “Introduction: prediction as understanding, the pre-training setting, the d8 model organism” (Sep 22, 2026), and LLMs 101 (supplementary session), Sep 23, 2026, of Stanford CS 312 Deep Learning Alchemy, Fall 2026. Taught by Tatsunori Hashimoto and Suhas Kotha; course staff Kaiyue Wen and Tristan Thrush (CAs).
Course site Lecture slides Assignment Assignment code LLMs 101 slides LLMs 101 handout
The lessons, experiments, figures and quiz problems in this note are the course's, shown here with the instructors' permission.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Lecture 1: Introduction. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, LLMs 101 (supplementary lecture): handout. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, LLMs 101 (supplementary lecture): slides. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Assignment 1: Basics. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, Quiz 1 (Basics) answer slides. Stanford, Fall 2026.
- Tatsunori Hashimoto and Suhas Kotha. CS 312 Deep Learning Alchemy, course website. Stanford, Fall 2026.
- Konwoo Kim, Suhas Kotha, Percy Liang, and Tatsunori Hashimoto. Pre-training under infinite compute. arXiv preprint, 2025.
- Mikhail Belkin, Daniel Hsu, Siyuan Ma, and Soumik Mandal. Reconciling modern machine learning practice and the bias-variance trade-off. Proceedings of the National Academy of Sciences, 2019.
- Taku Kudo and John Richardson. SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing. Proceedings of EMNLP 2018: System Demonstrations, 2018.
- Ilya Loshchilov and Frank Hutter. Decoupled Weight Decay Regularization. International Conference on Learning Representations, 2019.
Connected notes
- Softmax attention as a sum of RNNsEfficient sequence models · Additive paths carry signal through depth and time
Linear attention's state is a running sum of key-value products that never forgets. Of Mamba-2's components added one at a time to a 300M model, a data-dependent decay of that sum and a short convolution carry nearly all the gain. Test loss goes from 3.13 to 2.88 with the decay alone, 2.93 with the convolution alone and 2.77 with both, while the other components move it by 0.07 or less.
- Stein's paradox and the James-Stein estimatorBenign overfitting · Comparing noisy runs is an estimation problem
With effects spread around a common mean, the posterior mean pulls each raw estimate toward that mean, and Lindley's version of James-Stein estimates both the mean and the amount of pulling from the spread of the estimates themselves. It beats the raw estimates in total squared error for every configuration of the once there are four or more, and in Efron's batting example it cuts the total prediction error to 0.28 of that of the raw batting averages.
PreNorm's unweighted running sum grows with depth and dilutes every earlier output, so Attention Residuals replace it with softmax-weighted averages over earlier block sums, bounding the mixed input by while keeping direct shortcuts across depth without the matrix-product instability of multi-stream mixing.
- Best arm identificationBandits and exploration · Comparing noisy runs is an estimation problem
To name the better of two Gaussian arms with error at most , sample arm 1 on the fraction of rounds, which minimizes the variance of the difference of means, and stop once that difference exceeds standard deviations; equal sampling costs up to twice as many samples, and with equal variances the rule is Robbins' sequential test.