Generalized Linear Mode Connectivity for Transformers

Alexander Theus, Alessandro Cabodi, Sotiris Anagnostidis, Antonio Orvieto, Sidak Pal Singh, Valentina Boeva

Introduction

Understanding the geometry of neural network loss landscapes is a central question in deep learning. A striking phenomenon in this space is Linear Mode Connectivity (LMC). Typically, two models trained from different random initializations end up in separate, isolated "basins" of the loss landscape. If one simply averages the weights of these two models, the resulting intermediate model performs terribly, encountering a high loss barrier.

However, neural networks exhibit symmetries in their parameter space. By "re-basining" one model—rearranging its parameters so they align with the other without changing its underlying function—researchers can often find a straight, low-loss path connecting the two.

Conceptual illustration of Linear Mode Connectivity, showing a high-loss direct path versus a low-loss path after applying a symmetry transformation.

While LMC has been successfully demonstrated for simpler networks using basic neuron permutations, it has consistently failed for modern architectures like Transformers. The reason lies in the richer internal symmetries of Transformers—such as those within Multi-Head Attention and LayerNorm—which simple permutations cannot adequately capture.

A Unified Framework for Transformer Symmetries

To bridge this gap, recent work introduces a unified framework that moves beyond simple neuron reordering. The authors categorize network symmetries into a hierarchy of transformations:

  1. Permutations: Standard neuron swapping, typically applicable to Feed-Forward Network (FFN) layers.
  2. Semi-permutations: Weighted mixing of inputs, useful for aligning Attention heads.
  3. Orthogonal Transformations: Rotations and reflections that preserve vector lengths. This is a crucial addition for handling the Residual Stream and RMSNorm layers.
  4. General Invertible Maps: The most flexible class of transformations, applicable to linear layers without strict constraints.

To find the optimal "teleportation" map between models, the framework proposes three distinct alignment strategies:

  • Weight Matching: A data-free approach utilizing the Procrustes method to align orthogonal matrices and the Hungarian algorithm for permutations.
  • Activation Matching: Aligning layers based on their activation responses to the same input data.
  • Learned Matching: The most effective strategy, which treats the symmetry transformations as trainable parameters and optimizes them via gradient descent to explicitly minimize the interpolation loss.

Key Insights: The Residual Stream and Heterogeneous Alignment

A major breakthrough in this research is the realization that the residual path in Transformers is governed by orthogonal symmetry. Previous attempts at LMC failed largely because they tried to apply simple permutations to the residual stream. By utilizing orthogonal maps, the authors successfully "flattened" the loss barrier between independently trained models.

Furthermore, because orthogonal transformations can be rectangular (mapping a smaller dimensional space into a larger one), this framework naturally extends to cross-architecture alignment. It allows a smaller model to be effectively embedded into the parameter space of a larger one, enabling width-heterogeneous LMC. The framework also scales beyond simple pairwise alignment, allowing multiple independently trained models to be merged simultaneously by aligning them to a shared "universe" or reference point.

Experimental Results

The framework was rigorously evaluated across both vision and language domains, utilizing Vision Transformers (ViT) on CIFAR-10, CIFAR-100, and Tiny ImageNet, as well as GPT-2 models on Tiny Shakespeare and BookCorpus.

Experimental results showing near-zero loss barriers for ViT and GPT-2 models using the proposed learned matching, alongside interpolation curves.

For the first time, researchers achieved zero or near-zero loss barriers for these complex architectures. On CIFAR-10, the loss barrier dropped dramatically from 1.69 (using vanilla averaging) to 0.00 using the learned matching method. Similarly, for GPT-2 on Tiny Shakespeare, the barrier plummeted from 2.02 to just 0.02.

The heterogeneous alignment experiments were equally successful, connecting a small GPT-2 model to one with twice the embedding dimension while maintaining a near-zero barrier along the interpolation path. Even the data-free "Weight Matching" approach significantly outperformed traditional permutation-only methods, offering a highly practical tool for privacy-sensitive applications like Federated Learning.

Limitations and Future Directions

While these results unlock new understandings of the Transformer loss landscape, some challenges remain. The current experiments focus on relatively small models (e.g., ViT-Small, GPT-2 small); scaling these alignment procedures to multi-billion parameter models presents a significant computational hurdle.

Additionally, modern Large Language Models (LLMs) frequently employ Rotary Positional Encodings (RoPE), which embed rotations directly into the keys and queries. This breaks the "full" orthogonal symmetry assumed in the current framework, necessitating more specialized, RoPE-aware alignment techniques in the future. Finally, while "soft" permutations (using Sinkhorn layers) can improve midpoint performance, they do not preserve exact functional equivalence at the endpoints, highlighting an ongoing trade-off between optimal connectivity and strict model integrity.

Summary updated

BibTeX
@inproceedings{theus2025generalized,
  author = {Alexander Theus and Alessandro Cabodi and Sotiris Anagnostidis and Antonio Orvieto and Sidak Pal Singh and Valentina Boeva},
  title = {{Generalized Linear Mode Connectivity for Transformers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=KurYdcCbjv},
}
Figure