Mode Connectivity & Permutation Symmetry
Low-loss paths between solutions, weight matching and linear interpolation.
Train the same network twice from different random seeds, and the straight line between the two solutions climbs over a ridge of high loss. Yet the two are joined by simple curves of low loss, copies that share a short stretch of training are joined by straight lines, and much of the ridge between independent runs disappears once their hidden units are put in the same order. This lesson develops these findings, the algorithms behind them and the conjecture they support.
What you’ll learn
- Define loss barriers and (linear) mode connectivity, construct low-loss curves between two solutions, and state when dropout stability guarantees such paths.
- Describe instability analysis and the finding that linear connectivity sets in early in training, and connect it to lottery tickets, federated averaging and weight averaging.
- State the permutation conjecture, count the symmetries behind it, and derive weight matching as a sequence of linear assignment problems.
- Derive variance collapse in averaged networks and its REPAIR correction, and weigh the evidence on width, depth, training time and the conjecture's limits.
Curves of low loss
Let and be two trained networks with the same architecture, for instance from two random seeds. How the loss behaves on paths between them shows how the low-loss regions of the loss landscape fit together.
Garipov, Izmailov, Podoprikhin, Vetrov & Wilson (2018) searched for low-loss curves directly. They fix the two endpoints and train the free parameters of a simple curve, a polygonal chain with one bend or a quadratic Bézier curve with one control point :
Between independently trained ResNets, VGG networks and wide ResNets on CIFAR-10 and CIFAR-100, they found curves along which the training loss and the test accuracy stay nearly constant. Draxler, Veschgini, Salmhofer & Hamprecht (2018) reached the same conclusion with the nudged elastic band method from chemistry and called the paths "essentially flat": minima look less like the bottoms of separate valleys than like points on one connected low-loss manifold. Yet networks along a curve make different predictions, enough that ensembling them helps. Garipov et al. turned this into fast geometric ensembling: after about 80% of a normal training run, a cyclical learning rate with cycles of 2 to 4 epochs keeps the weights moving through the low-loss region, and the checkpoints taken where the rate is lowest form an ensemble for about the price of one run. Averaging such checkpoints instead of their predictions is the subject of Weight Averaging: SWA, EMA & Model Soups.
In Kuditipudi et al.'s construction, what does permuting the hidden units of one network achieve?
- It makes the two networks compute the same function, so the path becomes trivial
- It puts one network's surviving units into the slots the other leaves empty, so one half can be faded out while the other is faded in
- It lowers the loss of the permuted network
- It aligns the two networks so that the straight line between them has no barrier
Show the answer
B. It puts one network's surviving units into the slots the other leaves empty, so one half can be faded out while the other is faded in
After the dropout moves, each network uses at most half the units of every layer. A permutation, which leaves the function unchanged, moves one network's survivors into the other's empty slots. With disjoint units, a few segments can switch one network off while switching the other on without the two interfering.
Linear connectivity sets in early
Curves must be trained; straight lines are free. Frankle, Dziugaite, Roy & Carbin (2020) asked when two runs end in the same linearly connected region, using instability analysis: train a network to step , make two copies, finish training each with different SGD noise (data order and augmentation), and measure the error barrier on the straight line between the two results. At , two runs from one shared initialization, every network they studied except a small LeNet on MNIST ended in regions separated by a barrier. After a short stretch of shared training the barrier was gone:
| Network | Data | Stable to SGD noise from |
|---|---|---|
| LeNet | MNIST | initialization |
| ResNet-20 | CIFAR-10 | iteration 2,000 (3% of training) |
| VGG-16 | CIFAR-10 | iteration 1,000 (1.5%) |
| ResNet-50 | ImageNet | epoch 18 (20%) |
| Inception-v3 | ImageNet | epoch 28 (16%) |
Three practices rest on this observation.
- Lottery tickets. Sparse subnetworks found by iterative magnitude pruning reach full accuracy only from a point at which they are stable in this sense: at initialization for small MNIST networks, early in training for ResNet-50 and Inception-v3 on ImageNet. That is why large-scale tickets are rewound to an early iterate rather than to initialization (Pruning, Sparsity & Lottery Tickets).
- Federated averaging. McMahan et al. (2017) trained pairs of MNIST networks, each on its own 600 examples, and averaged their weights: from different initializations the average was a poor model, while from a shared initialization it had lower loss on the full training set than either parent. Federated averaging, which repeatedly averages client models that each start from the current shared model, relies on this.
- Weight averaging. Checkpoints of one run, and fine-tuned copies of one pretrained model (which stay in one basin: Neyshabur, Sedghi & Zhang, 2020), can be averaged into a single better model for the same reason (Weight Averaging: SWA, EMA & Model Soups; Model Merging & Task Arithmetic).
Think first Averaging the weights of two ResNet-20s trained on CIFAR-10 from different seeds gives a network far worse than either. Two copies spawned from a checkpoint at 5% of training and then finished separately average with almost no increase in error. Why the difference?
The independent runs end in regions separated by a barrier, partly because their hidden units sit in unrelated orders, so the average mixes units that do different jobs. Copies spawned after the stability point, about 3% of training for ResNet-20, end in one linearly connected region, and their average lies on a low-loss segment. Putting the independent runs' units in the same order first, the subject of the next step, recovers much of what averaging lost.
Permutations: the conjecture and the matching algorithms
Why do independent runs end in different regions at all? One reason is guaranteed by permutation symmetry. Reordering the units of a hidden layer, together with the rows of its incoming weights and the columns of its outgoing weights, leaves the function unchanged, so a network with hidden widths has copies of every solution, and times more per layer when the activation is odd, like tanh, because all of a unit's weights can flip sign (Symmetries & Conservation Laws). Two runs that learned exactly the same features would still differ by a permutation, and averaging them would mix units that play different roles.
A hidden layer has units. About how many orderings of its units compute the same function? Give .
Show the answer
1167 log₁₀
By Stirling's formula, , so has 1,167 digits. Even the widget's network below, with two tanh layers of 32 units, has equivalent copies of each solution. No search can try them all: the alignment has to be computed.
A permutation acts on network B layer by layer, with permutation matrices (: inputs and outputs stay fixed; biases are permuted with their units). Choose to bring B closest to A. Permutations preserve norms, so this maximizes an inner product:
Each term is bilinear in two neighboring permutations, and the joint problem, a sum of bilinear assignment problems, is NP-hard for . With every other layer fixed, though, the objective is linear in :
Maximizing over permutation matrices is the linear assignment problem, which the Hungarian method solves exactly in time. Weight matching sweeps over the layers, solving one assignment problem at a time, until no permutation changes: coordinate ascent that runs in seconds and needs no data. Activation matching instead pairs units whose activations agree on the training data, solving for each layer separately, with the units' activations over the dataset.
import torch
from scipy.optimize import linear_sum_assignment
def align_hidden(A, B):
"""Permute the hidden units of B (Linear, ReLU, Linear) to best match A's weights."""
W1a, b1a, W2a = A[0].weight, A[0].bias, A[2].weight
W1b, b1b, W2b = B[0].weight, B[0].bias, B[2].weight
# similarity of A's unit i and B's unit j: incoming weights, bias and outgoing weights
S = W1a @ W1b.T + torch.outer(b1a, b1b) + W2a.T @ W2b
_, perm = linear_sum_assignment(S.detach().numpy(), maximize=True) # exact LAP, O(n³)
with torch.no_grad():
B[0].weight.copy_(W1b[perm]); B[0].bias.copy_(b1b[perm])
B[2].weight.copy_(W2b[:, perm])
return B # the same function, at a different point in weight spaceWith one hidden layer, weight matching is a single assignment problem, solved exactly by scipy.optimize.linear_sum_assignment. The aligned B computes exactly what B did, up to rounding; only its position in weight space, and so the straight path from A, has changed.
Variance collapse and the limits of alignment
Take an aligned pair of first-layer units, with pre-activations and (random over the data), equal variances and correlation . The averaged network's unit computes their average:
Aligned units are similar but not identical: Jordan et al. report correlations around as typical, so the averaged unit keeps about 70% of the variance. The shrinkage compounds through the layers, and deep layers of an averaged network become nearly constant across inputs: a variance collapse that alignment alone cannot undo.
REPAIR rescales and shifts each unit (or channel) of the interpolated network so that its mean and standard deviation over the data equal the interpolations of the endpoints' statistics, which costs a few passes over training data:
On top of neuron alignment, REPAIR reduced barriers by 60% to 100% across architecture families and datasets: by 90% for ResNet-18 on CIFAR-10 and by 74% for ResNet-50 on ImageNet. What else the evidence says:
- Width. Ainsworth et al. found no linear connectivity after alignment for ResNet-20 and VGG-16 of standard width on CIFAR-10, but the barrier fell with width and reached zero for a ResNet-20 32 times wider than standard, the first zero-barrier connection between independently trained ResNets on CIFAR-10. On ImageNet, alignment cut the ResNet-50 barrier by 67% without removing it.
- Training time. Alignment found no linear connectivity early in training: it emerges as training proceeds.
- Depth. Without alignment, barriers grow quickly with depth (Entezari et al., 2022).
- The optimizer. Ainsworth et al. built solutions that no permutation linearly connects. They are not SGD solutions, so the conjecture survives, but connectivity must then come partly from SGD's implicit bias rather than from the landscape alone. Other symmetries, such as rescalings and features that move between layers, exist as well.
- Theory. Ferbach, Goujaud, Gidel & Dieuleveut (2024) proved, from convergence rates of empirical measures in Wasserstein distance, that two wide enough two-layer networks trained by SGD are linearly connected after permutation with high probability, and bounded the widths at which deep networks with independent neuron weights become connected. The required width grows with the dimension of the support of the neurons' weight distribution, which also tracked connectivity in their experiments.
Key takeaways
- The barrier is the largest rise of the loss above the chord on the straight path. Independent solutions have high barriers on straight lines but are joined by simple low-loss curves (Garipov et al., 2018), and dropout-stable solutions provably by piecewise-linear paths (Kuditipudi et al., 2019).
- Copies that share a short stretch of training end linearly connected: after about 3% of training for ResNet-20 on CIFAR-10 and 20% for ResNet-50 on ImageNet (Frankle et al., 2020). Lottery-ticket rewinding, federated averaging and weight averaging rely on this.
- Permutation symmetry gives every solution copies. The conjecture says SGD's solutions are linearly connected modulo permutations; weight matching aligns networks by coordinate ascent over layer-wise linear assignment problems, activation matching by correlating units.
- Averaging aligned units with correlation keeps only of their variance, compounding with depth; REPAIR restores the statistics and cuts barriers by 60–100%. Zero barriers have been reached only for wide networks on small datasets, connectivity emerges during training, and non-SGD counterexamples show it depends on SGD's implicit bias.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In instability analysis, two copies of a network are trained from its state at step with different data orders and augmentations. What did Frankle et al. (2020) find for ResNet-20 on CIFAR-10?
- The final networks were separated by a barrier for every
- They were linearly connected for every , including
- They were separated by a barrier for , but linearly connected once reached about 3% of training
- They were linearly connected only for
Show the answer
C. They were separated by a barrier for , but linearly connected once reached about 3% of training
From a shared initialization the two runs still end in different regions, but after about 2,000 iterations of shared training, 3% of the run, SGD noise no longer changes which linearly connected region training ends in.
How does weight matching (Ainsworth, Hayase & Srinivasa, 2023) find the permutations that align network B with network A?
- By gradient descent on the entries of the permutation matrices
- By trying all orderings of each layer
- It needs the training data to compare the units' activations
- With the other layers fixed, choosing one layer's permutation is a linear assignment problem, solved exactly in time; it sweeps over the layers until nothing changes, since the joint problem is NP-hard
Show the answer
D. With the other layers fixed, choosing one layer's permutation is a linear assignment problem, solved exactly in time; it sweeps over the layers until nothing changes, since the joint problem is NP-hard
The objective is linear in each when its neighbors are fixed, so each sub-step is an assignment problem for the Hungarian method. The joint problem, a sum of bilinear assignment problems, is NP-hard, hence the coordinate ascent.
Two aligned hidden units have equal variance and correlation over the data. What fraction of that variance does the corresponding unit of the averaged network keep?
Show the answer
A.
. The shrinkage compounds layer by layer, which is the variance collapse that REPAIR corrects by restoring each unit's mean and standard deviation.
Ainsworth et al. constructed solutions, not found by SGD, that no permutation can linearly connect. What does this imply for the permutation conjecture?
- It refutes the conjecture
- It shows that permutations play no role in barriers
- It does not contradict it, because the conjecture is about SGD's solutions; connectivity must then come partly from SGD's implicit bias, not from the landscape alone
- It shows that wider networks are always linearly connected
Show the answer
C. It does not contradict it, because the conjecture is about SGD's solutions; connectivity must then come partly from SGD's implicit bias, not from the landscape alone
The conjecture claims that SGD's solutions, with high probability, form a set that is linearly connected modulo permutations. Adversarially built minima outside that set do not contradict it, but they show the landscape alone does not guarantee connectivity.
Further reading
- T. Garipov, P. Izmailov, D. Podoprikhin, D. Vetrov & A. G. Wilson, "Loss surfaces, mode connectivity, and fast ensembling of DNNs," NeurIPS (2018).
- J. Frankle, G. K. Dziugaite, D. M. Roy & M. Carbin, "Linear mode connectivity and the lottery ticket hypothesis," ICML (2020).
- R. Entezari, H. Sedghi, O. Saukh & B. Neyshabur, "The role of permutation invariance in linear mode connectivity of neural networks," ICLR (2022).
- S. K. Ainsworth, J. Hayase & S. Srinivasa, "Git Re-Basin: Merging models modulo permutation symmetries," ICLR (2023).
- K. Jordan, H. Sedghi, O. Saukh, R. Entezari & B. Neyshabur, "REPAIR: REnormalizing permuted activations for interpolation repair," ICLR (2023).