Sam Babichenko

Reading notes / Matrix scaling and optimal transport

Matrix scaling and Sinkhorn's theorem

Sinkhorn, 1964; Sinkhorn and Knopp, 1967

Matrices and scalings
nnthe size of the square matrices
A,A, aija_{ij}the matrix to be scaled, with entries aija_{ij}, all positive in Steps 1 to 4
xxthe row scalings, a positive vector in Rn\mathbb R^n
yythe column scalings, a positive vector in Rn\mathbb R^n
Dx,D_x, DyD_ythe diagonal matrix with xx (or yy) on its diagonal; the paper writes D1D_1 for DxD_x and D2D_2 for DyD_y
BBthe scaled matrix DxADyD_xAD_y, with entries bij=xiaijyjb_{ij}=x_ia_{ij}y_j
1\mathbf 1the vector of nn ones; BB is doubly stochastic when B1=B⊤1=1B\mathbf 1=B^\top\mathbf 1=\mathbf 1
B∗B^*the doubly stochastic matrix of the form DxADyD_xAD_y, the limit of the iteration
cjc_jthe sum of column jj just after a row step; the cjc_j total nn
Potential
uulog⁡x\log x, entrywise
vvlog⁡y\log y, entrywise
FFthe potential ∑i,jaijeui+vj−∑iui−∑jvj\sum_{i,j}a_{ij}e^{u_i+v_j}-\sum_iu_i-\sum_jv_j; its slopes are the row and column sums of BB minus 1
hijh_{ij}the term of entry (i,j)(i,j) in FF, hij(w)=aijew−w/nh_{ij}(w)=a_{ij}e^w-w/n at w=ui+vjw=u_i+v_j
ttthe free factor: (x,y)→(tx,y/t)(x,y)\to(tx,y/t), or (u,v)→(u+t1,v−t1)(u,v)\to(u+t\mathbf 1,v-t\mathbf 1) in logarithms, leaves BB and FF unchanged
The 2 × 2 plane
α\alphau2−u1=log⁡(x2/x1)u_2-u_1=\log(x_2/x_1), the horizontal coordinate
β\betav2−v1=log⁡(y2/y1)v_2-v_1=\log(y_2/y_1), the vertical coordinate
MMa11+a12eβ+a21eα+a22eα+βa_{11}+a_{12}e^\beta+a_{21}e^\alpha+a_{22}e^{\alpha+\beta}, the total of the scaled entries with x1=y1=1x_1=y_1=1
Φ\Phi2log⁡M−α−β2\log M-\alpha-\beta, the potential minimized over the common factor, up to a constant
κ\kappathe cross-ratio a11a22/(a12a21)a_{11}a_{22}/(a_{12}a_{21}), unchanged by scaling
ppthe diagonal entry of B∗B^* for n=2n=2, with p/(1−p)=κp/(1-p)=\sqrt\kappa
Rate and uses
σ2\sigma_2the second-largest singular value of a matrix
μ\mutarget row sums, positive
ν\nutarget column sums, positive, with the same total as μ\mu
CCa cost matrix in optimal transport
ε\varepsilonthe weight of the entropy term; Cuturi writes λ=1/ε\lambda=1/\varepsilon
KKe−C/εe^{-C/\varepsilon}, entrywise, the matrix that entropic transport scales

Context. Any square matrix with positive entries can be made doubly stochastic, with every row and column summing to 1, by multiplying each row by one positive factor and each column by another. Sinkhorn (1964) proves that this scaled matrix is unique and that alternating row and column normalizations converge to it. Sinkhorn originally motivated the problem in statistics, scaling an estimated transition matrix of a Markov chain known to be doubly stochastic. Now called Sinkhorn-Knopp, the same iteration solves entropy-regularized optimal transport, balances cluster assignments in self-supervised learning, and keeps the stream-mixing matrices of manifold-constrained hyper-connections (Xie et al., 2025): a residual design with several parallel copies of the stream, mixed at every layer by learned m×mm\times m matrices that are projected onto the doubly stochastic matrices by 20 Sinkhorn-Knopp iterations, so that their product over depth stays bounded. Reading note: Signal propagation in depth bounded across depth.

