Gradient Masked Averaging for Federated Learning

Irene Tenison, Sai Aravind Sreeramadas, Vaikkunth Mugunthan, Edouard Oyallon, Irina Rish, Eugene Belilovsky

Abstract: Federated learning (FL) is an emerging paradigm that permits a large number of clients with heterogeneous data to coordinate learning of a unified global model without the need to share data amongst each other. A major challenge in federated learning is the heterogeneity of data across client, which can degrade the performance of standard FL algorithms. Standard FL algorithms involve averaging of model parameters or gradient updates to approximate the global model at the server. However, we argue that in heterogeneous settings, averaging can result in information loss and lead to poor generalization due to the bias induced by dominant client gradients. We hypothesize that to generalize better across non-i.i.d datasets, the algorithms should focus on learning the invariant mechanism that is constant while ignoring spurious mechanisms that differ across clients. Inspired from recent works in Out-of-Distribution generalization, we propose a gradient masked averaging approach for FL as an alternative to the standard averaging of client updates. This aggregation technique for client updates can be adapted as a drop-in replacement in most existing federated algorithms. We perform extensive experiments on multiple FL algorithms with in-distribution, real-world, feature-skewed out-of-distribution, and quantity imbalanced datasets and show that it provides consistent improvements, particularly in the case of heterogeneous clients.

Introduction

Federated Learning (FL) enables decentralized training across numerous edge devices, such as mobile phones or medical imaging stations, without centralizing raw data. The standard approach, FedAvg, aggregates local updates by simple averaging. However, real-world data is rarely independent and identically distributed (i.i.d.). When clients possess highly skewed data—for instance, one client having only images of cats and another only dogs—standard averaging can lead to "client drift." In these scenarios, the global model may overfit to local noise or dominant client signals, washing out the "invariant" features that are universally true across the entire data distribution.

The authors argue that standard averaging acts like a logical "OR" operation, incorporating spurious signals. Instead, a logical "AND" operation is needed to prioritize features where clients reach a consensus.

Methodology: Gradient Masked Averaging (GMA)

To address the limitations of simple averaging, this paper introduces Gradient Masked Averaging (GMA). Inspired by Out-of-Distribution (OOD) generalization techniques, GMA modifies the server-side aggregation step to focus on gradient consensus.

Overview of the Gradient Masked Averaging (GMA) process, illustrating sign agreement and soft masking.

The GMA process follows four key steps:

  1. Sign Agreement: For each model parameter, the server evaluates the signs (positive or negative) of the updates received from all participating clients.
  2. Agreement Score: An agreement score is calculated based on the consensus of these signs. High consensus suggests the update direction represents a fundamental, invariant feature.
  3. Soft Masking: Unlike previous "hard" masking approaches that could stall convergence, GMA applies a "soft" mask. If the agreement score exceeds a threshold ($\tau$), the update is applied normally. If agreement is low, the update for that specific parameter is scaled down proportionally.
  4. Compatibility: GMA is designed as a drop-in replacement for the aggregation step in existing FL frameworks, such as FedAvg, FedProx, FedAdam, and FedYogi.

Experimental Setup

The researchers evaluated GMA across a diverse set of benchmarks to test its robustness against various forms of data heterogeneity, including label skew, quantity skew, and feature skew.

Summary of datasets, skew types, and experimental configurations used to evaluate GMA.

The evaluation included standard vision datasets (MNIST, CIFAR-10/100) and more complex real-world scenarios like FEMNIST (based on actual user handwriting) and FedCMNIST (designed to test if models can ignore spurious color correlations in favor of invariant digit shapes).

Key Results and Insights

  • Improved Generalization: GMA consistently outperformed standard averaging across nearly all tested datasets and algorithms. The performance boost was most significant in highly non-i.i.d. settings, such as a 1-2% accuracy improvement on CIFAR-10 over FedAvg.
  • OOD Robustness: In the FedCMNIST experiments, GMA demonstrated a superior ability to ignore spurious correlations (like background color) compared to standard FedAvg, focusing instead on the invariant shapes of the digits.
  • Privacy Benefits: By prioritizing consensus and downweighting unique client-specific directions, GMA naturally mitigates Membership Inference Attacks. Simulations showed a reduction in attack accuracy from 57% to 55%, indicating the model is less likely to memorize individual client outliers.
  • Stability: The method proved robust to its primary hyperparameter, $\tau$, with a value of 0.4 providing stable performance across most experimental configurations.

Conclusion and Future Work

Gradient Masked Averaging provides a robust alternative to standard aggregation in Federated Learning, specifically targeting the challenges of data heterogeneity. By using sign agreement as a proxy for feature invariance, GMA improves model generalization and privacy.

While effective, the authors note that optimal performance may still require some hyperparameter tuning of $\tau$, which can be challenging in data-blind federated settings. Future research may explore incorporating gradient magnitude into the masking process to capture more nuanced agreement beyond simple directional signs.

Summary updated

BibTeX
@article{tenison2023gradient,
  author = {Irene Tenison and Sai Aravind Sreeramadas and Vaikkunth Mugunthan and Edouard Oyallon and Irina Rish and Eugene Belilovsky},
  title = {{Gradient Masked Averaging for Federated Learning}},
  journal = {Accepted by TMLR},
  year = {2023},
  url = {https://openreview.net/forum?id=REAyrhRYAo},
}
Figure