Implicit Gradient Alignment in Distributed and Federated Learning

Yatin Dandi, Luis Barba, Martin Jaggi

Abstract

Stochastic Gradient Descent (SGD) possesses an inherent ability to generalize well by implicitly aligning gradients across sequential mini-batches. This implicit regularization is frequently lost in large-batch distributed training and heterogeneous federated learning (FL), leading to performance degradation known as the "generalization gap" and "client drift." We present GradAlign and its federated extension, FedGA, which restore this regularization through calculated parameter displacements. By shifting weights before gradient computation, these methods force alignment in parallel settings. Our analysis also reveals that the popular SCAFFOLD algorithm implicitly performs a similar alignment. Experimental results on EMNIST and CIFAR-10 show that FedGA and GradAlign outperform standard baselines, effectively closing the generalization gap in large-batch training and mitigating client drift in non-IID federated settings.

Introduction

In distributed and federated learning, training is accelerated by parallelizing updates across multiple workers or clients. However, when data is heterogeneous (non-IID), gradients from different clients often point in conflicting directions, causing "client drift" that hinders convergence. Furthermore, standard large-batch distributed training suffers from a well-known generalization gap. This paper argues that these issues arise because large-batch and parallel training lose the implicit regularization inherent to the sequential nature of standard SGD.

The Theory of Implicit Gradient Alignment

The authors mathematically demonstrate that sequential SGD steps implicitly minimize a regularization term representing the variance of gradients across mini-batches. This "gradient alignment" is a key driver of SGD's ability to generalize to unseen data. When updates are parallelized or batches are made very large, this sequential alignment is lost, leading to poorer model performance.

Proposed Algorithms: GradAlign and FedGA

To replicate the benefits of sequential SGD in a parallel environment, the authors propose two novel algorithms based on strategic parameter displacements:

  • GradAlign (GA): Instead of computing gradients on current model weights, GA applies a calculated displacement $v_i = -\beta(\nabla f(x) - \nabla f_i(x))$ to the weights before computing the gradient for mini-batch $i$. This forces the optimizer to align gradients across different mini-batches even when computed in parallel.
  • FedGA (Federated Gradient Alignment): This extends the concept to federated settings. Each client calculates a displacement based on the global gradient, applies it, and then performs local SGD steps from this displaced starting point.

Interestingly, theoretical analysis shows that SCAFFOLD, a popular FL algorithm, inadvertently induces a similar implicit gradient alignment through its use of control variates. FedGA improves upon this by decoupling the displacement step size from the learning rate, allowing for finer regularization control.

Geometric comparison of the gradient update paths for GradAlign, FedGA, and SCAFFOLD.

Experimental Evaluation

The algorithms were evaluated on standard image classification benchmarks, including EMNIST (in both IID and highly heterogeneous settings) and CIFAR-10.

Key Results

  • Superior Accuracy on Heterogeneous Data: On highly heterogeneous EMNIST, FedGA achieved 85.95% test accuracy, significantly outperforming SCAFFOLD (84.67%), FedProx (83.19%), and FedAvg (82.9%).
  • Closing the Generalization Gap: In datacenter distributed learning, GradAlign successfully utilizes large batches to minimize sequential updates without suffering the typical drop in test accuracy. As shown in the figure below, GradAlign maintains higher accuracy and faster convergence compared to standard Large-Batch SGD.
Test accuracy comparison on CIFAR-10 showing GradAlign's superior performance and generalization over Large-Batch SGD and SCAFFOLD.

Conclusion and Limitations

GradAlign and FedGA provide a principled way to restore the implicit regularization of SGD in distributed and federated settings. By aligning gradients through parameter displacement, these methods allow for massive parallelism and handle data heterogeneity more effectively than standard baselines.

However, the approach introduces a new hyperparameter, $\beta$ (displacement step size), which can be difficult to tune as its optimal value varies between IID and heterogeneous settings. Additionally, the requirement for an extra communication round to compute initial displacements may pose a bottleneck in extremely bandwidth-constrained environments, though this is often offset by faster overall convergence.

Summary updated

BibTeX
@inproceedings{dandi2022implicit,
  author = {Yatin Dandi and Luis Barba and Martin Jaggi},
  title = {{Implicit Gradient Alignment in Distributed and Federated Learning}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i6.20597},
}
Figure