The proof rests on one convex potential in the logarithms of the scalings. Its partial derivatives equal the row and column sums of the scaled matrix minus 1, so any doubly stochastic scaling is a global minimum. With every entry positive, the potential rises in every direction except one flat line along which both the potential and the scaled matrix stay unchanged. A minimum therefore exists and produces a unique scaled matrix. Row normalization minimizes the potential exactly over the row scalings, and column normalization over the column scalings, so the alternation descends to that minimum. For a 2 × 2 matrix the potential reduces to a function on the plane, where the figures below draw each step exactly.

Setting. Let an n×nn\times n matrix whose entries aija_{ij} are all positive be an n×nn\times n matrix with every entry aij>0a_{ij}>0. For positive vectors the row scalings xi>0x_i>0 and the column scalings yj>0y_j>0; DxD_x is the diagonal matrix with diagonal xx, write DxD_x and DyD_y for the diagonal matrices with diagonals xx and yy. Scaling row ii by xix_i and column jj by yjy_j givesB=DxADy,bij=xiaijyj.\begin{aligned}B&=D_xAD_y,\\b_{ij}&=x_ia_{ij}y_j.\end{aligned}The matrix BB is doubly stochastic when B1=1B\mathbf 1=\mathbf 1 and B⊤1=1B^\top\mathbf 1=\mathbf 1, where 1\mathbf 1 is the vector of nn ones. Sinkhorn's theorem guarantees that exactly one doubly stochastic matrix has the form DxADyD_xAD_y, with xx and yy unique up to x→txx\to tx, y→y/ty\to y/t for t>0t>0. Alternately dividing each row by its sum and each column by its sum converges to it.

Counting equations and unknowns does not settle existence. Removing the shared factor tt leaves 2n−12n-1 unknowns, and the 2n2n sum constraints have one redundancy because row sums and column sums share the same total. The counts match, yet the system is bilinear in xx and yy, so equal counts guarantee no solution. Nor does the iteration obviously converge: normalizing columns disturbs the row sums just set.

Step 1

A convex potential whose slopes are the row and column sums minus 1. Passing to logarithms the entrywise logarithm of the row scalings, ui=log⁡xiu_i=\log x_i and the entrywise logarithm of the column scalings, vj=log⁡yjv_j=\log y_j removes the positivity constraints and turns each product xiyjx_iy_j into eui+vje^{u_i+v_j}. DefineF(u,v)=∑i,jaijeui+vj−∑iui−∑jvj.\begin{aligned}F(u,v)&=\textstyle\sum_{i,j}a_{ij}e^{u_i+v_j}\\&\quad-\textstyle\sum_iu_i-\sum_jv_j.\end{aligned}The first sum is the entry total of BB, so∂F/∂ui=∑jbij−1,∂F/∂vj=∑ibij−1.\begin{aligned}\partial F/\partial u_i&=\textstyle\sum_jb_{ij}-1,\\\partial F/\partial v_j&=\textstyle\sum_ib_{ij}-1.\end{aligned}Doubly stochastic scalings are thus the critical points of FF. Because every aijeui+vja_{ij}e^{u_i+v_j} is convex and the remaining terms are linear, FF is convex, so its critical points are global minima. Shifting (u,v)(u,v) to (u+t1,v−t1)(u+t\mathbf 1,v-t\mathbf 1) along the the line (u+t1, v−t1)(u+t\mathbf 1,\,v-t\mathbf 1), t∈Rt\in\mathbb R: every ui+vju_i+v_j and the sum ∑iui+∑jvj\sum_iu_i+\sum_jv_j are unchanged along it, so FF and BB are too leaves every ui+vju_i+v_j and the sum ∑iui+∑jvj\sum_iu_i+\sum_jv_j unchanged, so both BB and FF stay fixed. That invariance is the scaling freedom x→etxx\to e^tx, y→e−tyy\to e^{-t}y.

