AI State of the Art
SOTA/Training: Modern Training Techniques/33 min
Section 126

Training Stability: Residuals, Conditioning, and Orthogonality

Listen as a podcast →

A story: the game of telephone across 100 floors

Picture a message that has to travel up a 100-storey building. On each floor, someone rewrites it before passing it on. If every person exaggerates a little (speaks louder), the message arrives screaming at the top: it explodes. If everyone whispers a little, it arrives inaudible: it vanishes.

A deep neural network is exactly that game of telephone. The "message" is the gradient: the error signal that flows back from the output toward the input during training, telling each layer how to improve. Each layer the signal crosses multiplies it by a weight matrix. Multiplying 100 times in a row is dangerous: the slightest tendency to amplify or to shrink turns into an exponential catastrophe.

Two classic symptoms, already seen in the page on feed-forward networks and residual connections (a feed-forward network, almost always abbreviated FFN, is the small network that processes each token on its own after attention):

  • Exploding gradient: the signal grows huge, the weights spin out of control, training diverges.
  • Vanishing gradient: the signal shrinks to nearly zero, and the early layers stop learning anything.

This page tells the story of three complementary ideas that keep the message legible from the ground floor to the 100th: residual connections (let the signal through), good conditioning (don't distort the signal), and orthogonality (only rotate the signal, without changing its volume).

Recap: residuals let the gradient through, but aren't enough

The residual connection (skip connection) solves a large part of the problem. Instead of replacing the input with a layer's output, we add the transformation to the input:

output=x+F(x)\text{output} = x + F(x)

The benefit is that the derivative of addition is 11: the gradient gets a "highway" that lets it flow back without being multiplied at every floor. This is what made it possible to stack dozens, then hundreds, of layers.

Diagram of a residual block: the input x passes through two weight layers separated by a ReLU to produce F(x), while a curved arrow carries x directly to the final addition, giving F(x) + x followed by a ReLU.
The residual block in its original form. The arrow on the right is the identity path: it copies the input x straight through to the final addition. That addition, whose derivative is 1, is what gives the gradient a direct highway back down to the lower layers, whatever the two weight layers in the middle happen to do.Source : ResNet paper (He et al., figure 2), via ML Digest

Reading the formula: xx is the bundle of numbers entering the layer (the activation, recomputed on every pass of text), FF is the transformation the layer applies, and output\text{output} is what leaves for the next floor. In one sentence: the layer does not replace its input, it adds a correction to it.

But (and this is the whole point of the page) the residual handles the direct path, not the path that runs through the transformation F(x)F(x). And FF contains multiplications by weight matrices WW. If those matrices are badly conditioned, they blow up certain directions of the space and crush others. The signal that flows through FF gets distorted, the activations swell or collapse layer after layer, and numerical stability degrades despite the residual.

What is learned, what is recomputed

This distinction governs the rest of the page. A weight matrix WW is a learned parameter: it is modified at every training step, then frozen once training ends. Activations (xx, F(x)F(x)) are results recomputed on every pass, different for every text handed to the model.

All the constraints described here (good conditioning, orthogonality, double stochasticity) apply to the learned weights, never to the activations. You constrain the tool, not the material it works on.

Two distinct problems

The residual guarantees that one path for the gradient stays clean. It does not guarantee that the transformation itself behaves well. For that, you have to deal with the shape of the weight matrices, that's conditioning.

Conditioning: how much you amplify or shrink

A matrix WW acts on a vector by stretching it along some directions and compressing it along others. Conditioning measures the gap between the strongest stretch and the weakest one.

More precisely, every matrix has singular values: the factors by which it scales length along its preferred directions. Call σmax⁡\sigma_{\max} the largest and σmin⁡\sigma_{\min} the smallest. The condition number is their ratio:

κ(W)=σmax⁡σmin⁡\kappa(W) = \frac{\sigma_{\max}}{\sigma_{\min}}

Reading the symbols: WW is the weight matrix, σmax⁡\sigma_{\max} (Greek letter sigma) its strongest stretch factor, σmin⁡\sigma_{\min} its weakest, and κ\kappa (Greek letter kappa) the ratio of the two. In one sentence: the condition number says how many times better the most favoured direction is treated than the worst-treated one.

  • κ\kappa close to 11: the matrix treats every direction in a balanced way. This is well-conditioned.
  • κ\kappa very large: some directions are stretched thousands of times more than others. This is badly conditioned.

An analogy: a good loudspeaker reproduces bass and treble at the same relative volume as the input. A bad one saturates the lows and muffles the highs, it distorts. Chain 100 bad loudspeakers in series and all that's left is a shapeless rumble. That's exactly what happens to the signal and the gradient when you chain badly-conditioned matrices.

Four-panel diagram of the singular value decomposition of a matrix A: the unit circle is first rotated by V transpose, then stretched into an ellipse by Sigma, then rotated again by U; the direct path through A reaches the same result.
What a matrix really does, seen geometrically. Following the bottom path, any matrix A breaks down into three moves: a rotation (V transpose), a stretch along the axes (Sigma), then another rotation (U). Only the middle stretch distorts the circle into an ellipse: the singular values are the half-axis lengths of that ellipse, and the condition number is the ratio of the largest to the smallest. An orthogonal matrix is the case where the stretch is absent, only the rotations remain, and the circle stays a circle.Source : Hadrien Jean, Essential Math for Data Science

The ideal that follows is norm preservation, the norm of a list of numbers being its overall size, measured as the length of an arrow. Two ways of measuring it recur in this page: the ℓ2 norm (ordinary Euclidean length) and the ℓ1 norm (the sum of absolute values). Both are defined in norms and distances. We would like that size to stay roughly constant as a vector crosses layers. No swelling, no collapse.

∥Wx∥≈∥x∥\| W x \| \approx \| x \|

Reading the symbols: the pair of vertical bars ∥⋅∥\|\cdot\| denotes the norm, i.e. the size of whatever sits between them; WxW x is the result of applying the matrix to the vector xx. In one sentence: what comes out of the layer is about the same size as what went in.

A matrix that achieves this equality exactly, for every vector, has a precise name: it is orthogonal.

Orthogonal matrices: only rotating the space

An orthogonal matrix QQ satisfies

Q⊤Q=IQ^\top Q = I

Two notations worth knowing, because they recur throughout this page:

  • Q⊤Q^\top reads "QQ transposed": the same matrix flipped along its diagonal, rows becoming columns (see matrix operations). For a rotation, the transpose is exactly the inverse rotation, the one that puts the object back where it started.
  • II is the identity matrix: the one that does nothing at all, the matrix equivalent of the number 11.

So Q⊤Q=IQ^\top Q = I reads: "doing QQ then undoing QQ returns you exactly to the starting point, with nothing lost along the way." Which says that its columns are perpendicular directions of length 11. Geometrically, QQ only rotates (and possibly reflects) the space: it neither stretches nor squeezes it in any direction. It's a rigid rotation of an object, you turn it, but its size doesn't change.

The direct consequence, and this is the key point: an orthogonal matrix preserves the Euclidean norm exactly.

∥Qx∥=∥x∥for every x\| Q x \| = \| x \| \quad \text{for every } x

All of its singular values equal 11, so its conditioning is perfect: κ(Q)=1\kappa(Q) = 1.

Why this is desirable for training a deep network:

  • Stable signal propagation: activations keep a constant norm as they move forward through the layers. No swelling, no collapse.
  • Stable gradient propagation: during backpropagation, the gradient is multiplied by Q⊤Q^\top, which also preserves the norm. So it can neither explode nor vanish across that layer.
  • No information lost: a rotation is invertible and reversible. No direction of the space is crushed to zero, so no information is permanently destroyed by the layer.
The link with normalization

Normalization (LayerNorm, RMSNorm) fixes the norm of the activations after the fact, at each layer: it acts on the computed result. Orthogonality constraints act on the learned weights, so they attack the cause at the source: they make the transformation itself non-distorting. The two approaches are complementary.

How to enforce orthogonality in practice

The problem: if you train a matrix freely, nothing keeps it orthogonal. You need a mechanism. Three broad families exist, from the strictest to the most flexible.

1. Explicit projection (via SVD)

After each weight update, you reproject the matrix onto the nearest orthogonal one. The tool is the singular value decomposition, almost always abbreviated SVD, which writes any matrix as W=UΣV⊤W = U \Sigma V^\top, exactly the three moves in the diagram above: V⊤V^\top is a first rotation, Σ\Sigma (capital sigma) is the stretch along the axes, UU is a second rotation. UU and VV are orthogonal; Σ\Sigma holds the singular values. You then replace Σ\Sigma with the identity, i.e. delete the stretch and keep only the two rotations:

Worth=UV⊤W_{\text{orth}} = U V^\top

You have forced all singular values to 11. This is the strictest guarantee, but also the most expensive: SVD is heavy to compute, especially on large matrices and at every training step.

This exact operation (replacing a matrix by the nearest orthogonal one) is what the Muon optimizer applies, not to the weights, but to the update of the weights, and what it makes affordable by replacing the SVD with a handful of matrix multiplications. See Muon and learning-rate schedulers.

2. Direct, differentiable parameterization (the Cayley transform)

Rather than correcting after the fact, you parameterize the matrix so that it is orthogonal by construction, whatever the learned values are. The Cayley transform is the emblematic example. Start from a skew-symmetric matrix AA (meaning A⊤=−AA^\top = -A: flipping it along its diagonal is the same as flipping every sign, so you only need to learn a little under half the coefficients of a full matrix, the other half follows) and form:

Q=(I+A)−1(I−A)Q = (I + A)^{-1}(I - A)

Reading the symbols: II is the identity matrix, AA the skew-symmetric matrix whose coefficients are the actual learned parameters, and the exponent −1-1 denotes the inverse, the matrix that undoes the effect of (I+A)(I + A), the matrix equivalent of division. In one sentence: you build the rotation by dividing one quantity by another, and the result of that division is automatically a rotation. One can prove that the result QQ is always orthogonal, for any skew-symmetric AA. The decisive advantage: the construction is differentiable, so you can train AA by gradient descent like any other parameter while staying permanently on the "surface" of orthogonal matrices. No projection to recompute, no SVD. The main cost is the inversion (I+A)−1(I+A)^{-1}.

The Cayley transform

The Cayley transform is a classic result of linear algebra (19th century) that bridges skew-symmetric matrices and orthogonal matrices. In deep learning, it is reused to parameterize orthogonal layers in a differentiable way, without having to enforce the constraint by projection at each step.

3. Regularization (a penalty in the loss)

The most flexible approach: you don't enforce orthogonality, you encourage it. You add to the loss (the quantity training tries to drive down) a term that measures how far the matrix strays from orthogonality:

Ltot=Ltask+λ ∥W⊤W−I∥2\mathcal{L}_{\text{tot}} = \mathcal{L}_{\text{task}} + \lambda \, \big\| W^\top W - I \big\|^2

Reading the symbols: Ltot\mathcal{L}_{\text{tot}} is the total quantity to minimize, Ltask\mathcal{L}_{\text{task}} the error on the task itself, λ\lambda (Greek letter lambda) a knob chosen by the engineer, and ∥W⊤W−I∥2\| W^\top W - I \|^2 the departure from orthogonality, exactly zero when WW is orthogonal, growing as it drifts away. The square is there so that a departure counts positively whichever way it goes. In one sentence: you ask the model to do its job well and to keep its matrices close to a rotation, with λ\lambda arbitrating between the two.

So the coefficient λ\lambda sets the trade-off: too small and the constraint is ignored; too large and you smother the learning of the task. This is cheap (just one extra matrix product) but only guarantees approximate orthogonality.

Comparison table

MethodGuaranteeCostIdea in one sentence
SVD projection (UV⊤UV^\top)Exact (strict)High (SVD every step)Recompute the nearest orthogonal after each update
Cayley (I+A)−1(I−A)(I{+}A)^{-1}(I{-}A)Exact, by constructionMedium (one inversion)Parameterize to stay orthogonal in a differentiable way
RegularizationApproximateLow (one penalty term)Gently push toward orthogonality via the loss

Beyond the ℓ2 norm: doubly stochastic constraints

Orthogonality preserves the Euclidean (ℓ2) norm, i.e. ordinary length. But in some contexts (notably when you want to read the weights as a distribution of "mass" or attention across elements) you'd rather preserve the ℓ1 norm, i.e. the sum of absolute values.

That's the role of doubly stochastic matrices: matrices with nonnegative entries whose every row and every column sum to 11. They redistribute a total quantity without creating or losing any, like a transport table that reallocates goods without misplacing any.

The catch: enforcing this double constraint (rows and columns) has no direct formula. You obtain it through an iterative algorithm, Sinkhorn-Knopp, which alternately normalizes rows then columns, over and over, until convergence. That is precisely what makes them expensive: each application takes several iterations, where a simple normalization is done in one shot.

The cost / property trade-off

Choosing a constraint (orthogonal ℓ2, doubly stochastic ℓ1) means arbitrating between the property you want to guarantee and the price you're willing to pay at each training step. The stronger and more exact the guarantee, the heavier the computation. A large part of stability research consists of finding cheap approximations of these constraints.

The bigger idea: hyper-connections

Residual connections are just a special case of a broader family. In a residual, you simply add the input and the output (x+F(x)x + F(x)), with an implicit weight of 11 on each term. Hyper-connections generalize this: instead of a single path with fixed weight, you maintain several copies of the information stream and learn how to mix them at each layer, how much to keep of the input, how much of the transformation, how to recombine them.

Intuitively, it's going from a single gradient highway to a network of highways with adjustable interchanges. The mixing coefficients are themselves learned parameters, just like the weight matrices. The model can then learn for itself the best balance between "let the signal through as is" and "transform it," instead of having it imposed.

From hyper-connections to a frontier model

The idea was proposed under that name in 2024.

Hyper-Connections

It has reached production: the DeepSeek-V4 abstract lists, among its three headline changes, Manifold-Constrained Hyper-Connections (mHC) replacing conventional residual connections, the manifold constraint being a geometric constraint of exactly the kind described above. The same model is trained with the Muon optimizer, the other application of orthogonality covered in this course.

DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligence

Why it matters

At the scale of a model with tens of billions of parameters, trained for weeks across thousands of graphics processing units (GPUs, the chips specialized in matrix multiplication that do all the arithmetic of a training run), an instability is no minor annoyance: a gradient divergence can ruin a run that costs a fortune in compute and time. Keeping the signal and the gradient in a healthy range (through residuals, good conditioning, and where needed orthogonality constraints) is therefore a condition of economic viability, not just mathematical elegance.

Two 3D loss surfaces for the same ResNet-56 network: on the left, without skip connections, a chaotic terrain bristling with peaks and crevasses; on the right, with skip connections, a wide smooth bowl with a single central minimum.
The same ResNet-56 architecture, trained without (left) and with (right) skip connections. On the left, the landscape the optimizer has to descend is a chaotic terrain in which it gets lost; on the right, it is a regular bowl with a single bottom. Only one thing differs between the two networks: the presence of the addition x + F(x). This is the most striking visual demonstration of what stability buys you during training.Source : Visualizing the Loss Landscape of Neural Nets paper (Li et al., figure 1), via slides.com

It is also a domain where innovation is concrete and easy to locate: each family of methods embodies a different trade-off between guarantee and cost (exact but heavy projection, differentiable parameterization, soft regularization, ℓ1 constraints via an iterative algorithm). New techniques aim precisely to get the same stability for less, a clever approximation of an expensive constraint is exactly the kind of technical "trick" that sets one architecture apart from another.

Key takeaways

  1. The problem: in a deep network the gradient crosses many layers and tends to explode or vanish. Residual connections (x+F(x)x + F(x), derivative =1= 1) open a highway for it, but don't protect the path that runs through the weights.
  2. Conditioning κ=σmax⁡/σmin⁡\kappa = \sigma_{\max}/\sigma_{\min} measures how much a matrix distorts the space, those σ\sigma are the singular values, i.e. the square roots of the eigenvalues of W⊤WW^\top W, a notion covered in eigenvalues and eigenvectors; badly conditioned, it destabilizes activations and gradient despite the residual. The ideal is norm preservation.
  3. Orthogonal matrices (Q⊤Q=IQ^\top Q = I) only rotate the space: they preserve the Euclidean norm exactly (κ=1\kappa = 1), so they propagate signal and gradient without distorting them or losing information.
  4. Three ways to enforce it: SVD projection (UV⊤UV^\top, exact but expensive); differentiable parameterization such as the Cayley transform (I+A)−1(I−A)(I+A)^{-1}(I-A); regularization λ∥W⊤W−I∥2\lambda\|W^\top W - I\|^2 (flexible and cheap, but approximate).
  5. ℓ1 variants: doubly stochastic matrices preserve the ℓ1 norm (rows and columns summing to 11); they are obtained via the iterative Sinkhorn-Knopp algorithm, which makes them expensive. Hyper-connections generalize residuals by learning how to mix several streams, DeepSeek-V4 ships a geometrically constrained version of them.
  6. Why it matters: at the scale of very large models, stability drives the cost and success of training; finding a cheaper guarantee of stability is a major engineering and innovation challenge.
Check your understanding0 / 5

1. Are residual connections enough to stabilize a deep network?

2. What do the orthogonality and conditioning constraints described in this page apply to?

3. What does an orthogonal matrix do to a vector it transforms?

4. What trade-off governs the choice between SVD projection, the Cayley transform and regularization?

5. Why are doubly stochastic matrices expensive to enforce?