Gradient Masked Federated Optimization

Irene Tenison, Sreya Francis, Irina RisharXiv 2021

Introduction

Federated Learning (FL) has emerged as a pivotal paradigm for training machine learning models across decentralized edge devices while preserving data privacy. The standard algorithm, Federated Averaging (FedAVG), aggregates local model updates by simple parameter averaging. However, FedAVG often struggles with non-identically and independently distributed (non-IID) data. In such scenarios, local models diverge toward disparate optima, and their average may fail to generalize to new, unseen clients—a challenge known as Out-of-Distribution (OOD) generalization.

The Challenge of Non-IID Data

When data is non-IID, different clients may rely on "spurious correlations" unique to their local environments. For instance, in a medical imaging task, one hospital's data might have a specific lighting condition correlated with a diagnosis. FedAVG "sews together" these conflicting local optima. The resulting global model sits at a mathematical average that may not capture the invariant features necessary for robust performance across all potential distributions.

Comparison of local loss surfaces and the resulting FedAVG server loss surface, illustrating how averaging divergent optima can lead to a global minimum that poorly represents individual client logic.

As shown in the loss surface visualizations, the global average (c) can end up in a region that is suboptimal for both client A (a) and client B (b), leading to significant "client drift."

FedGMA: Federated Gradient Masked Averaging

To address this, we introduce FedGMA, an optimization framework that incorporates a "gradient mask" to enforce consensus. Inspired by Invariant Risk Minimization (IRM), FedGMA seeks features that are consistent across different client environments.

The AND-Mask Mechanism

The core of FedGMA is the AND-Mask applied during the server-side update:

  1. Local Update: Clients compute their total gradient (the difference between initial and final local weights).
  2. Sign Agreement: The server examines the sign of each gradient component across all participating clients.
  3. Masking: An update for a specific parameter is only retained if a threshold percentage of clients (e.g., 80%) agree on the direction (sign) of the change. If there is significant disagreement, the component is zeroed out.
  4. Consensus Update: The server updates the global model using both the standard parameter average and an additional step in the direction of this "masked" consensus gradient.

By treating disagreement as noise, the AND-mask forces the model to ignore spurious features and focus on invariant ones that are universally supported across the client population.

Experimental Evaluation

We evaluated FedGMA using the Colored MNIST (CMNIST) benchmark, specifically designed to test OOD generalization. In CMNIST, digit color is highly correlated with the label during training but randomized or reversed during testing. A model that generalizes well must learn to ignore color and focus on digit shape.

Key Results

FedGMA demonstrates significant improvements in OOD accuracy compared to FedAVG, particularly in non-IID settings.

OOD accuracy for multiclass classification on CMNIST under IID (left) and non-IID (right) conditions. FedGMA consistently outperforms FedAVG, especially as the server step size (lr_s) is tuned.

As illustrated in the multiclass classification results, FedGMA maintains higher accuracy on the "flipped" color test set. While FedAVG's performance degrades as data heterogeneity increases, FedGMA remains robust. The effectiveness of the algorithm is sensitive to the server step size ($\eta_s$), where a larger step size allows the consensus gradient to more effectively steer the global model away from divergent local minima.

Conclusion and Future Directions

FedGMA provides a principled approach to mitigating client drift in federated learning by prioritizing gradient consensus. By filtering out inconsistent updates, it promotes the learning of invariant features, leading to superior OOD generalization. Future research will focus on scaling FedGMA to more complex datasets and optimizing the agreement threshold hyperparameter.

Summary updated

BibTeX
@misc{tenison2021gradient,
  author = {Irene Tenison and Sreya Francis and Irina Rish},
  title = {{Gradient Masked Federated Optimization}},
  year = {2021},
  eprint = {2104.10322},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.10322},
}
Figure