For n=2n=2 the potential can be drawn. Write the log-ratio of the two row scalings, log⁡(x2/x1)\log(x_2/x_1) and the log-ratio of the two column scalings, log⁡(y2/y1)\log(y_2/y_1). Modulo the flat direction, the only remaining coordinate is the common log-factor u1+v1u_1+v_1 on all four entries. With MM denoting the entry total at x1=y1=1x_1=y_1=1, the potential reads F=eu1+v1M−2(u1+v1)−α−βF=e^{u_1+v_1}M-2(u_1+v_1)-\alpha-\beta. Minimizing over u1+v1u_1+v_1 sets eu1+v1M=2e^{u_1+v_1}M=2, fixing the entry total of BB at 2 and leaving, up to an additive constant,Φ(α,β)=2log⁡M−α−β,M=a11+a12eβ+a21eα+a22eα+β.\begin{aligned}\Phi(\alpha,\beta)&=2\log M-\alpha-\beta,\\M&=a_{11}+a_{12}e^{\beta}\\&\quad+a_{21}e^{\alpha}+a_{22}e^{\alpha+\beta}.\end{aligned}In the figure, AA has rows (3,1)(3,1) and (a21,1)(a_{21},1), the gray curves are level sets of Φ\Phi, and the blue dot marks its minimum.

Step 2

Every entry walls off a direction, so FF has a lowest point. A convex function need not attain a minimum if it can fall forever toward infinity. Using ∑i,j(ui+vj)=n(∑iui+∑jvj)\sum_{i,j}(u_i+v_j)=n(\sum_iu_i+\sum_jv_j) splits FF into one term per matrix entry:F(u,v)=∑i,jhij(ui+vj),hij(w)=aijew−w/n.\begin{aligned}F(u,v)&=\textstyle\sum_{i,j}h_{ij}(u_i+v_j),\\h_{ij}(w)&=a_{ij}e^{w}-w/n.\end{aligned}Each the term of entry (i,j)(i,j), hij(w)=aijew−w/nh_{ij}(w)=a_{ij}e^w-w/n, evaluated at w=ui+vjw=u_i+v_j; aijew=bija_{ij}e^w=b_{ij} is the scaled entry is convex and hits its minimum (1+log⁡(naij))/n(1+\log(na_{ij}))/n at aijew=1/na_{ij}e^w=1/n. Because aij>0a_{ij}>0, it grows to +∞+\infty on both sides, exponentially as w→+∞w\to+\infty and linearly as w→−∞w\to-\infty. On any sublevel set {F≤c}\{F\le c\}, each hij(ui+vj)h_{ij}(u_i+v_j) is at most cc minus the other terms' minima, trapping every sum ui+vju_i+v_j in a bounded interval.

Those n2n^2 bounded sums trap (u,v)(u,v) modulo the flat direction, because ui+vj=0u_i+v_j=0 for all i,ji,j forces u=t1u=t\mathbf 1 and v=−t1v=-t\mathbf 1. Restrict FF to the slice ∑iui=∑jvj\sum_iu_i=\sum_jv_j, which crosses each flat line once. On that slice FF has closed, bounded sublevel sets and therefore attains a minimum. Because FF is constant along the flat direction, that minimizer is a critical point on all of R2n\mathbb R^{2n}, giving a doubly stochastic scaling by Step 1. In the figure, the level sets form closed curves around the blue dot. Setting a21=0a_{21}=0 removes that entry's wall, so the level sets open into a channel toward α→+∞\alpha\to+\infty, β→−∞\beta\to-\infty, and the minimum escapes the plane.

Step 3

Across the flat direction FF is strictly convex, so the scaled matrix is unique. Differentiating F(u+t δu, v+t δv)F(u+t\,\delta u,\,v+t\,\delta v) twice in tt at t=0t=0 drops the linear terms:d2dt2∣t=0F(u+t δu, v+t δv)=∑i,jbij(δui+δvj)2.\begin{aligned}&\tfrac{d^2}{dt^2}\Big|_{t=0}F(u+t\,\delta u,\,v+t\,\delta v)\\&\quad=\textstyle\sum_{i,j}b_{ij}(\delta u_i+\delta v_j)^2.\end{aligned}Because every bij>0b_{ij}>0, this second derivative is strictly positive unless every δui+δvj=0\delta u_i+\delta v_j=0, which means (δu,δv)(\delta u,\delta v) points along the flat direction (Step 2). Suppose two scalings are both doubly stochastic. Both minimize the convex function FF, so FF is constant along the segment joining them and its second derivative vanishes there. That segment must run along the flat direction, so the two scalings differ only by x→txx\to tx, y→y/ty\to y/t and produce the same matrix BB. In the figure this yields the single lowest point. Sinkhorn draws an immediate corollary for symmetric AA. Since (DxADy)⊤=DyADx(D_xAD_y)^\top=D_yAD_x is also doubly stochastic, uniqueness forces y=txy=tx and B=DzADzB=D_zAD_z with z=t xz=\sqrt t\,x.

