Sam Babichenko

Reading notes / Deep Learning Alchemy

Depth, width and expressivity

From Lecture 9 of Stanford CS 312 Deep Learning Alchemy (Fall 2026), taught by Tatsunori Hashimoto and Suhas Kotha

slides assignment code

Approximation and depth
σ\sigmaReLU, max⁡(z,0)\max(z,0)
dind_{\rm in}input dimension of the target function, defined on [0,1]din[0,1]^{d_{\rm in}}
ε\varepsilonapproximation accuracy; a grid of hinges needs about (1/ε)din(1/\varepsilon)^{d_{\rm in}} units to reach it
ffthe fold f(z)=min⁡(2z,2−2z)f(z)=\min(2z,2-2z) on [0,1][0,1], computed by two ReLU layers
fkf^kthe fold ff composed kk times, a sawtooth with 2k−12^{k-1} teeth and 2k2^k linear pieces
kknumber of folds; also the depth limit of the shallow class in Telgarsky's theorem
gga comparison ReLU network of one input variable, measured against the sawtooth fkf^k
llnumber of layers of the comparison network gg
mmtotal number of units of the comparison network gg
Cr(g)\mathrm{Cr}(g)crossing number, the number of intervals on which gg stays on one side of 12\tfrac12; Cr(g)≤2(2m/l)l\mathrm{Cr}(g)\le2(2m/l)^l for a ReLU network
ssstandard deviation of noise added to the weights; the sawtooth's teeth survive only for s≲2−ks\lesssim2^{-k}
z(x)z(x)a neuron's preactivation, the input to its ReLU, an affine function of the previous layer's outputs
IIa segment of a line x=vt+cx=vt+c in input space, of length ∣I∣|I|, on which linear pieces are counted
Transformer shapes
ddresidual width (512 in d8)
VVvocabulary size (4,096 in d8)
hhfinal hidden state of one context, h∈Rdh\in\mathbb R^d
WWoutput head (unembedding) W∈RV×dW\in\mathbb R^{V\times d}, which maps the final hidden state to the logits
zzlogits z=Whz=Wh, one score per vocabulary token
HHmatrix whose rows are the final hidden states of all contexts
log⁡Z\log Zcolumn of the log softmax normalizers, one per context (row of HH)
PPmatrix of next-token probabilities, one row per context and one column per token, log⁡P=HW⊤−log⁡Z 1⊤\log P=HW^\top-\log Z\,\mathbf 1^\top
gtg_tgradient of the cross-entropy with respect to the logits at position tt, gt=softmax(zt)−ext+1∈RVg_t=\mathrm{softmax}(z_t)-e_{x_{t+1}}\in\mathbb R^V
eye_yone-hot vector of token yy
UUorthonormal basis of the column space of the output head WW
EEfraction of gradient energy outside the column space of WW, E=∑t∥gt−UU⊤gt∥2/∑t∥gt∥2E=\sum_t\|g_t-UU^\top g_t\|^2/\sum_t\|g_t\|^2; a random subspace gives 1−d/V1-d/V (0.875 in d8)
Q,KQ,Kqueries and keys of one attention head; the score matrix QK⊤QK^\top has rank at most dheadd_{\rm head}
dheadd_{\rm head}head dimension, which caps the rank of the score matrix QK⊤QK^\top (64 in d8)
nnnumber of keys a head attends over (128 in Lecture 9's fitting experiment)
NeN_enumber of experts in a mixture of experts
fif_ifraction of the TbT_b tokens in a batch sent to expert ii, counted from the hard assignments
PiP_ithe router's mean probability for expert ii over a batch
TbT_bnumber of tokens per batch
Automata
QQfinite state set of a semiautomaton
qtq_tstate of the semiautomaton after step tt, qt=δ(qt−1,at)q_t=\delta(q_{t-1},a_t)
ata_tinput symbol read at step tt (Liu et al. write σt\sigma_t)
δ\deltatransition map, which gives the next state δ(q,a)\delta(q,a) from a state qq and an input aa
δt\delta_tthe map δt=δ(⋅,at)\delta_t=\delta(\cdot,a_t) from QQ to QQ that input tt applies
TTsequence length
Compute yardstick (Assignment 5)
CCtraining compute of a model or method
C0C_0training compute of d8, the unit of the dense reference curve
L∞L_\inftyasymptote of the dense reference curve L^ref(C)=L∞+A(C/C0)−α\hat L_{\rm ref}(C)=L_\infty+A(C/C_0)^{-\alpha}, the loss it approaches as compute grows
AAcoefficient of the dense reference curve L^ref(C)=L∞+A(C/C0)−α\hat L_{\rm ref}(C)=L_\infty+A(C/C_0)^{-\alpha}
α\alphaexponent of the dense reference curve L^ref(C)=L∞+A(C/C0)−α\hat L_{\rm ref}(C)=L_\infty+A(C/C_0)^{-\alpha}
Ceq(L)C_{\rm eq}(L)compute a dense model needs to reach loss LL, Ceq(L)=C0(A/(L−L∞))1/αC_{\rm eq}(L)=C_0\big(A/(L-L_\infty)\big)^{1/\alpha}
Constants
CgradC_{\rm grad}bound on the mean gradient norm E∥∇z(x)∥\mathbb E\|\nabla z(x)\| of every neuron's preactivation, set by the initialization, in Hanin and Rolnick's piece count
CbiasC_{\rm bias}bound on the probability density of every neuron's bias, set by the initialization, in Hanin and Rolnick's piece count
λbal\lambda_{\rm bal}weight of the Switch Transformer's load-balancing loss λbalNe∑ifiPi\lambda_{\rm bal}N_e\sum_if_iP_i

Context. One hidden layer can approximate any continuous function on a compact set whenever the activation is not a polynomial. With ReLU σ(z)=max⁡(z,0)\sigma(z)=\max(z,0), a single hidden layer matches a one-dimensional target by placing a hinge σ(t−ti)\sigma(t-t_i) at each grid point tit_i, weighted by the slope jump there. Higher dimensions reduce to one by approximating the target as a sum of powers cj(wj⊤x)kjc_j(w_j^\top x)^{k_j} of linear projections and fitting each power along its line. Universal approximation says little about practice. On [0,1]din[0,1]^{d_{\rm in}}, a hinge grid needs about (1/ε)din(1/\varepsilon)^{d_{\rm in}} units to reach accuracy ε\varepsilon on a 1-Lipschitz function, where dind_{\rm in} is the input dimension. Any ReLU architecture that approximates every 1-Lipschitz function on [0,1]din[0,1]^{d_{\rm in}} to accuracy ε\varepsilon needs of order ε−din/2\varepsilon^{-d_{\rm in}/2} weights (Yarotsky, 2017). Even when a compact network can represent a function, gradient descent may never find it. Lecture 9 of Stanford CS 312 (Hashimoto and Kotha, Fall 2026) asks which network shapes express more, how much of that expressivity trained models use, and which transformer matrices create real bottlenecks.

Depth beats width exponentially in the worst case, but the separating functions oscillate sharply and collapse under tiny weight noise. Typical random and trained ReLU networks produce roughly one linear piece per neuron regardless of depth. Language-model loss shows the same pattern, tracking total parameter count far more than aspect ratio. Adding parameters at fixed per-token compute therefore relies on sparse layers such as mixtures of experts. The real architectural bottlenecks are narrow matrix products. An output head of rank at most the residual width dd caps log-probability rank at d+1d+1 and discards most of the backward gradient. Low-rank attention scores hurt far less because point lookups need little rank. On sequential tasks, fixed-depth transformers find parallel shortcuts that succeed in distribution but break on shifted distributions or longer sequences. Generating intermediate states through chain of thought supplies the serial depth they lack.

Setting. The course's the course's model organism: a transformer with 8 blocks and residual width 512, pre-trained on about 614M tokens of web text. Reading note: Prediction as understanding: the d8 model organism model fixes concrete dimensions: residual width d=512d=512, 64-dimensional attention heads, and SwiGLU MLPs of shape 512→1792→512512\to1792\to512. Its output head W∈RV×dW\in\mathbb R^{V\times d} (the unembedding) projects onto a vocabulary of V=4,096V=4{,}096 tokens, eight times the width. Assignment 5 runs four interventions on d8: a depth-width grid, low-rank factored output heads, a four-expert mixture of experts, and weight-shared block looping. Each is judged against ordinary dense scaling on the ladder d4 through d10, where model dD has DD blocks and width 64D64D. Fit a power-law reference curve L^ref(C)=L∞+A(C/C0)−α\hat L_{\rm ref}(C)=L_\infty+A(C/C_0)^{-\alpha} to loss against training compute CC, with C0C_0 the compute of d8, and invert it: Ceq(L)=C0(AL−L∞)1/α.C_{\rm eq}(L)=C_0\Big(\frac{A}{L-L_\infty}\Big)^{1/\alpha}. A method reaching loss LL at compute CC has dense-equivalent efficiency Ceq(L)/CC_{\rm eq}(L)/C. It pays off only when it beats spending the same compute on a larger dense model.

Folded sawtooths separate depth from width. Composing one ReLU fold multiplies linear pieces exponentially with depth. Two ReLU layers fold [0,1][0,1] onto itself: f(z)=σ(2σ(z)−4σ(z−12))=min⁡(2z, 2−2z)  on [0,1].\begin{aligned}f(z)&=\sigma\big(2\sigma(z)-4\sigma(z-\tfrac12)\big)\\&=\min(2z,\,2-2z)\ \text{ on }[0,1].\end{aligned} Composing ff with itself kk times yields a sawtooth fkf^k with 2k−12^{k-1} teeth and 2k2^k linear pieces. A network kk layers deep and two units wide builds it. A single hidden layer of ww units sums ww hinges and has at most w+1w+1 linear pieces on a line, so matching fkf^k takes width of order 2k2^k.

Telgarsky's crossing-number lower bound. Telgarsky (2016) turns piece counting into a formal L1L^1 separation. Write the crossing number of a function gg of one variable: the number of intervals on which gg stays on one side of 12\tfrac12, the pieces of the classifier 1[g≥12]\mathbb 1[g\ge\tfrac12] for the number of intervals where a one-variable network gg stays on one side of 12\tfrac12. Any ReLU network with ll layers and mm total units obeys Cr(g)≤2(2ml)l.\mathrm{Cr}(g)\le2\Big(\frac{2m}{l}\Big)^{l}. Depth sits in the exponent and average width in the base, while Cr(fk)=2k+1\mathrm{Cr}(f^k)=2^k+1. If gg has at most 2k−22^{k-2} intervals, each covers many alternating intervals of fkf^k, putting gg on the wrong side of 12\tfrac12 across at least a quarter of fkf^k's intervals. Each missed interval adds an error triangle of base 2−k2^{-k} and height 12\tfrac12, with area 2−k/42^{-k}/4, giving ∫01∣fk−g∣≥116\int_0^1|f^k-g|\ge\tfrac1{16} in the lecture's simplified count. Telgarsky's full theorem extends this separation to [0,1]din[0,1]^{d_{\rm in}} for every kk. Some ReLU network with 2k3+82k^3+8 layers and 3k3+123k^3+12 units stays at L1L^1 distance at least 164\tfrac1{64} from every network with at most kk layers and at most 2k2^k units. The bound still holds when the shallow network uses arbitrary a unit whose output is piecewise polynomial in its inputs, with the pieces cut out by polynomial inequalities; ReLU, max and indicator units are examples or boosted decision trees. Other worst-case constructions match this picture. Linear-region counts can grow exponentially with depth (Montúfar et al., 2014), and radial functions built cleanly in three layers require exponential width in two (Eldan and Shamir, 2016).

In practice, loss tracks parameter count far more than shape. Empirical scaling sweeps find almost none of this exponential depth advantage. Kaplan et al. (2020) hold non-embedding parameters fixed across language models from 50M to 1.5B parameters and vary the the residual width divided by the number of layers, d/nlayerd/n_{\rm layer} by a factor of 40. Loss barely moves: a 6-layer model of width 4,288 lands within 3% of a 48-layer model of width 1,600. Only models with zero or one layer, or with extreme depth-to-width ratios, leave the shared loss-versus-parameters curve. Vision models behave similarly. A 40-layer wide ResNet beats a 1,001-layer thin ResNet of comparable size on CIFAR-100 (Zagoruyko and Komodakis, 2016). Scaling depth, width, and resolution together also outperforms scaling any single axis (Tan and Le, 2019). Depth can still matter more on downstream benchmarks than on pre-training loss (Tay et al., 2022). Deployment hardware also shifts the best shape, as in MobileLLM, which uses a deep, thin layout with shared embeddings and repeated blocks to save parameters on phones.

Adding parameters at fixed compute via mixture of experts. Because loss tracks total parameter count, raising capacity at a fixed per-token compute budget requires parameters that only some tokens activate. A a layer of several feed-forward networks (experts) with a learned router that sends each token to one or a few of them, so total parameters grow while compute per token stays fixed does this, and its router must spread tokens evenly across the NeN_e experts to keep hardware busy. The Switch Transformer (Fedus et al., 2022) enforces balance with the auxiliary loss λbalNe∑ifiPi\lambda_{\rm bal}N_e\sum_if_iP_i. Here fif_i is the fraction of the TbT_b batch tokens routed to expert ii, counted from hard assignments so it carries no gradient, and PiP_i is the router's mean probability for expert ii. Differentiating with respect to one token's router probability pi(x)p_i(x) yields λbalNefi/Tb\lambda_{\rm bal}N_ef_i/T_b. That gradient pushes down routing probability hardest for experts that are already overloaded.

Deep sawtooths collapse under tiny weight noise. Trained networks miss Telgarsky's exponential piece count first because the construction is fragile. Each fold has slope ±2\pm2, so a perturbation at layer jj grows by a factor of 2k−j2^{k-j} at the output. Weight noise of standard deviation ss therefore shifts the output by roughly 2ks2^ks, erasing the teeth unless s≲2−ks\lesssim2^{-k}. Hanin and Rolnick (2019) test this directly by adding Gaussian noise of standard deviation 0.1 to the sawtooth's weights and biases. The dense oscillations collapse into a few isolated spikes.

Random and trained networks realize roughly one piece per neuron. Typical networks also stay far below exponential region counts, both at initialization and after training. Hanin and Rolnick (2019) restrict a ReLU network to a line x=vt+cx=vt+c in input space. Each neuron's the input z(x)z(x) to a neuron's ReLU, an affine function of the previous layer's outputs z(x)z(x) is piecewise linear along the line and adds a breakpoint whenever it crosses its bias. Under independent zero-mean Gaussian weights with variance 2/fan-in2/\text{fan-in}, where fan-in is the number of inputs to the unit; it keeps activations at the same scale through depth, every preactivation has order-one slope along the line and crosses its bias a bounded number of times per unit length, whatever the layer depth. On a segment II of length ∣I∣|I|, E #{pieces on I}≈∣I∣⋅#{neurons}⋅CgradCbias.\begin{aligned}&\mathbb E\,\#\{\text{pieces on }I\}\\&\quad\approx|I|\cdot\#\{\text{neurons}\}\cdot C_{\rm grad}C_{\rm bias}.\end{aligned} The constants a bound on the mean gradient norm E∥∇z(x)∥\mathbb E\|\nabla z(x)\| of every neuron's preactivation and a bound on the probability density of every neuron's bias depend only on the initialization. Counted on [−1,1][-1,1], random He-initialized ReLU networks of depths 1, 2, 4, and 8 all sit on one line of about one piece per neuron. Over 20 epochs of MNIST training, the piece count per neuron dips and rebounds near its starting value without growing with depth. The mean distance from an input to the nearest region boundary stays between 0.4 and 1.5 divided by the neuron count. Gradient descent also fits low frequencies first (Rahaman et al., 2019). On a sum of sinusoids, a three-layer MLP learns low frequencies well before high ones, because high-frequency structure demands many active breakpoints or large weights that grow slowly.

The softmax bottleneck at the output head. Narrow matrix products inside a transformer can bind much more tightly than depth-versus-width shape. In d8, MLPs are full rank and each attention head's score matrix QK⊤QK^\top has rank at most 64. The output head maps the final hidden state h∈Rdh\in\mathbb R^d to vocabulary logits z=Whz=Wh, capping logit rank across contexts at d=512d=512 against V=4,096V=4{,}096 tokens. Stack the final hidden states of all contexts as rows of HH, and let log⁡Z\log Z be the column of log softmax normalizers. The context-by-token log-probability matrix then satisfies log⁡P=HW⊤−log⁡Z 1⊤,rank(log⁡P)≤d+1.\begin{aligned}\log P&=HW^\top-\log Z\,\mathbf 1^\top,\\\mathrm{rank}(\log P)&\le d+1.\end{aligned} Yang et al. (2018) call this the the limit d+1d+1 on the rank of the log-probability matrix of any model whose logits are a linear map of a dd-dimensional hidden state: log⁡P=HW⊤−(log⁡Z)1⊤\log P=HW^\top-(\log Z)\mathbf 1^\top has rank at most d+1d+1, however many contexts and tokens there are (Yang et al., 2018). If natural language has true conditional log-probabilities of rank above d+1d+1, no depth or width below the head can match them, and nothing follows the head to restore rank. Replacing the single softmax with a p(y∣h)=∑jπj(h) softmax(Wjh)yp(y\mid h)=\sum_j\pi_j(h)\,\mathrm{softmax}(W_jh)_y, a mixture of several softmax distributions with weights πj(h)\pi_j(h) that depend on the context; its log is not linear in hh, so its rank is not capped by dd lifts the cap. On Penn Treebank (V=10,000V=10{,}000), log-probability rank jumps from the embedding width of 400 to 9,981. On One Billion Word, where overfitting is minimal, test perplexity falls from 42.8 to 37.1 and training perplexity drops from 41.5 to 36.4, confirming an expressivity gain rather than regularization. On character-level models, where VV is smaller than dd and the cap never binds, the mixture adds nothing.

The output head also filters the backward gradient. The same rank cap chokes learning signal entering the body. At position tt, the cross-entropy gradient with respect to the logits is gt=softmax(zt)−ext+1∈RVg_t=\mathrm{softmax}(z_t)-e_{x_{t+1}}\in\mathbb R^V, where ext+1e_{x_{t+1}} is the next token's one-hot vector. Backpropagation passes W⊤gtW^\top g_t to the final layer, wiping out every component of gtg_t outside the the span of the columns of WW, here a subspace of RV\mathbb R^V of dimension at most dd of WW. Let UU be an orthonormal basis of that subspace. The fraction of logit-gradient energy discarded is E=∑t∥gt−UU⊤gt∥2∑t∥gt∥2,E=\frac{\sum_t\|g_t-UU^\top g_t\|^2}{\sum_t\|g_t\|^2}, against 1−d/V1-d/V for a random subspace, or 0.875 in d8. Across GPT-2, Pythia, Llama 3, OLMo 2, and Qwen 3, Godey and Artzi (2026) find 95 to 99% of the gradient norm lost. In 2B-parameter models with a factored output head, raising head rank from 32 to 4,096 speeds training 16-fold. The rank-4,096 model reaches the rank-32 model's final loss, set after about 11B tokens, in 700M tokens. As a control, a one-layer model repeating a random symbol 64 times needs only a copying rule that a low-rank head can express. Failing to learn that task therefore does not implicate head expressivity. Assignment 5 compares how much a mixture of softmaxes, Kanai et al.'s (2018) sigmoid-corrected softmax, and a context copy path lift the head's the rank an ordinary softmax head would need to reach a method's loss, read off the curves of loss against head rank (Assignment 5).

Attention score rank rarely binds. An attention head of dimension dheadd_{\rm head} forms a score matrix QK⊤QK^\top of rank at most dheadd_{\rm head}, below the key count nn in long contexts. In practice, that cap costs far less than the output head's. In a width-512 BERT-style model with dhead=128d_{\rm head}=128, adding heads from 8 to 32 raises a reading-comprehension benchmark, scored here by F1, the overlap between predicted and true answer spans F1 from 89.6 to 90.95, though total parameters also climb from 168M to 319M (Bhojanapalli et al., 2020). In standard BERT-large, splitting width 1,024 into 32 heads instead of 8 shrinks dheadd_{\rm head} and nudges F1 down slightly, from 90.89 to 90.45. Lecture 9's fitting test shows why. Over n=128n=128 keys, a head matches a one-hot target row closely at dhead≈16d_{\rm head}\approx16, whereas a random diffuse row needs dhead≥nd_{\rm head}\ge n. Point lookups require little rank, and retrieval accounts for many practical attention patterns.

Parallel shortcuts for sequential tasks. Attention handles lookups and copying easily, whereas copying a length-TT string takes Ω(T)\Omega(T) bits of state in a recurrence (Sanford et al., 2023; Jelassi et al., 2024). State tracking, by contrast, is sequential. Model a sequential process as a qt=δ(qt−1,at)q_t=\delta(q_{t-1},a_t): a finite set of states QQ, a finite set of input symbols ata_t, and a transition map δ\delta that gives the next state from the current state and input; it reads the inputs one at a time and updates its state, qt=δ(qt−1,at)q_t=\delta(q_{t-1},a_t), with states qt∈Qq_t\in Q and inputs ata_t. Write δt=δ(⋅,at)\delta_t=\delta(\cdot,a_t) for the transition applied at step tt. Associativity lets a fixed-depth network compose transitions in a binary tree (Liu et al., 2023): qt=δt∘δt−1∘⋯∘δ1(q0),δ4∘δ3∘δ2∘δ1=(δ4∘δ3)∘(δ2∘δ1).\begin{aligned}&q_t=\delta_t\circ\delta_{t-1}\circ\cdots\circ\delta_1(q_0),\\&\delta_4\circ\delta_3\circ\delta_2\circ\delta_1\\&\quad=(\delta_4\circ\delta_3)\circ(\delta_2\circ\delta_1).\end{aligned} A transformer of depth O(log⁡T)O(\log T) and width polynomial in ∣Q∣|Q| can therefore simulate any semiautomaton over length TT. Some tasks collapse even further. Parity takes one layer: attention averages the inputs to count ones, and the MLP reduces mod 2. Every built from no non-solvable group such as S5S_5, the permutations of five objects; such a semiautomaton splits into counters and memory units (the Krohn-Rhodes decomposition) semiautomaton needs depth depending only on ∣Q∣|Q|, independent of TT, and a 1D gridworld moving left or right between walls needs depth 2. Gradient descent finds these shortcuts in practice. Across 19 semiautomata at T=100T=100, transformers with at most 16 layers top 99% held-out accuracy on every one.

Shortcuts fail out of distribution and at new lengths. Parallel shortcuts are brittle because they rely on the training distribution. A transformer that solves parity by counting ones breaks on rarely encountered counts, so accuracy falls as the probability of a 1 shifts away from the training value of 0.5. Both parity and bracket matching also degrade rapidly on sequences longer than those seen in training, while an LSTM tracks the recurrence at 100% accuracy. Shifting positions during training or dropping positional encodings helps only partially. Writing each intermediate state to a intermediate tokens the model writes before its answer, here the automaton's state at each step, combined with attention biased toward recent tokens, restores the recurrent algorithm.

Complexity limits and chain of thought. Circuit complexity makes the fixed-depth barrier sharp (Merrill and Sabharwal, 2023; Merrill et al., 2024). A fixed-depth transformer with numbers stored with O(log⁡n)O(\log n) bits for inputs of length nn, enough to index positions lies inside the class of problems solved by constant-depth, polynomial-size circuits with AND, OR, NOT and majority gates of any fan-in; it includes counting and parity. It can count and compute parity, yet it cannot simulate every finite automaton at arbitrary length unless TC0\mathsf{TC}^0 equals the class of problems solved by polynomial-size circuits of logarithmic depth with gates of fan-in two; it includes every regular language, which is widely believed false. The canonical hard example is the word problem of S5S_5, tracking a product of permutations of five objects. Under constant precision, a fixed-depth transformer cannot even compute parity. intermediate tokens a model generates before its answer, each computed from the input and all earlier tokens, so that each token adds one step of serial computation beyond the model's fixed depth (Merrill and Sabharwal, 2024) supplies the missing serial depth. Linearly many extra tokens in the input length nn suffice for every regular language, and polynomially many solve exactly the problems in P (Merrill and Sabharwal, 2024; Li et al., 2024). Looping a transformer block adds depth in the same spirit without adding parameters.

Limits. Depth-separation theorems rely on worst-case oscillating functions that trained networks rarely build, though that does not prove depth never helps, especially downstream. Hanin and Rolnick prove their region-count formula at initialization for fully connected ReLU networks and test it during MNIST training; no comparable count is given here for transformers. Kaplan et al.'s aspect-ratio invariance comes from one family of language models. Rank bounds capture representational limits, not compute tradeoffs. Whether a richer output head earns its extra compute is empirical, which Assignment 5's dense-equivalent efficiency tests directly.

Terms

universal approximation
one hidden layer approximates any continuous function on a compact set for a non-polynomial activation; the width needed can grow like (1/ε)din(1/\varepsilon)^{d_{\rm in}}
sawtooth fkf^k
kk folds of min⁡(2z,2−2z)\min(2z,2-2z): 2k2^k linear pieces from a network kk deep and 2 wide; one hidden layer needs about 2k2^k units
crossing bound
Cr(g)≤2(2m/l)l\mathrm{Cr}(g)\le2(2m/l)^l for ll layers and mm units: depth in the exponent, width in the base
Telgarsky's theorem
2k3+82k^3+8 layers and 3k3+123k^3+12 units stay L1L^1 distance ≥164\ge\tfrac1{64} from every network with ≤k\le k layers and ≤2k\le2^k units
realized pieces
at initialization, pieces on a segment ≈∣I∣⋅#neurons⋅CgradCbias\approx|I|\cdot\#\text{neurons}\cdot C_{\rm grad}C_{\rm bias}, independent of depth; stays near that in training
shape vs size
LM loss changes slightly over a 40-fold range of aspect ratio at fixed parameters; 0- and 1-layer models and extreme ratios are the exceptions
softmax bottleneck
log⁡P=HW⊤−log⁡Z 1⊤\log P=HW^\top-\log Z\,\mathbf 1^\top has rank ≤d+1\le d+1
gradient bottleneck
W⊤W^\top keeps only the part of the logit gradient in the column space of WW; a random subspace keeps d/Vd/V of the energy
attention rank
QK⊤QK^\top has rank ≤dhead\le d_{\rm head}; one-hot rows need little rank, diffuse random rows need dhead≥nd_{\rm head}\ge n
shortcuts to automata
associativity gives depth O(log⁡T)O(\log T) for any semiautomaton, depth independent of TT for solvable ones; brittle out of distribution and at new lengths
chain of thought
linearly many extra tokens: every regular language; polynomially many: exactly P
dense-equivalent efficiency
Ceq(L)/CC_{\rm eq}(L)/C: compute a dense model needs for loss LL, over the compute used

Sources

Lecture 9, “Architecture 2: Expressivity (depth vs. width, realized expressivity, transformer bottlenecks)” (Nov 5, 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

The lessons, experiments, figures and quiz problems in this note are the course's, shown here with the instructors' permission.

Connected notes

Threads