Deep Learning Alchemy
Lessons and quizzes from Stanford CS 312 Deep Learning Alchemy (Fall 2026), taught by Tatsunori Hashimoto and Suhas Kotha, with Kaiyue Wen and Tristan Thrush (CAs). The lessons, experiments, figures and quiz problems are the course's, shown here with the instructors' permission.
Deep learning lacks a general theory for what happens when a pretraining recipe changes, so understanding means predicting outcomes on a controlled transformer before running them. Across architecture and optimization, behavior reduces to how additive paths carry signal, how scale-invariant weights settle under decay, and how optimizer noise sets a loss floor.
Controlled ablations show that untuned learning rates and seed spread reverse naive rankings, and scaling ladders fail unless settings move with size. Noisy quadratics, width parametrization, loss basins, and edge-of-stability flows link batch size, momentum, and weight decay to equilibrium norms and sharpness. Residual paths, gated recurrences, and parameter count govern trainability and loss, while heavy decay and ensembles restore scaling on fixed data.
- Six d8 variants are trained at peak rates and scored by their best final validation loss over that grid. A: baseline; B: no pre-norm (block-input norms replaced by identities); C: no residuals; D: no MLP; E: no attention; F: no RoPE. Which ranking, lowest loss first, is right?With its own rate, , the model without pre-norm reaches 3.0766, just behind no RoPE (3.0671); it diverges only at the default 0.003, so a one-rate comparison puts it last. No MLP costs 0.29, no attention 1.94 (a bigram model) and no residuals 3.95 (it never trains). The course's commentary: its one-rate exploration missed that the pre-norm-free model fails only at the default and higher rates.From Prediction as understanding: the d8 model organism
Adapted from CS 312 Lecture 1, Example question 1 (Easy)
- The d8 recipe is trained at ten paired seeds (model seed = data seed = 4 to 13) on one GPU type. Separately, with full determinism on, pairs of runs differ in exactly one token of one training row (one of 614.4M), at five paired seeds. Which pair is closest to the measured standard deviation of the ten final validation losses and the mean final validation gap of the one-token pairs?The measured is 0.0029 (varying only one seed gives about the same), and the one-token gap is at the default rate. Training amplifies even a one-token change, to a spread about half of reseeding's (two reseeded runs differ by about on average, computed here); Summers and Dinneen found that a one-bit change to one initial weight gives the full spread.From Hyperparameters, scaling, noise and debugging
Adapted from CS 312 Quiz 1 (Basics), Problems 1(a) and 8(b)
- In Zhang et al.'s noisy quadratic (, , ), compare tuned SGD against -preconditioned SGD as batch size sweeps from tiny to huge. Where does preconditioning pay off?Preconditioning by cuts the condition number to but amplifies flat-direction noise by ; at small the raised noise floor caps step size, so gains appear at large .From Noisy quadratics and weight norms
- Under Adam P with reference width and base rate , widen the model to (). What learning rates and readout multiplier apply?Full-alignment Adam requires : hidden layers use , giving , while the readout uses , keeping rate with output multiplier .From Parametrization across width and depth
- A forked-run sweep on d8 at a constant learning rate: a shared prefix of updates, then two branches of more updates with different data orders. At learning rate .003 three cells came out as follows (lowest loss first, losses within .01 equal): (i) : Avg = Ens < Best; (ii) : Ens < Avg < Best; (iii) : Ens < Avg < Best. The whole sweep (prefix and branches) is repeated at a constant learning rate of .01. Which orderings do you predict for (i), (ii), (iii)?(i) unchanged, (ii) flips, (iii) unchanged. A higher learning rate shrinks the region where branches stay connected; inside it nothing changes. At .01 the branches take 3.3 times larger steps, so two data orders separate faster, and in cell (ii) the average is .04 to .06 worse than the better endpoint. With 50-update branches the average still matches the ensemble, and after a 250-update prefix the average still beats both endpoints. Altintas et al. (2023) also find higher barriers at higher learning rates.From Loss basins, river valleys and saddle points
Adapted from CS 312 Quiz 3 (Optimization 2), Problem 1(a)