Step 4

Normalizing the rows minimizes FF exactly over uu, and every step lowers FF. At fixed vv, setting ∂F/∂ui=0\partial F/\partial u_i=0 gives eui=1/∑jaijevje^{u_i}=1/\sum_ja_{ij}e^{v_j}, which divides row ii by its sum. Row normalization therefore minimizes FF exactly over uu, and column normalization over vv, making the alternation minimizing a function over one block of variables at a time, here uu and then vv, with the other block held fixed. After a row step the entries total nn. The next column step divides column jj by its sum the sum of column jj of the current matrix just after a row step; the cjc_j are positive and total nn, replacing vjv_j with vj−log⁡cjv_j-\log c_j while keeping the entry total at nn. Neither the exponential sum nor uu changes, so FF moves solely through −∑jvj-\sum_jv_j:ΔF=∑jlog⁡cj≤∑j(cj−1)−12n2∑j(cj−1)2=−12n2∥c−1∥2.\begin{aligned}\Delta F&=\textstyle\sum_j\log c_j\\&\le\textstyle\sum_j(c_j-1)-\frac{1}{2n^2}\sum_j(c_j-1)^2\\&=-\tfrac{1}{2n^2}\|c-\mathbf 1\|^2.\end{aligned}The inequality applies Taylor's bound log⁡c≤(c−1)−(c−1)2/(2n2)\log c\le(c-1)-(c-1)^2/(2n^2) for 0<c≤n0\lt c\le n, and the linear terms vanish because ∑jcj=n\sum_jc_j=n. A row step after a column step satisfies the same bound with rows and columns swapped.

Because FF is bounded below (Step 2), the total drop across all steps is finite, so the column sums after each row step tend to 1. By the same bound, the row sums after each column step also tend to 1. Every iterate stays in the initial sublevel set, where every ui+vju_i+v_j is bounded (Step 2), keeping all scaled entries bounded above and away from 0. Since the arrays (ui+vj)ij(u_i+v_j)_{ij} form a closed subspace, any limit point is doubly stochastic and keeps the form DxADyD_xAD_y. Step 3 leaves only one such matrix, so the bounded sequence converges to it.

In the plane, the row step minimizes FF over both row scalings at fixed vv, which minimizes Φ\Phi over α\alpha at fixed β\beta. It travels horizontally to the lowest level set that horizontal line touches. That point lies on the curve where the two row sums match,α=log⁡a11+a12eβa21+a22eβ,\alpha=\log\frac{a_{11}+a_{12}e^{\beta}}{a_{21}+a_{22}e^{\beta}},labeled “row sums 1” because at entry total 2 both row sums equal 1. The column step travels vertically onto the matching column-sum curve,β=log⁡a11+a21eαa12+a22eα.\beta=\log\frac{a_{11}+a_{21}e^{\alpha}}{a_{12}+a_{22}e^{\alpha}}.The doubly stochastic scaling sits where the two curves cross. In the figure, the blue path starts at AA, lands on one curve after each move, and meets its gray level set tangentially at every endpoint.

How fast. Convergence is linear. Near the limit the doubly stochastic matrix DxADyD_xAD_y of the theorem, the limit of the iteration, each sweep of one row step and one column step shrinks the distance to B∗B^* by a factor approaching the square of the second-largest singular value of B∗B^*; the largest is 1, with singular vectors 1\mathbf 1 (Knight, 2008). For n=2n=2, scaling preserves the cross-ratio κ\kappa=a11a22/(a12a21){}=a_{11}a_{22}/(a_{12}a_{21}). That invariant fixes B∗B^* directly: its rows are (p,1−p)(p,1-p) and (1−p,p)(1-p,p) with p/(1−p)=κp/(1-p)=\sqrt\kappa. Differentiating both curves at their crossing gives dα/dβ=1−2pd\alpha/d\beta=1-2p on the row curve and dβ/dα=1−2pd\beta/d\alpha=1-2p on the column curve. Each half-step therefore scales the coordinate error by 1−2p1-2p, so a full sweep contracts it by(1−2p)2=(κ−1κ+1)2,(1-2p)^2=\Big(\frac{\sqrt\kappa-1}{\sqrt\kappa+1}\Big)^2,the readout shown in the figure.

