Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Synchronous vs. Asynchronous SGD: Convergence and Hardware Tradeoffs

Introduction

Welcome to the next lesson in our exploration of large-scale training dynamics. In our previous discussions on data parallelism, particularly in the context of 3D parallelism, we implicitly assumed a synchronous update model. In this model, all workers (GPUs) process their mini-batch, compute gradients, and then participate in a collective AllReduce operation to average these gradients. Only after this global synchronization does every worker apply the exact same update to its copy of the model. This lock-step approach ensures consistency but isn't the only way to perform distributed training.

Today, we will dissect this assumption by comparing the synchronous Stochastic Gradient Descent (SGD) paradigm with its alternative, asynchronous SGD. This lesson will directly address the critical trade-offs between these two approaches, focusing on their impact on model convergence and hardware utilization. Understanding this trade-off is fundamental to designing efficient and robust distributed training systems.

The Fundamental Distinction: Blocking vs. Non-Blocking

At its heart, the difference between synchronous and asynchronous training mirrors the classic computer science concepts of blocking and non-blocking operations.

Synchronous vs. Asynchronous Processing Diagram
This diagram illustrates the core difference in execution flow. In synchronous processing, Process A must wait for Process B to finish. In asynchronous processing, Process A can continue its work while Process B operates in the background, handling the response when it arrives.

In the context of distributed training:

  • Synchronous: All worker processes are blocked at a synchronization barrier, waiting for every other worker to finish computing gradients before the collective update can proceed.
  • Asynchronous: Each worker process operates independently, sending its computed gradients to be applied without waiting for others.

This simple difference has profound consequences for both system efficiency and algorithmic behavior.

Synchronous SGD: Consistency and Stability

Synchronous SGD is the most direct extension of single-GPU training to a distributed setting. It operates in a highly coordinated, lock-step fashion.

For a deeper, more formal understanding of this process, please read the following section from the provided paper.

Analysis of Distributed Training Systems and Optimization Algorithms

The paper 'Analysis of Distributed Training Systems and Optimization Algorithms' provides a concise and formal definition of Synchronous SGD, including its update rule.

Please read section '3.1 Synchronous SGD'. Pay close attention to the global parameter update formula and the description of the multi-stage workflow: local computation, global synchronization (all-reduce), and parameter update.

As you read, the core mechanism of synchronous SGD is a multi-step cycle:

  1. Broadcast: All workers start with an identical copy of the model parameters .
  2. Local Computation: Each of the workers computes gradients on its own unique mini-batch of data.
  3. Synchronization & Aggregation: The workers enter a synchronization barrier. The gradients are aggregated across all workers, typically using an AllReduce operation, and averaged.
  4. Update: The global model parameters are updated using the averaged gradient: This new parameter set is then broadcast back to all workers for the next iteration.

This is exactly what happens when using libraries like NCCL for AllReduce, which we discussed in the context of data parallelism. The key characteristic is that all workers apply the same update based on information from the entire global batch.

Trade-offs of Synchronous SGD

Advantages:

  • Convergence Stability: Since gradients are always calculated on the current model state , there is no "staleness". The algorithm behaves exactly like standard mini-batch SGD on a very large batch (N times the per-worker batch size). This makes convergence behavior much easier to analyze and reproduce.
  • Algorithmic Correctness: It is a faithful implementation of the SGD algorithm, which is often critical for research and when precise replication of results is needed.

Disadvantages:

  • Hardware Underutilization (The Straggler Problem): The system's throughput is dictated by its slowest worker. If one GPU is slow due to hardware variation, network congestion, or contention from other processes, all other GPUs will sit idle waiting for it at the synchronization barrier. This can dramatically reduce overall hardware utilization.
  • High Communication Overhead: The global synchronization barrier can become a significant bottleneck, especially as the number of workers increases.

Asynchronous SGD: Maximizing Throughput

Asynchronous SGD relaxes the strict synchronization requirement to maximize hardware utilization. In this paradigm, workers don't wait for each other.

The dominant architecture for asynchronous training is the parameter server.

Introduction to Distributed Deep Learnring

This video from mlverse provides an excellent overview of the parameter server architecture, which was one of the earliest and most influential approaches to large-scale distributed training.

Watch the segment from 05:33 to 11:30. The speaker explains how workers compute gradients and send them to a central parameter server, the problem of overlapping updates, and why this 'relaxed consistency' works in practice for non-convex optimization.

The workflow in a parameter server architecture is as follows:

  1. Fetch Parameters: A worker fetches the latest model parameters from a central parameter server(s).
  2. Local Computation: The worker computes gradients on its mini-batch using the parameters it just fetched.
  3. Push Gradients: The worker sends its computed gradients back to the parameter server.
  4. Server-Side Update: The parameter server updates its copy of the model using the gradients it just received.

Crucially, each worker does this independently and on its own schedule.

The Stale Gradient Problem

The independence of workers introduces a fundamental challenge: gradient staleness. By the time a worker finishes computing its gradients and sends them to the parameter server, other workers may have already updated the model. Therefore, the gradients being applied are "stale"—they were computed based on an older version of the model parameters.

