D2: Decentralized Training over Decentralized Data

Hanlin Tang, Xiangru Lian, Ming Yan, Ce Zhang, Ji LiuICML 2018

TL;DR

The $D^2$ algorithm solves a major bottleneck in decentralized machine learning: the performance collapse that occurs when data is distributed unevenly across workers (non-IID data). By adding a clever variance reduction component to standard decentralized SGD, $D^2$ achieves the same convergence rate as centralized training, even when every worker has a completely different dataset.

The Problem: Data Heterogeneity in Decentralized Learning

In decentralized learning, a group of workers (computers or edge devices) collaborates to train a single model by communicating only with their immediate neighbors. There is no central server coordinating the updates. While this architecture is excellent for privacy and scaling, it harbors a "dirty secret": standard algorithms usually assume the data on every worker is roughly the same, or Independent and Identically Distributed (IID).

In the real world, data is inherently "decentralized" and "unique." One worker might only have photos of cats, while another has only dogs. This creates "outer variance" ($\zeta^2$)—a measure of how much local gradients differ across the network. Standard algorithms like Decentralized Parallel SGD (D-PSGD) are highly sensitive to this variance. When data is very different across workers, D-PSGD converges slowly or fails entirely because the local updates pull the model in contradictory directions.

The Solution: The $D^2$ Algorithm

The authors introduce $D^2$ (Decentralized Training over Decentralized Data) to tackle this exact issue. It builds upon the foundation of D-PSGD but incorporates a crucial variance reduction mechanism.

  • The Standard Way (D-PSGD): Workers average their models with neighbors and then take a local gradient step.
  • The $D^2$ Way: Each worker keeps track of its local model and stochastic gradient from the previous iteration. The update rule combines the current gradient with the difference between the previous model and previous gradient.
  • The Intuition: This "difference" term acts as a correction factor. It effectively cancels out the steady-state bias caused by different workers looking at different data distributions. Mathematically, it ensures that the mean update across all workers behaves like a centralized stochastic gradient descent step, regardless of how diverse the local data is.

Theoretical Breakthrough

The most significant theoretical contribution is that $D^2$ improves the convergence rate from $O(\frac{\sigma}{\sqrt{nT}} + \frac{(n\zeta^2)^{1/3}}{T^{2/3}})$ to $O(\frac{\sigma}{\sqrt{nT}})$. By completely removing the term involving $\zeta^2$ (inter-node variance), the algorithm becomes theoretically as fast as centralized training. It also achieves "linear speedup," meaning doubling the number of workers roughly halves the training time required to reach a certain accuracy.

Experimental Setup and Key Results

The researchers evaluated $D^2$ using two primary setups:

  1. TRANSFERLEARNING: Using the first 16 classes of ImageNet with a pre-trained InceptionV4 model as a feature extractor to train a logistic regression model.
  2. LENET: Training a LeNet architecture from scratch on the CIFAR-10 dataset.

They tested these in two modes: Unshuffled (Non-IID), where each worker only has access to a limited set of labels, and Shuffled (IID), where data is randomly distributed.

Robustness to Heterogeneity (Non-IID Data)

In the "Unshuffled" experiments, data variance across workers is maximized. Here, standard D-PSGD struggled significantly, showing higher loss and highly unstable training curves. In contrast, $D^2$ performed almost identically to the centralized baseline.

Training loss on unshuffled (Non-IID) data for TransferLearning and LeNet. D² matches centralized performance while standard decentralized training struggles.

On the LeNet/CIFAR-10 task with high data variance, D-PSGD failed to converge with a standard learning rate, while $D^2$ remained remarkably stable and converged quickly.

Consistency on Uniform Data (IID Data)

When data was shuffled (IID), $D^2$ performed just as well as D-PSGD. This proves there is no performance "penalty" for using the more robust $D^2$ algorithm in simpler, uniform scenarios.

Training loss on shuffled (IID) data. D² performs consistently well, matching both standard decentralized and centralized baselines.

Limitations and Future Work

While $D^2$ represents a major step forward, the authors note a few limitations:

  • Batch Normalization: Modern neural networks often use Batch Normalization, which assumes data is uniform across batches. In a highly decentralized, non-IID setting, standard Batch Norm fails. While $D^2$ fixes the gradient logic, it doesn't solve the Batch Norm statistics problem.
  • Topology: The experiments primarily used a ring topology. While the theory covers any connected graph, the performance impact of more complex or dynamic network structures remains an area for further exploration.
  • Hyperparameters: Like most deep learning algorithms, $D^2$ still requires careful tuning of the learning rate to achieve optimal performance.

Summary updated

BibTeX
@inproceedings{tang2018d,
  author = {Hanlin Tang and Xiangru Lian and Ming Yan and Ce Zhang and Ji Liu},
  title = {{D2: Decentralized Training over Decentralized Data}},
  booktitle = {International Conference on Machine Learning},
  year = {2018},
}
Figure