Going Beyond Linear Mode Connectivity: The Layerwise Linear Feature Connectivity

Zhanpeng Zhou, Yongyi Yang, Xiaojiang Yang, Junchi Yan, Wei Hu

Introduction

Recent research into neural network training has revealed intriguing phenomena regarding the highly complex loss landscape. One prominent observation is Linear Mode Connectivity (LMC), where different training solutions can be connected by a linear path in parameter space without a drop in accuracy. However, LMC primarily describes the "surface" of the loss landscape—the final output. This paper introduces Layerwise Linear Feature Connectivity (LLFC), shifting the focus to internal representations to explain why and how these models can be seamlessly blended.

The Phenomenon of Linear Mode Connectivity

In deep learning, different training runs typically converge to different optima. Surprisingly, if two models are trained from the same early checkpoint (a process called spawning) or if their neurons are aligned post-training (permutation), a straight line can be drawn between their weights in the parameter space while maintaining near-constant training and test losses.

While LMC is fascinating, it leaves a critical question unanswered: does weight averaging work because the internal, hidden-layer representations are also being averaged?

Introducing Layerwise Linear Feature Connectivity (LLFC)

To investigate the internal mechanics of LMC, the authors propose LLFC. Formally, if two models ($A$ and $B$) are interpolated by averaging their weights, LLFC holds if the internal feature maps produced by the interpolated model are approximately equal to the average of the feature maps produced by $A$ and $B$ individually.

Illustration of Layerwise Linear Feature Connectivity

The authors investigate this using two primary methods to generate connected models:

  1. Spawning: Training a model for a few epochs, then branching it into separate runs with different data shuffling or augmentation.
  2. Permutation (e.g., Git Re-Basin): Taking two independently trained models and re-ordering the neurons of one to match the other.

Theoretical Underpinnings

Through rigorous mathematical analysis, the paper identifies two core conditions that imply LLFC:

  • Weak Additivity: Despite being a non-linear function, the ReLU activation behaves linearly along the specific interpolation path between the two models. The "on/off" activation patterns are similar enough that averaging them preserves the network's logic.
  • Commutativity: A property indicating that the linear transformation of one model's layer can be swapped with the features of the other model without introducing significant error.

The authors successfully prove (Theorem 1) that Weak Additivity combined with Commutativity mathematically guarantees LLFC.

Key Findings and Implications

  • LLFC is a Stronger Condition than LMC: The authors demonstrate that if a model satisfies LLFC at its output layer, it automatically satisfies LMC. LLFC provides a finer-grained, layer-by-layer perspective on model similarity.
  • Empirical Verification: Across various architectures (MLPs, VGG-16, ResNet-20/50) and datasets (MNIST, CIFAR-10, Tiny-ImageNet), the authors found that whenever LMC is present, LLFC is also present. The cosine similarity between interpolated features and the linear average of features consistently approaches 1.0.
  • Justifying Permutation Methods: The theoretical framework justifies recent model merging techniques. Matching activations or weights is essentially an attempt to satisfy the Commutativity condition.
  • Zero-Shot Model Stitching: Because internal features are functionally interchangeable in LLFC-compliant models, one can perform "model stitching"—connecting the first half of Model A to the second half of Model B—without requiring additional transformation layers. In experiments, stitched models achieved error rates remarkably close to the original models (e.g., 2.11% error for a stitched MLP on MNIST versus ~1.8% for the originals).

Limitations and Future Directions

While LLFC offers a powerful new lens for understanding neural networks, the study notes a few limitations:

  • Scope: The current empirical validation is limited to image classification tasks. Exploring LLFC in Natural Language Processing or Generative Models remains a crucial next step.
  • Scaling Factor: The formal definition of LLFC includes a scaling factor ($c$). Although empirically observed to be close to 1, a rigorous theoretical explanation for this scaling factor is still needed.
  • Computational Complexity: Directly enforcing the commutativity property involves solving Quadratic Assignment Problems (QAPs), which are NP-hard. Discovering efficient methods to encourage LLFC during training could significantly advance fields like federated learning and model merging.

Summary updated

BibTeX
@inproceedings{zhou2023going,
  author = {Zhanpeng Zhou and Yongyi Yang and Xiaojiang Yang and Junchi Yan and Wei Hu},
  title = {{Going Beyond Linear Mode Connectivity: The Layerwise Linear Feature Connectivity}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=vORUHrVEnH},
}
Figure