Gradient Staleness Distribution under Softsync Policies
This figure illustrates the concept of gradient staleness. The plots show the distribution of how many steps 'old' a gradient is when it is applied. A more synchronous system (a) has low staleness (most gradients are 1 step old). A highly asynchronous system (b, c) has a much wider distribution of staleness, with some gradients being significantly delayed.

This staleness introduces noise into the training process. While the stochastic nature of SGD provides some resilience, excessive staleness can hurt convergence.

Trade-offs of Asynchronous SGD

Advantages:

  • High Hardware Utilization: Workers are never idle. As soon as a worker finishes its task, it fetches the latest parameters and starts a new one. This is especially beneficial in heterogeneous clusters where workers have varying performance.
  • Fault Tolerance: If a worker fails, the training can continue with the remaining workers, making the system more robust for long-running jobs.

Disadvantages:

  • Convergence Instability: Stale gradients can degrade statistical efficiency, potentially slowing convergence or causing the model to diverge, especially with a large number of workers. This often requires careful tuning of hyperparameters like the learning rate.
  • Parameter Server Bottleneck: The centralized parameter server can become a communication bottleneck, as all workers must communicate with it.

A Head-to-Head Comparison: Theory and Practice

We now have a clear theoretical understanding of the trade-offs. Let's ground this with a direct comparison and empirical evidence.

First, let's watch a concise summary that contrasts the two approaches as implemented in TensorFlow.

A friendly introduction to distributed training (ML Tech Talks)

The TensorFlow channel provides a clear, practical comparison of synchronous (MirroredStrategy) and asynchronous (ParameterServerStrategy) training.

Please watch two clips. First, from 22:09 to 23:41, which provides a high-level recap. Then, for a more detailed explanation of the asynchronous approach, watch from 18:12 to 22:09.

The following table, adapted from the "Analysis of Distributed Training Systems" paper, provides an excellent summary of the core differences.

Dimension Synchronous SGD Asynchronous SGD
Update Mechanism Workers update in lock-step after aggregating all gradients. Each worker independently computes and pushes gradients.
Synchronization Strong synchronization; all workers wait at a barrier. Weak/no synchronization; workers proceed independently.
Gradient State Gradients are always fresh. Gradients can be stale, computed on older parameters.
Hardware Utilization Potential for idle time due to the "straggler problem". High utilization; no waiting.
Convergence Stability More stable and predictable. Potentially unstable; may require techniques to stabilize.
Communication Bottleneck at the global AllReduce barrier. Potential bottleneck at the central parameter server.
Best Use Cases Homogeneous clusters where stability is critical (e.g., research). Heterogeneous environments, large-scale production.

Empirical Evidence

The paper "Revisiting Distributed Synchronous SGD" from Google provides compelling experimental results. The authors found that while asynchronous training could be faster per step, the noise from stale gradients often led to lower final accuracy and required more training epochs to converge.

REVISITING DISTRIBUTED SYNCHRONOUS SGD

This paper provides a fantastic real-world analysis of the trade-offs, backed by experiments on the ImageNet dataset.

Please review the following parts of this paper: Section 2: A summary of Asynchronous SGD and the stale gradient problem. Section 3: An explanation of Synchronous SGD and a key practical optimization: backup workers to mitigate the straggler problem. Section 4: The ImageNet experiments. Focus on Figure 1 (comparing accuracy and epochs) and Figure 2 (comparing average step time).

The key findings from that paper are crucial for system design:

  1. Sync-SGD achieves better accuracy: By eliminating stale gradients, synchronous training consistently converged to a better final model.
  2. The Straggler Problem is real: As seen in Figure 2, vanilla Sync-SGD has a noticeably slower step time than Async-SGD.
  3. Backup Workers offer a solution: By launching a few extra workers and only waiting for a quorum (N out of N+k) to report, the impact of stragglers is largely eliminated. This makes Sync-SGD nearly as fast as Async-SGD per step, while retaining its superior convergence properties.

This has led to a general industry trend: most state-of-the-art training systems today favor synchronous training, leveraging highly optimized communication libraries (like NCCL) and system-level tricks (like backup workers) to make it efficient. The stability and predictability are often worth the engineering effort.

Conclusion

In this lesson, we have contrasted the two dominant paradigms for distributed SGD, analyzing their core mechanisms and trade-offs.

Key Takeaways:

  • Synchronous SGD enforces a lock-step update, ensuring all workers apply the same gradients computed on the same model version. This guarantees convergence stability but can suffer from low hardware utilization due to the "straggler problem."
  • Asynchronous SGD maximizes hardware utilization by allowing workers to operate independently without waiting. However, this introduces stale gradients, which can destabilize training and harm final model accuracy.
  • In practice, the superior stability of synchronous training is highly valued. Modern systems often use Sync-SGD and mitigate its performance drawbacks with optimized collective communication algorithms (e.g., Ring-AllReduce) and clever system design (e.g., backup workers).

Preview of the Next Lesson:

We established that synchronous training is equivalent to mini-batch SGD with a very large effective batch size. While this aids convergence stability in one sense, simply increasing the batch size introduces its own set of optimization challenges. In our next lesson, we will analyze the impact of large-batch training on model convergence and explore the necessary adjustments, such as learning rate scaling and the use of adaptive optimizers like LARS and LAMB.

Can't find a good explanation? Sign up and we'll make it for you

Sign up