Federated Learning with Matched Averaging

Hongyi Wang, Mikhail Yurochkin, Yuekai Sun, Dimitris S. Papailiopoulos, Yasaman Khazaeni

TL;DR

Standard Federated Learning often fails because it naively averages neural network weights coordinate-by-coordinate, ignoring that different clients might learn the same features in different "slots." Federated Matched Averaging (FedMA) solves this by using a layer-wise matching algorithm to align neurons, channels, or hidden states before averaging them. This approach significantly boosts performance on heterogeneous data and reduces the communication rounds needed to reach high accuracy.

What Problem Does This Paper Address?

In Federated Learning (FL), a central server coordinates multiple edge devices (like phones or sensors) to train a shared model without ever seeing their private data. The "gold standard" algorithm, FedAvg, works by having clients train locally and then averaging their model weights.

However, FedAvg has a major flaw: permutation invariance. In a neural network, you can swap the positions of two neurons in a layer (and adjust the next layer accordingly) without changing the model's output. Because of this, Client A might learn a "vertical edge detector" in its first neuron, while Client B learns the exact same detector in its tenth neuron. If you naively average their weights coordinate-wise, you end up washing out these features, leading to a "blurry" global model that performs poorly, especially when the data across clients is very different (heterogeneous).

Methods

The authors propose FedMA, which moves away from coordinate-wise averaging in favor of Matched Averaging.

  1. Layer-wise Matching: Instead of trying to match the entire model at once (which is computationally NP-hard), FedMA constructs the global model one layer at a time.
  2. The Hungarian Algorithm & Bayesian Nonparametrics: For each layer, the server collects weights from clients and treats the problem as a "maximum bipartite matching" task. It uses a framework based on the Beta-Bernoulli Process (BBP-MAP) to find which neurons from different clients "match" based on their feature extraction signatures (e.g., Euclidean similarity of weights).
  3. Iterative Construction: The process is recursive. The server matches the first layer, averages the matched neurons to create a global first layer, and sends it back. Clients then "freeze" this global layer and train the next layer. This continues until the entire network is built.
  4. Adaptive Model Size: A unique feature of FedMA is that the global model's size can adapt. If a client has learned a unique feature that doesn't match anyone else's, the algorithm can choose to add a new neuron to the global model rather than forcing a bad match.

Datasets

The authors evaluated FedMA on three classic benchmarks using different architectures:

  • MNIST: Using the LeNet architecture.
  • CIFAR-10: Using a deep VGG-9 convolutional neural network.
  • Shakespeare: A language modeling task using LSTMs (Long Short-Term Memory networks) to predict the next character in plays.

They specifically focused on heterogeneous (non-IID) partitions, where each client only sees a subset of classes or specific data distributions, simulating real-world edge device conditions.

Key Insights and Ideas

  • Neurons are not Coordinates: The core "aha" moment is that weights are just a representation; the function is what matters. By matching neurons with similar "signatures," FedMA preserves the specialized features learned by individual clients.
  • Communication Efficiency via Layer-wise Training: While FedAvg requires hundreds of communication rounds, FedMA's basic version only requires as many rounds as there are layers in the network. Even with additional communication rounds to refine the model, it remains much more "bandwidth-thrifty."
  • Robustness to Local Training: In FedAvg, training too much on local data often causes the global model to diverge. FedMA actually benefits from more local training because it results in higher-quality features that are easier to match accurately.
Test accuracy versus the number of local epochs. FedMA benefits from more local training, whereas FedAvg diverges.
  • Interpretability: The paper shows that matched filters actually look similar. For example, if two clients both learn to detect "horse legs," FedMA correctly identifies and merges those specific filters.

Key Results

  • Superior Accuracy: On the VGG-9/CIFAR-10 task with heterogeneous data, FedMA achieved 87.53% accuracy, outperforming FedAvg (86.29%) and FedProx (85.32%).
  • Massive Communication Savings: To reach a target accuracy on the Shakespeare dataset, FedMA required significantly less data transfer (in Gigabytes) compared to FedAvg, largely because it converges in far fewer rounds.
Test accuracy versus communication amount (GB) for VGG-9 on CIFAR-10. FedMA achieves higher accuracy with significantly less communication.
  • Handling Data Bias: In a "skewed domain" experiment where some clients only saw grayscale images and others saw color, FedMA was able to successfully aggregate the knowledge, while standard training often failed to learn meaningful relations.

Limitations and Future Work

  • Architecture Constraints: The current version of FedMA was tested on VGG and LSTMs. It does not yet explicitly handle more complex building blocks like Residual Connections (ResNets) or Batch Normalization, which are standard in modern computer vision.
  • Sequential Bottleneck: The layer-wise "freeze and train" approach means you can't train the whole network at once during the matching phase, which might be restrictive for certain types of architectures.
  • Computational Complexity: While the Hungarian algorithm is efficient, matching very large layers across hundreds of clients could eventually become a computational bottleneck for the central server.

The authors suggest that future work will focus on extending these matching techniques to more diverse architectures and improving the quadratic assignment solutions for RNNs.

Summary updated

BibTeX
@inproceedings{wang2020federated,
  author = {Hongyi Wang and Mikhail Yurochkin and Yuekai Sun and Dimitris S. Papailiopoulos and Yasaman Khazaeni},
  title = {{Federated Learning with Matched Averaging}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
}
Figure