In the (α,β)(\alpha,\beta) plane, the slope dβ/dαd\beta/d\alpha is 1/(1−2p)1/(1-2p) on the row curve and 1−2p1-2p on the column curve. When ∣1−2p∣|1-2p| nears 1, the two curves cross at a shallow angle and the zigzag crawls. That occurs when κ\kappa is far from 1, so AA resembles a diagonal or anti-diagonal matrix. At κ=1\kappa=1, AA has rank one and a single sweep is exact. At a21=0a_{21}=0, the contraction factor approaches 1 and the iterates walk off along the open channel.

Zero entries (Sinkhorn and Knopp, 1967). Sinkhorn (1964) already showed by example that zero entries can break convergence, and that even a converging iteration need not admit finite scalings x,yx,y. Sinkhorn and Knopp (1967) establish the exact conditions. A nonnegative matrix AA has AA has a positive diagonal: a permutation π\pi of {1,…,n}\{1,\dots,n\} with a1π(1),…,anπ(n)a_{1\pi(1)},\dots,a_{n\pi(n)} all positive if it has a positive diagonal, meaning some permutation π\pi with every aiπ(i)>0a_{i\pi(i)}>0. It has A≠0A\ne0 and every positive entry of AA lies on some positive diagonal a1π(1),…,anπ(n)a_{1\pi(1)},\dots,a_{n\pi(n)} if A≠0A\ne0 and every positive entry lies on one. A doubly stochastic scaling DxADyD_xAD_y exists if and only if AA has total support, and it is then unique. Necessity of total support follows from the doubly stochastic n×nn\times n matrices are exactly the averages, with nonnegative weights summing to 1, of the n×nn\times n permutation matrices, since every doubly stochastic matrix is a convex combination of permutation matrices and puts every positive entry on a positive diagonal. Those scaling vectors x,yx,y are unique up to (tx,y/t)(tx,y/t) if and only if AA is no permutation matrices P,QP,Q bring AA to the block form PAQ=(A10A2A3)PAQ=\begin{pmatrix}A_1&0\\A_2&A_3\end{pmatrix} with A1A_1 square.

Convergence requires less than existence of finite scalings. The alternation converges if and only if AA has support. When support is not total, every entry outside all positive diagonals vanishes in the limit, leaving a doubly stochastic matrix not of the form DxADyD_xAD_y. The figures at a21=0a_{21}=0 show this case. The matrix with rows (3,1)(3,1) and (0,1)(0,1) has the positive diagonal (3,1)(3,1), while a12=1a_{12}=1 lies on none, so the iterates converge to the identity as α→+∞\alpha\to+\infty and β→−∞\beta\to-\infty.

In hindsight. Sinkhorn and Knopp's original convergence proof tracks one product along a positive diagonal, s=∏ixiyπ(i)s=\prod_ix_iy_{\pi(i)}. Because π\pi is a permutation, s=e∑iui+∑jvjs=e^{\sum_iu_i+\sum_jv_j}. Just after a row step the column sums cjc_j average 1, so the arithmetic-geometric mean inequality gives ∏jcj≤1\prod_jc_j\le1. The next column step divides ss by ∏jcj\prod_jc_j, so ss never falls and the column sums approach 1. Since the matrix entries total nn after every step, F=n−log⁡sF=n-\log s throughout the iteration. Their monotone product is the potential FF, and their AM-GM step is the drop bound of Step 4.

Other row and column sums. Positive target row sums μi\mu_i and column sums νj\nu_j with equal total ∑kμk=∑kνk\sum_k\mu_k=\sum_k\nu_k change only the linear terms of the potential, to F=∑i,jaijeui+vj−∑iμiui−∑jνjvjF=\sum_{i,j}\htmlData{gr=gn1}{a_{ij}}e^{u_i+v_j}-\sum_i\mu_iu_i-\sum_j\nu_jv_j. The same proof works with hij(w)=aijew−μiνjw/∑kμkh_{ij}(w)=a_{ij}e^w-\mu_i\nu_jw/\sum_k\mu_k (computed here). Row steps now scale row ii by μi\mu_i divided by its current sum, and column steps scale column jj by νj\nu_j divided by its current sum.

