Toward Data Efficient Model Merging between Different Datasets without Performance Degradation

Masanori Yamada, Tomoya Yamashita, Shin'ya Yamaguchi, Daiki Chijiwa

TL;DR

While deep neural networks trained with different random seeds on the same dataset can be easily merged via weight permutation, merging models trained on different datasets causes severe performance degradation. This paper reveals that weight-only matching fails because it ignores the steep loss barrier between differing data distributions. By guiding neuron alignment with tiny surrogate datasets—via dataset condensation or simple random coreset sampling—the authors achieve strong merged accuracy (e.g., an 82.6% test accuracy on Split-CIFAR10 with only 50 images per class) without needing the full original datasets.

What Problem Does This Paper Address?

Model merging aims to combine independently trained neural networks into a single model by permuting and averaging their weights. Under Linear Mode Connectivity (LMC), two models trained on the same dataset can often be aligned in weight space without encountering a loss barrier between them.

However, merging models trained on different datasets (or disjoint task splits) remains unsolved:

  1. Weight-Only Alignment Breaks Down: Standard zero-data methods (like Weight Matching) align neurons by minimizing the Euclidean distance between weight matrices. Across different datasets, minimizing weight distance fails to bridge the performance gap.
  2. Data Access Constraints: While data-driven alignment methods (like the Straight-Through Estimator) recover accuracy, they typically demand the full training sets. Sharing massive datasets is computationally prohibitive and often impossible due to privacy, security, and bandwidth limitations.

The authors investigate why cross-dataset merging fails and whether model merging can succeed using only a tiny fraction of data.

Methods

The paper contrasts weights-only matching with data-driven alignment and introduces surrogate data strategies:

  • Weight Matching (WM): A standard baseline that solves a linear assignment problem to align neurons by minimizing the $L_2$ distance between weight tensors, using no data.
  • Straight-Through Estimator (STE) Merging: An optimization-based merging approach that directly optimizes the neuron permutation matrix to minimize prediction loss on the mixed data distribution.
  • Surrogate Dataset Construction: Rather than evaluating STE on the full dataset, the authors create lightweight proxies:
  • Coreset Selection: Selecting a small subset of samples. Surprisingly, uniform random sampling per class performed as well as complex coreset selection heuristics.
  • Dataset Condensation: Synthesizing highly informative condensed samples via Gradient Matching (and infinite-width kernel methods for CIFAR-10).
  • Interpolation Repair (REPAIR): Applied post-merging to renormalize layer activation statistics, mitigating variance collapse introduced by batch normalization.

Datasets

The authors evaluated cross-domain and split-task setups across several benchmarks:

  • Rotated-MNIST (RMNIST): MNIST images rotated at angles from $0^\circ$ to $90^\circ$ to systematically measure how domain shift affects the loss landscape.
  • USPS and MNIST (USPS-MNIST): Domain adaptation between two distinct handwritten digit datasets.
  • SPLIT-CIFAR10: CIFAR-10 split into two disjoint 5-class subsets (classes 0–4 vs. 5–9) evaluated on a wide ResNet-20×16 architecture.
  • MNIST-FMNIST: Merging two completely different visual tasks (digits vs. Fashion-MNIST clothing classes) sharing the same output dimensions.

Key Insights and Ideas

  • Close weights do not imply low loss across datasets: On a single dataset, the loss minima share the same basin. Across different datasets, bringing weights close in $L_2$ space does not eliminate the loss barrier. In fact, weights forced into proximity often yield sharp loss spikes on the joint task.
  • Weight-space metrics fail to correlate with mixed-task loss: Neither weight $L_2$ distance nor local loss sharpness correlates with merged test loss. Only directly measuring the empirical loss barrier predicts merged model performance, confirming that data signals are strictly necessary.
  • A handful of examples suffices: Neuron alignment does not require learning new representations—the individual networks already learned them. The data is only needed to solve the permutation assignment. Consequently, as few as 10 to 50 samples per class are sufficient for near-optimal merging.
  • Merging beats training from scratch on small data: Training a model from scratch on the surrogate dataset yielded poor results (e.g., 38.5% on Split-CIFAR10), whereas merging pre-trained models using the exact same surrogate dataset achieved 82.6%.

Key Results

  • Split-CIFAR10:
  • Naïve weight averaging collapses to 10.00%.
  • Weight-only matching (WM) achieves 58.91%, and ZipIt! achieves 72.05%.
  • STE with the full dataset reaches 89.80%.
  • STE with a surrogate coreset (50 samples/class) reaches 82.77% (and 88.62% with 500 samples/class).
  • MNIST-RMNIST ($90^\circ$ shift):
  • Full STE achieves 93.52% test accuracy.
  • Surrogate methods (both 10-shot Coreset and Data Condensation) achieve 88.78%, substantially outperforming WM (70.92%).
  • Speedup: STE with surrogate data reached over 80% accuracy in significantly fewer optimization steps than training a joint network from scratch.

Limitations and Future Work

  • Combinatorial Optimization: STE optimizes permutations heuristically; the combinatorial search space lacks formal convergence guarantees.
  • Architecture Scope: Experiments were restricted to matching identical architectures on image classification benchmarks (MLPs and ResNet-20×16).
  • Scaling to Modern Modalities: Extending surrogate-guided merging to large language models, vision-language models, and diffusion architectures remains open.
  • Privacy Guarantees: While sharing surrogate datasets or synthetic condensed images reduces data leakage compared to sharing raw datasets, formal differential privacy guarantees were not analyzed.

Summary updated

BibTeX
@inproceedings{yamada2024toward,
  author = {Masanori Yamada and Tomoya Yamashita and Shin'ya Yamaguchi and Daiki Chijiwa},
  title = {{Toward Data Efficient Model Merging between Different Datasets without Performance Degradation}},
  booktitle = {ACML Conference Track},
  year = {2024},
  url = {https://openreview.net/forum?id=Le3qPaeSAn},
}
Figure