Gradient Masked Averaging for Federated Learning

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

TL;DR

Gradient Masked Averaging (GMA) is a drop-in replacement for standard update averaging in Federated Learning (FL). By applying a "soft mask" based on directional agreement across clients, GMA helps the global model ignore spurious local features and focus on invariant mechanisms, significantly improving generalization in heterogeneous (non-i.i.d.) data settings.

What Problem Does This Paper Address?

Federated Learning (FL) allows multiple clients to train a shared global model without ever exchanging their raw, sensitive data. However, a major roadblock is data heterogeneity: the data on a smartphone in Tokyo looks very different from data on a laptop in London (non-i.i.d. distribution).

Standard FL algorithms, like FedAvg, simply average the updates sent by clients. The authors argue that this naive averaging leads to "information loss." Specifically, the global model can become biased toward "spurious mechanisms"—features that are dominant in a few specific clients but don't generalize across the whole population. This results in "client drift," where the model optimizes for local objectives at the expense of global performance.

Methods

The authors propose Gradient Masked Averaging (GMA), inspired by recent advances in Out-of-Distribution (OOD) generalization. The core idea is to treat different clients as different "environments" and look for updates that are consistent across them.

The process works as follows:

  1. Local Updates: Clients perform their usual local training and send their updates ($\Delta^n$) to the server.
  2. Agreement Score: The server calculates an element-wise agreement score ($A$) for every parameter. This score is the absolute value of the mean of the signs of the client updates. If all clients agree on the direction (all positive or all negative), the score is 1. If they are perfectly split, the score is 0.
  3. Soft Masking: Instead of a hard binary mask (which can kill convergence speed), GMA uses a soft mask ($\tilde{m}_\tau$). If the agreement score is above a threshold $\tau$, the update is kept as is. If it's below $\tau$, the update magnitude is scaled down proportional to the agreement score.
  4. Aggregation: The final global update is the masked version of the average update.
Figure 1: Illustration of Gradient Masked Averaging (GMA). Each client receives a global model and performs multiple iterations to obtain a final update sent to the server. The server uses the sign of each update component to determine an elementwise agreement score. This is then used to adjust the overall global model update, emphasizing components where client’s agree on their direction.

Crucially, GMA is a drop-in replacement. It can be plugged into existing FL optimizers like FedAvg, FedProx, FedAdam, or FedYogi without changing the underlying algorithm.

Datasets

The authors evaluated GMA across a wide range of scenarios:

  • Standard Benchmarks: MNIST, FMNIST, CIFAR-10, CIFAR-100, and TinyImageNet.
  • Real-World Heterogeneity: FEMNIST, which uses actual user-based data splits.
  • Synthetic Skews: They induced label distribution skew, feature distribution skew, and quantity imbalance to stress-test the algorithm.
  • OOD Evaluation: FedCMNIST, a variant where spurious color-digit correlations are introduced to test if the model can ignore them and focus on the invariant digit shapes.
Summary of datasets and heterogeneity settings

Key Insights and Ideas

  • Invariance as a Proxy for Generalization: The paper shifts the goal from "finding the average update" to "finding the invariant update." If clients disagree on a gradient direction, that direction likely represents a local quirk rather than a fundamental pattern.
  • The Power of the Sign: Simply looking at the sign of the updates is a computationally cheap but effective way to measure agreement in high-dimensional parameter spaces.
  • Overcoming the Convergence Trade-off: Previous "AND-mask" techniques often suffered from slow convergence because they zeroed out too many gradients. GMA’s soft masking provides the benefits of robustness without sacrificing the speed needed for practical FL.
  • Robustness to Hyperparameters: The authors found that a threshold of $\tau = 0.4$ (meaning at least 70% of clients agree on a direction) worked consistently well across almost all datasets and algorithms.

Key Results

GMA consistently outperformed standard averaging (AVG) across nearly all tested configurations, with the most dramatic gains appearing in highly heterogeneous settings:

  • Accuracy Boosts: On CIFAR-100 with label skew, GMA improved FedAdam's accuracy from 53.4% to 56.68%. On the real-world FEMNIST dataset, it improved FedAvg from 94.28% to 95.57%.
  • Better Generalization: GMA showed a significant advantage in performance on "non-participating clients"—clients whose data was not used in a particular training round. In one FMNIST trial, GMA improved accuracy for non-participating clients by 4.6% compared to only 2.4% for participating ones.
  • Privacy Side-Effect: Interestingly, the authors found that GMA models were slightly more resistant to Membership Inference Attacks, likely because the masking prevents the model from overfitting to specific data points from individual clients.

Limitations and Future Work

  • Threshold Sensitivity: While $\tau=0.4$ was robust, the optimal threshold might still vary for extremely niche tasks.
  • Theoretical Simplifications: The convergence analysis assumes the masks follow independent Bernoulli distributions, which is a simplification of the complex, correlated reality of neural network training.
  • Future Directions: The authors suggest exploring masks that incorporate the magnitude of gradients, not just the sign, and investigating how GMA interacts with other privacy-preserving techniques like Differential Privacy.

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