Sam Babichenko

Reading notes / Deep Learning Alchemy

Signal propagation in depth

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

slides quiz answers assignment code

Residual stream
xlx_lthe residual stream after block ll, xl+1=xl+Fl(xl)x_{l+1}=x_l+F_l(x_l); x0x_0 is the embedded input
FlF_lthe branch of block ll, the part added to the stream: convolutions with batch norm in a ResNet, an attention or MLP sublayer with its input norm in a transformer
LLa later block, or the number of blocks
EEa generic loss, differentiated through the unrolled residual sum
L\mathcal Lthe mean next-token loss of the course's runs
λ\lambdaconstant multiplying every shortcut (ResNet v2), which turns the identity term into λL−lI\lambda^{L-l}I
g(x)g(x)learned sigmoid gate on the shortcut, which becomes (1−g) x(1-g)\,x
α2\alpha^2a branch's output variance divided by the stream's, at initialization; independent branches give Var(xl)=(1+α2)lVar(x0)\mathrm{Var}(x_l)=(1+\alpha^2)^l\mathrm{Var}(x_0)
NNnormalization layer (RMSNorm or LayerNorm)
Mean-field theory
hlh^lpreactivations of layer ll, hl=Wlφ(hl−1)+blh^l=W^l\varphi(h^{l-1})+b^l, a vector of width nn
φ\varphiactivation function of the wide fully connected network
WlW^lweight matrix of layer ll, with entries Wijl∼N(0,σw2/n)W^l_{ij}\sim N(0,\sigma_w^2/n)
blb^lbias vector of layer ll, with entries bil∼N(0,σb2)b^l_i\sim N(0,\sigma_b^2)
nnwidth of each layer
σw2/n\sigma_w^2/nvariance of each weight entry WijlW^l_{ij} at initialization
σb2\sigma_b^2variance of each bias entry bilb^l_i at initialization
qlq^lvariance of one preactivation coordinate of layer ll for a single input, over the random weights
q∗q^*fixed point of the preactivation variance qlq^l, where the variance settles quickly with depth
clc^lcorrelation between the preactivations hl(a)h^l(a) and hl(b)h^l(b) of two inputs aa and bb
χ1\chi_1χ1=σw2 Ez[φ′(q∗z)2]\chi_1=\sigma_w^2\,\mathbb E_z[\varphi'(\sqrt{q^*}z)^2], the slope of the correlation map at c=1c=1; χ1<1\chi_1\lt 1 is the ordered phase and χ1=1\chi_1=1 the edge of chaos
ξc\xi_cdepth scale over which correlations approach 1, ∣cl−1∣∝e−l/ξc|c^l-1|\propto e^{-l/\xi_c}; ξc=−1/log⁡χ1\xi_c=-1/\log\chi_1 in the ordered phase
Skipless transformers
XlX_lmatrix of token representations after layer ll, one row per token of a sequence
ddwidth of the token representations XlX_l
AlA_lattention matrix of layer ll, in the simplified model Xl=AlXl−1X_l=A_lX_{l-1}
Σl\Sigma_ltoken Gram matrix Σl=1dXlXl⊤\Sigma_l=\tfrac1dX_lX_l^\top
ClC_lCholesky factor of the target Gram matrix of layer ll, Σl=ClCl⊤\Sigma_l=C_lC_l^\top
Hyper-connections
mmnumber of parallel residual streams (the paper writes n; 4 in the 27B mHC run)
CCmodel width; with hyper-connections the stream is xl∈Rm×Cx_l\in\mathbb R^{m\times C}
HlresH^{\rm res}_lm×mm\times m matrix mixing the parallel streams at layer ll, started at II
HlpreH^{\rm pre}_l1×m1\times m row that reads the input of layer ll from the streams, Fl(Hlprexl)F_l(H^{\rm pre}_lx_l)
HlpostH^{\rm post}_lrow that writes the output of layer ll back to the streams through (Hlpost)⊤Fl(⋅)(H^{\rm post}_l)^\top F_l(\cdot); started at all ones
Constants
66empirical factor in the trainable-depth fit L≲6ξcL\lesssim6\xi_c
−6-6best starting gate bias for ResNet v2's gated shortcuts

Context. For decades, networks more than a few layers deep were hard to train end to end. On ImageNet, a 34-layer plain network had higher training error than an 18-layer one even with careful initialization, ReLU activations, and batch normalization. Higher training error ruled out overfitting and pointed straight to optimization. shortcuts that add a block's input to its output, xl+1=xl+Fl(xl)x_{l+1}=x_l+F_l(x_l), so that each block learns a correction to what it receives (He et al., 2016) broke that barrier: ResNet-34 reaches 25.0% top-1 error on ImageNet against ResNet-18's 27.9%. Lecture 7 of Stanford's CS 312, Deep Learning Alchemy (Hashimoto and Kotha, Fall 2026), examines why residual depth trains cleanly and how far initialization-time theory explains shortcuts and normalization. It also asks where newer residual designs leave that theory behind. Assignment 4 and Quiz 4 test these ideas on the course's the course's small reference model, an 8-block transformer pre-trained on about 614M tokens, on which every assignment experiment is run. Reading note: Prediction as understanding: the d8 model organism.

A deep network trains when forward signals and backward gradients cross every layer with their scale and geometry intact. Norms must not vanish or explode, and distinct inputs must stay distinguishable. A clean identity path delivers this almost automatically. It turns the the matrix of derivatives of a late layer's output with respect to an early layer's input, ∂xL/∂xl\partial x_L/\partial x_l; it carries the gradient from the late layer back to the early one, and for residual blocks it is the product ∏m=lL−1(I+∂Fm/∂xm)\prod_{m=l}^{L-1}(I+\partial F_m/\partial x_m) into the identity plus branch terms, giving every layer a unit-gain route to the loss. Tracking variances and input correlations at initialization predicts which shortcut edits break training, where normalization belongs, and how deep a plain network can train. Initialization theory still has limits. Newer designs depart from the identity, using learned mixing across parallel streams or attention over earlier layers, and can beat plain residuals when their depth-wise products stay bounded.

Setting. Write the residual stream after block ll: the running sum that every block reads and adds to, with x0x_0 the embedded input for the residual stream after block ll and block ll's branch: a few convolutions with batch norm in a ResNet, an attention or MLP sublayer with its input norm in a transformer for its branch, so each block computes xl+1=xl+Fl(xl)x_{l+1}=x_l+F_l(x_l). The course's model-organism runs train width-512 models with vocabulary 4,096, context length 1,024, and batch size 64. Each run takes 9,375 Adam with decoupled weight decay; each coordinate moves by the learning rate times a running average of its gradient (the momentum), divided by the square root of a running average of its squared gradient, so every coordinate takes a step of similar size; weight decay then shrinks every weight by a small fixed fraction per step, applied to the weights directly instead of through that division (Loshchilov and Hutter, 2019) updates over 614.4M token slots, with 1% warmup and linear decay. The default transformer has 8 xl+1=xl+Fl(N(xl))x_{l+1}=x_l+F_l(N(x_l)), with FlF_l here the sublayer alone: each sublayer's input is normalized and its output is added to a stream that is itself never normalized blocks with division of a vector by its root mean square, followed by a learned per-coordinate gain, QK-norm, rotary position embedding: queries and keys are rotated by angles proportional to their positions, so attention scores depend on relative position, and a gated MLP: the elementwise product of a SiLU-activated projection and a linear projection, followed by an output projection, where SiLU(z)=z/(1+e−z)\mathrm{SiLU}(z)=z/(1+e^{-z}) MLPs. The RNN baseline has 4 blocks, each pairing a tanh recurrence and a SwiGLU MLP with depth residuals and pre-norm layer normalization: subtract a vector's mean across its coordinates, divide by their standard deviation, then apply a learned gain and bias.

What it changes in practice. Keep an unscaled identity path from embedding to output, and normalize either each branch's input (pre-norm) or both its input and output (xl+1=xl+N(Fl(N(xl)))x_{l+1}=x_l+N(F_l(N(x_l))), with FlF_l here the sublayer alone: a normalization both before and after each sublayer, with the stream itself left unnormalized; used in Gemma models (OLMo 2 keeps only the norm after each sublayer)). Start each branch near zero; a learnable branch scalar initialized at zero trains 1,000-block networks without normalization. Leave the shortcut itself untouched by scaling, gating, convolutions, or dropout, and log activation and gradient RMS block by block so propagation failures show up right away. When widening the stream into parallel copies, keep the mixing matrices with nonnegative entries and every row and every column summing to 1 so their product across depth stays bounded. Stable training still does not guarantee that late layers do useful work, and skipless networks need several times the step budget to train.

Anything that scales or blocks the shortcut breaks a deep ResNet. Unrolling the recursion from block ll to a later block LL and differentiating a loss EE separates the identity route from the branches:xL=xl+∑i=lL−1Fi(xi),∂E∂xl=∂E∂xL(I+∂∂xl∑i=lL−1Fi(xi)).\begin{aligned}x_L&=x_l+\sum_{i=l}^{L-1}F_i(x_i),\\\frac{\partial E}{\partial x_l}&=\frac{\partial E}{\partial x_L}\Big(I\\&\quad+\frac{\partial}{\partial x_l}\sum_{i=l}^{L-1}F_i(x_i)\Big).\end{aligned}The identity term passes the gradient from block LL to block ll unchanged, regardless of what the branches compute. He et al. (2016, ResNet v2) multiply every shortcut by a constant λ\lambda, turning that identity term into λL−lI\lambda^{L-l}I. That factor vanishes exponentially for λ<1\lambda\lt 1 and explodes for λ>1\lambda\gt 1. They also test a learned sigmoid gate g(x)g(x) on the shortcut. On CIFAR-10 with a 110-layer ResNet (54 two-layer residual units, 5-run medians), every edit to the shortcut raised test error, and several that start far from the identity failed:
CIFAR-10 test error, ResNet-110 (He et al., 2016)
Shortcut (branch)Error (%)
xx (FF), the original6.61
0.5 x0.5\,x (FF)fail
0.5 x0.5\,x (0.5 F0.5\,F)12.35
(1−g) x(1-g)\,x (g Fg\,F), best start8.70
(1−g) x(1-g)\,x (FF), gate nearly open6.91
1×11\times1 convolution (FF)12.22
Dropout 0.5 on xx (FF)fail
"Fail" means test error above 20%. The gated shortcuts need a strongly negative starting gate bias (−6-6 was best; exclusive gating failed from 0 to −5-5). That bias keeps 1−g≈11-g\approx1, so the shortcut starts close to the identity.The halved shortcut with a halved branch converges, but to higher training error than the original, so the damage is to optimization.

Clearing operations off the shortcut helps both ResNets and transformers. Moving batch norm and ReLU off the stream into the branch (the ResNet v2 block, which applies batch norm and ReLU before each convolution inside the branch, so that nothing acts on the stream after the addition) lowers CIFAR-10 error to 6.37% at 110 layers, and cuts 1,001-layer error from 7.61% to 4.92%. On d8 at learning rate 0.003, scaling the skip path behaves the same way. Multiplying the shortcut by 0.5 raised final validation loss from 2.9267 to 3.2269, while multiplying it by 2 cost far less (2.9500). Adding unit-variance Gaussian noise on the residual path barely hurt (2.9662); the lecture suggests the stream may already have a high signal-to-noise ratio.

Most of the gradient takes short paths, and late layers can be removed. Expanding nn residual blocks yields 2n2^n paths of binomially distributed length, one per subset of branches. In a 54-block ResNet, Veit et al. (2016) found that most gradient travels along paths only 5 to 17 blocks long, well below the typical length of 27. Deleting one block from a trained ResNet barely changes its error, whereas deleting one layer of a plain network ruins it. Large language models show the same redundancy. In Llama-2, DeepSeek-7B, and Qwen3, removing most single layers beyond about layer 18 barely moves a multiple-choice benchmark of questions from 57 academic and professional subjects (Sun et al., 2025). Stable training and active use of every layer are therefore separate questions.

At initialization, one number decides whether depth preserves input differences. Even when activation magnitudes stay finite, a deep plain network can collapse distinct inputs onto the same vector or scramble nearby inputs apart. Schoenholz et al. (2017) analyze a wide fully connected network hl=Wlφ(hl−1)+blh^l=W^l\varphi(h^{l-1})+b^l with weights Wijl∼N(0,σw2/n)W^l_{ij}\sim N(0,\sigma_w^2/n) and biases bil∼N(0,σb2)b^l_i\sim N(0,\sigma_b^2). In their the large-width limit in which each layer's preactivations are Gaussian, so a variance qlq^l and an input correlation clc^l describe the whole layer; both obey one-dimensional recursions in ll whose fixed points and slopes decide whether signals die, saturate or propagate (Schoenholz et al., 2017), the preactivations the preactivations of layer ll, a vector of width nn are Gaussian, so two scalars track any input pair a,ba,b: the single-input coordinate variance the variance of one coordinate of hlh^l for a single input, over the random weights and the correlation the correlation between the preactivations hl(a)h^l(a) and hl(b)h^l(b) of two inputs aa and bb between hl(a)h^l(a) and hl(b)h^l(b). Variance settles quickly at a fixed point q∗q^*, and c=1c=1 is always a fixed point of the correlation map. Its slope at c=1c=1 is χ1\chi_1, which in the ordered phase sets the correlation depth scale ξc\xi_c (for z∼N(0,1)z\sim N(0,1)):χ1=σw2 Ez[φ′(q∗ z)2],ξc=−1/log⁡χ1.\begin{aligned}\chi_1&=\sigma_w^2\,\mathbb E_z\big[\varphi'(\sqrt{q^*}\,z)^2\big],\\\xi_c&=-1/\log\chi_1.\end{aligned}In the ordered phase (χ1<1\chi_1\lt 1), every input pair converges to correlation 1 at rate ∣cl−1∣∝e−l/ξc|c^l-1|\propto e^{-l/\xi_c}, erasing input differences. In the chaotic phase (χ1>1\chi_1\gt 1), nearby inputs pull apart toward a fixed point c∗<1c^*\lt 1, where the slope at c∗c^* sets ξc\xi_c. The depth scale diverges on the the curve χ1=1\chi_1=1 in the plane of (σw2,σb2)(\sigma_w^2,\sigma_b^2), where χ1=σw2 E[φ′(q∗z)2]\chi_1=\sigma_w^2\,\mathbb E[\varphi'(\sqrt{q^*}z)^2] for z∼N(0,1)z\sim N(0,1); where χ1<1\chi_1\lt 1 correlations between inputs converge to 1 with depth (ordered phase), where χ1>1\chi_1\gt 1 nearby inputs are pulled apart (chaotic phase) (Schoenholz et al., 2017) χ1=1\chi_1=1. Backward gradient variance multiplies by the same χ1\chi_1 per layer, so gradients vanish in the ordered phase and explode in the chaotic phase.

The correlation depth scale predicts trainable depth, and dropout caps it. Schoenholz et al. tested fully connected networks on MNIST and CIFAR-10 with SGD and RMSProp across a grid of σw2\sigma_w^2 and depth LL. Training succeeded only where why: an empirical fit, not a derived bound; the authors observe that the trainable region ends near this curve and leave the factor 6 unexplained. Dropout destroys the critical point. Two passes of the same input draw independent masks, so correlation 1 stops being a fixed point. The order-to-chaos transition disappears, ξc\xi_c stays finite for every σw2\sigma_w^2, and trainable depth is capped.

Normalizing each branch's input keeps the variance growing linearly with depth. Suppose each branch at initialization adds an output independent of the stream with variance α2\alpha^2 times the stream's. Stream variance then grows exponentially:Var(xl)=(1+α2)l Var(x0).\mathrm{Var}(x_l)=(1+\alpha^2)^l\,\mathrm{Var}(x_0).For an unnormalized branch with α=1\alpha=1, that factor reaches 2l2^l. Normalizing each branch's input (batch norm in ResNets, pre-norm in transformers) holds every branch's output variance at order one instead (De and Smith, 2020). Stream variance then grows linearly like 1+l1+l, so block ll's relative contribution shrinks like 1/l1/l. Deep blocks start as small perturbations near the identity. Scaling each branch by 1/L1/\sqrt L bounds total growth by (1+1/L)l≤e(1+1/L)^l\le e. The direct version puts a learnable scalar initialized at zero on each branch (a learnable scalar multiplying each residual branch, initialized at zero, so that every block starts as the identity, closely related to ReZero and Fixup). On CIFAR-10 at depths 16, 100, and 1,000, De and Smith reach 93.5%, 94.7%, and 94.6% accuracy with batch norm, and 93.3%, 94.2%, and 94.3% with SkipInit and no normalization. Unnormalized scale-1 branches train only at depth 16, and dividing branches by 2\sqrt 2 fails at depth 1,000.

In transformers, pre-norm keeps the identity clean while post-norm rescales early layers at every block. Xiong et al. (2020) apply the same variance count to transformer normalization. Pre-norm, x+F(N(x))x+F(N(x)) with normalization layer NN, leaves the shortcut unscaled so variance grows like ll. normalizing after the residual addition, N(x+F(x))N(x+F(x)), as in the original transformer, N(x+F(x))N(x+F(x)), renormalizes the stream after every block. For a unit-RMS stream and an independent branch of variance Var F\mathrm{Var}\,F, each norm multiplies the identity path by ∥x∥/∥x+F∥≈1/1+Var F\|x\|/\|x+F\|\approx1/\sqrt{1+\mathrm{Var}\,F}, shrinking early signals at every later block. Initial gradients therefore concentrate in the last layers, which Xiong et al. link to post-norm's need for learning-rate warmup. The two placements also leave opposite ends idle (Sun et al., 2025), early layers in post-norm and late layers in pre-norm. Because a pre-norm stream sums all earlier branch outputs, later blocks must write larger outputs to move it. Quiz 4's answer slides offer this as one explanation for activation growth across depth in trained models. Peri-norm also normalizes each branch output, bounding stream growth and, in the lecture's view, controlling both the forward and backward passes.

Per-token normalization avoids batch norm's stale running statistics. Outside the lecture, rapid activation shifts early in training give a second reason transformers normalize each token individually (LayerNorm or RMSNorm) instead of across a minibatch. Batch normalization trains on current-batch statistics but evaluates with slow running averages, and training variants that use running averages still rely on them tracking the current weights. When activations shift faster than those averages can follow, the statistics describe an outdated network. Per-token norms compute fresh statistics at every step and never couple one example to the rest of its batch.

Norm placement shows directly in d8's activation and gradient RMS profiles. On the 8-block transformer, three variants edit both sublayers of every block: no pre-norm (x+F(x)x+F(x)), post-norm (N(x+F(x))N(x+F(x))), and no residual (F(N(x))F(N(x))). Each run logs the RMS of xlx_l and ∂L/∂xl\partial\mathcal L/\partial x_l at every block, where L\mathcal L is the mean next-token loss. Each profile matches the mechanisms above. Post-norm pins stream RMS at 1 by construction, while each norm rescales backward gradients and shrinks them in early blocks. Pre-norm keeps an unscaled path to every block. Without pre-norm, branches grow unchecked and early blocks feed the loss through every later branch plus the identity, so early blocks see the largest gradients. Without residuals, the plain 8-block stack suffers uncontrolled activation growth and vanishing gradients toward the input.

Built-in bounding makes normalization matter less to an RNN. The same depth ablations carry over to the 4-block RNN baseline (tanh recurrence plus SwiGLU MLP, depth residuals, and pre-LayerNorm). Because tanh bounds every recurrent state coordinate inside (−1,1)(-1,1), the RNN controls its own norm. Normalization therefore alters its stability and final loss far less than in the transformer, though it still reduces tanh saturation.

Plain networks train at extreme depth when the Jacobian starts near an isometry. Criticality (χ1=1\chi_1=1) fixes the mean squared singular value of the end-to-end Jacobian at 1, leaving its spread unconstrained. the condition that all singular values of the end-to-end Jacobian are close to 1, so that every direction of the gradient passes back with nearly unchanged size requires every singular value to sit near 1. Even with orthogonal weights, ReLU spreads singular values across depth, whereas tanh in its near-linear region keeps them tightly clustered (Pennington et al., 2017, 2018). Xiao et al. (2018) combine tanh, small initial preactivations, critical (σw2,σb2)(\sigma_w^2,\htmlData{gr=gn7}{\sigma_b^2}), and orthogonal convolution kernels to train plain 10,000-layer convolutional networks on MNIST and CIFAR-10. They see no accuracy gain past about 1,200 layers, however, and the initialization behaves almost like a deep linear network. Zhang et al. (2022) later remove skips and batch norm from a ResNet using tuned leaky ReLUs and a second-order optimizer.

Skipless transformers preserve token geometry via initialization, but train five times slower. Attention adds a second failure mode. Stacking attention matrices averages across tokens at every layer, contracting all token representations toward one another (the c→1c\to 1 collapse of mean-field theory; Dong et al., 2021). Model layer ll as Xl=AlXl−1X_l=A_lX_{l-1}, where the matrix whose rows are the representations of the tokens of one sequence after layer ll, of width dd stacks token rows of width dd and AlA_l is the attention matrix. The token Gram matrix Σl=1dXlXl⊤\Sigma_l=\tfrac1dX_lX_l^\top then evolves asΣL=(AL⋯A1) Σ0×(AL⋯A1)⊤.\begin{aligned}\Sigma_L&=(A_L\cdots A_1)\,\Sigma_0\\&\quad\times(A_L\cdots A_1)^\top.\end{aligned}Pick target Gram matrices Σl=ClCl⊤\Sigma_l=C_lC_l^\top with Cholesky factors ClC_l and set Al=ClCl−1−1A_l=C_lC_{l-1}^{-1}. The product telescopes to CLC0−1C_LC_0^{-1} and hits ΣL\Sigma_L exactly. He et al. (2023) realize this as valid initial attention (E-SPA) with a distance-decaying target. On WikiText-103, it takes a 36-block skipless transformer from untrainable (training loss near 7.5) down to 2.79, though it needs roughly five times as many steps as a pre-norm transformer. As the lecture summarizes, signal propagation theory prescribes keeping the end-to-end Jacobian near the identity. That constraint spans all layers, yet stays tractable because initialization and local behavior dominate.

Hyper-connections widen the residual stream, but unconstrained mixing explodes with depth. a residual design with several parallel copies of the stream, mixed by small learned matrices at every layer (Zhu et al., 2024) expand the residual stream into the number of parallel residual streams; the paper writes nn parallel copies, xl∈Rm×Cx_l\in\mathbb R^{m\times C} for model width CC, replacing the residual update withxl+1=Hlres xl+(Hlpost)⊤Fl(Hlpre xl).\begin{aligned}x_{l+1}&=H^{\rm res}_l\,x_l\\&\quad+(H^{\rm post}_l)^\top \htmlData{gr=g5}{F_l}\big(H^{\rm pre}_l\,x_l\big).\end{aligned}Here the 1×m1\times m row HlpreH^{\rm pre}_l reads the layer's input from the streams, HlpostH^{\rm post}_l writes its output back, and the m×mm\times m matrix HlresH^{\rm res}_l mixes the streams. Each of the three combines a learned constant with an input-dependent term. Setting Hlres=IH^{\rm res}_l=I, HlpreH^{\rm pre}_l to read one stream, and HlpostH^{\rm post}_l to all ones starts the network as standard pre-norm. In that setup, hyper-connections train an OLMoE a model whose MLP is split into many experts, of which a learned router activates a few per token model faster, with larger gains from more streams. Over many layers, however, the identity shortcut becomes the unconstrained product ∏lHlres\prod_lH^{\rm res}_l. In Xie et al.'s (2025) 27B model, that product's largest absolute row or column sum reached about 3,000, accompanied by a loss surge near step 12,000.

Manifold-constrained hyper-connections (mHC) keep composite mixing bounded. manifold-constrained hyper-connections: hyper-connections whose residual mixing matrices are constrained to be doubly stochastic (Xie et al., 2025) projects each HlresH^{\rm res}_l onto the doubly stochastic matrices via 20 iterations of the algorithm that alternately rescales the rows and the columns of a positive matrix to sum to 1; it converges to a doubly stochastic matrix. Reading note: Matrix scaling and Sinkhorn's theorem applied to exp⁡(H~lres)\exp(\tilde H^{\rm res}_l). It also constrains HlpreH^{\rm pre}_l and HlpostH^{\rm post}_l to be nonnegative with sigmoids. Every doubly stochastic matrix is a convex combination of permutations, so it has spectral norm at most 1 and preserves the mean across streams. Because the set is closed under multiplication, products of any depth stay doubly stochastic. With this approximate projection, the composite gain stayed below about 1.6. At 27B parameters (m=4m=4), mHC finished 0.021 lower in loss than the baseline, raising BIG-Bench Hard, a set of 23 hard reasoning tasks from 43.8 to 51.0 and a reading-comprehension benchmark whose questions need discrete reasoning such as counting and arithmetic over a paragraph from 47.0 to 53.9 (against 48.9 and 51.6 for unconstrained hyper-connections). It added 6.7% training time and was adopted in DeepSeek-V4.

Attention residuals leave the identity path altogether and still train well. Attention residuals (Kimi team) replace the running residual sum with a softmax over all earlier layer outputs. Each layer carries one learned query vector, while the earlier outputs serve as keys and values. The update starts uniform over earlier layers, far from an identity shortcut, and can focus on a few layers or skip others. Even so, it performs well in practice. The lecture closes on this tension. Variance tracking and end-to-end Jacobian tools explain why identity shortcuts work, yet they predicted neither mHC nor attention residuals.

Limits. Mean-field theory describes wide random networks at initialization. It predicts trainability rather than final loss, and its L≲6ξcL\lesssim6\xi_c boundary was fitted to fully connected networks on MNIST and CIFAR-10. The stream-variance calculation assumes branch outputs are independent of the stream, which holds only at initialization. The course's d8 and RNN results are single runs of small models on one dataset. Hyper-connection and mHC evidence comes from their authors' runs at 1B to 27B parameters, and attention-residual results come from a technical report.

Terms

identity path
xL=xl+∑iFi(xi)x_L=x_l+\sum_iF_i(x_i): the gradient reaches every block with gain one, whatever the branches do
scaled shortcut
λx\lambda x on every shortcut gives λL−l\lambda^{L-l} on the identity term: vanishing for λ<1\lambda\lt 1, exploding for λ>1\lambda\gt 1
χ1\chi_1
σw2 E[φ′(q∗z)2]\sigma_w^2\,\mathbb E[\varphi'(\sqrt{q^*}z)^2]: per-layer factor on correlations near 1 and on gradient variance
depth scale
ξc=−1/log⁡χ1\xi_c=-1/\log\chi_1 in the ordered phase; networks trained only where depth L≲6ξcL\lesssim6\xi_c
edge of chaos
χ1=1\chi_1=1: ξc\xi_c diverges; dropout removes this critical point
stream variance
(1+α2)l(1+\alpha^2)^l unnormalized; about 1+l1+l with normalized branches
pre-norm / post-norm
x+F(N(x))x+F(N(x)) keeps the identity clean; N(x+F(x))N(x+F(x)) divides early signals at every block
SkipInit
learnable branch scalar started at 0; trains 1,000 blocks without normalization
dynamical isometry
all singular values of the end-to-end Jacobian near 1; lets 10,000-layer plain networks train
E-SPA
attention at initialization chosen as Al=ClCl−1−1A_l=C_lC_{l-1}^{-1} to hit a target token kernel; trains skipless transformers about 5 times slower
mHC
hyper-connections with doubly stochastic HlresH^{\rm res}_l: products stay bounded (gain about 1.6 against 3,000)
attention residuals
softmax over earlier layer outputs with a learned query per layer, started uniform

Sources

Lecture 7, “Architecture 1: Signal propagation in depth” (Oct 22, 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 Online quiz Quiz answers 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

  • Online SGD's overlap with a hidden direction grows at the rate signal2^2/noise, which is tiny near a random start, so escaping takes about dk⋆−1d^{k^\star-1} samples for information exponent k⋆k^\star (the order of the first nonzero Hermite term) and almost all the samples are used up before the overlap grows.

  • Dividing the numerator of softmax attention by its L2 norm, which fixes the output's length, follows the softmax loss curve, while dividing by the sequence length behind a gate, with scores clamped at 5 and gradients clipped, still gives loss spikes.

  • 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 max⁡jRMS(vj)\max_j\mathrm{RMS}(v_j) while keeping direct shortcuts across depth without the matrix-product instability of multi-stream mixing.

  • At dimension 8, below about 2142^{14} pretraining tasks more data per task pulls the transformer toward the Bayes rule for the tasks it saw, and above 2152^{15} toward ridge, with the threshold growing roughly linearly in dimension.

Threads