Where it is used. Cuturi (2013) adds an the transport problem min⁡P∑i,jPijCij−εH(P)\min_P\sum_{i,j}P_{ij}C_{ij}-\varepsilon H(P) over matrices P≥0P\ge0 with row sums μ\mu and column sums ν\nu, where H(P)=−∑i,jPijlog⁡PijH(P)=-\sum_{i,j}P_{ij}\log P_{ij}; Cuturi writes λ=1/ε\lambda=1/\varepsilon and r,cr,c for the marginals to optimal transport between histograms μ\mu and ν\nu under cost matrix CC. The optimal coupling takes the form DxKDyD_xKD_y with K=e−C/εK=e^{-C/\varepsilon} entrywise, so Sinkhorn-Knopp with targets μ,ν\mu,\nu computes it directly. On large histograms, his implementation ran over 100,000 times faster than exact transport solvers at tolerance 0.01. As KK became diagonally dominant, iteration counts rose, matching the slow regime above. In representation learning, a self-supervised image method (Caron et al., 2020) that predicts the cluster assignment of one augmented view of an image from another view of the same image assigns batch images softly to equal-share prototypes via three Sinkhorn-Knopp iterations on exp⁡(scores/ε)\exp(\text{scores}/\varepsilon) with ε=0.05\varepsilon=0.05. Fewer iterations failed to converge. DINOv2 (Oquab et al., 2024) uses the same three-iteration step to center teacher outputs, though its ablation left k-NN and linear accuracy unchanged. a graph neural network (Sarlin et al., 2020) that matches keypoints between two images and outputs a partial assignment runs 100 iterations on a score matrix padded with one row and one column for unmatched points. mHC runs 20 iterations on the entrywise exponentials of its learned mixing matrices.

Terms

Sinkhorn's theorem
For AA with all entries positive, exactly one doubly stochastic matrix has the form DxADyD_xAD_y; x,yx,y are unique up to (tx,y/t)(tx,y/t); alternate row and column normalization converges to it.
Potential FF
∑aijeui+vj−∑ui−∑vj\sum a_{ij}e^{u_i+v_j}-\sum u_i-\sum v_j with u=log⁡xu=\log x, v=log⁡yv=\log y; gradient = row and column sums minus 1; convex, flat only along (1,−1)(\mathbf 1,-\mathbf 1).
Existence
F=∑i,jhij(ui+vj)F=\sum_{i,j}h_{ij}(u_i+v_j) with hij(w)=aijew−w/nh_{ij}(w)=a_{ij}e^w-w/n; each term rises on both sides, so sublevel sets are bounded across the flat direction.
Uniqueness
Second derivative ∑bij(δui+δvj)2>0\sum b_{ij}(\delta u_i+\delta v_j)^2>0 off the flat direction.
Convergence
A row step is the exact minimizer over uu; a column step lowers FF by ∑jlog⁡cj≤−∥c−1∥2/(2n2)\sum_j\log c_j\le-\|c-\mathbf 1\|^2/(2n^2).
Rate
Linear, factor →σ2(B∗)2\to\sigma_2(B^*)^2 per sweep; for n=2n=2, ((κ−1)/(κ+1))2((\sqrt\kappa-1)/(\sqrt\kappa+1))^2. Slow when AA is near a permutation pattern.
Zeros
Scaling exists iff total support; iteration converges iff support (Sinkhorn and Knopp, 1967).
Uses
Entropic optimal transport (K=e−C/εK=e^{-C/\varepsilon}), equal-size soft assignments (SwAV, DINOv2: 3 iterations), keypoint matching (SuperGlue), mHC (20 iterations).

Sources

Connected notes

  • 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.

  • 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.

  • Because every layer reads the residual stream linearly and adds its output back, an attention-only transformer expands directly into a sum of independent paths, linking any earlier write matrix WO1W_O^1 directly to any later read matrix WI2W_I^2 through virtual weights WI2WO1W_I^2W_O^1 across intervening layers.

  • The ordinary residual stream already carries early layers forward. In an 8-layer model a value shortcut from layer 2 or later adds little, because H1H_1 is reachable through the stream, and it helps once the residual chain is started at H2H_2. Deep layers want the first-layer shortcut most, so a direct path helps where the single running sum no longer carries that information cleanly.

Threads