← Tiled Thoughts

How GPUs Talk: A Practical Guide to Multi-GPU Training and Communication

Contents
  1. 1. Why Multi-GPU Training is a communication problem
  2. 2. How GPUs are wired: intra-node and inter-node
  3. 3. Core communication patterns
  4. 4. Multi-GPU training strategies
  5. 4.1 Distributed Data Parallel (DDP)
  6. 4.2 Fully Sharded Data Parallel (FSDP)
  7. 4.3 Tensor Parallelism
  8. 4.4 Pipeline Parallelism
  9. 5. Topology-aware communication: rings, trees, and NVLink
  10. 6. Hiding communication latency
  11. 7. Conclusion

An in-depth exploration of multi-GPU training techniques and the communication patterns that enable efficient distributed machine learning.

When people talk about scaling deep learning, they usually mean throwing more GPUs at the problem. However, horizontal scaling can only get you so far without efficient communication strategies.

Concretely, “using 8 GPUs instead of 1” will only help if GPUs can talk to each other fast enough. Under the hood, multi-GPU training is less about computation and more about communication.

In this post, I want to walk through how GPUs communicate during training:

The goal is to provide a mental model that explains why your training job suddenly becomes network-bound instead of compute-bound as you scale up.


1. Why Multi-GPU Training is a communication problem

On a single GPU, training looks simple:

  1. Load a batch of data
  2. Forward pass through the model
  3. Compute loss
  4. Backward pass to compute gradients
  5. Update model parameters
  6. Repeat

Scaling to multiple GPUs sounds equally simple:

That “averaging gradients across GPUs” step is where things get tricky.

At a small scale, communication overhead is negligible compared to computation; say, when you are doing a Matrix Multiply. At larger scales (32+ GPUs, or multi-node where GPUs are connected over a network), gradient sync and parameter updates can dominate the training time. Modern accelerators have extremely high compute throughput, which moves the bottleneck to:

To understand the trade-offs, we have to start from the hardware.


2. How GPUs are wired: intra-node and inter-node

Inside a single server (node), GPUs are connected via high-speed links:

Across multiple servers (nodes), GPUs communicate over a network:

The important bit: topology matters.

Libraries like NCCL (NVIDIA Collective Communications Library) probe this topology and build communication patterns (rings, trees) that optimize data transfer.


3. Core communication patterns

Most multi-GPU training strategies rely on a few core communication patterns, often called collectives:

Data-parallel training primarily uses all-reduce to average gradients.

For an N-GPU ring, all-reduce can be implemented in two phases:

  1. Reduce-scatter: Each GPU sends and receives chunks of data, reducing them as they go.
  2. All-gather: Each GPU gathers the reduced chunks to form the final result.

This ring algorithm is bandwidth-optimal as most GPUs are sending and receiving data simultaneously.


4. Multi-GPU training strategies

4.1 Distributed Data Parallel (DDP)

In classic Distributed Data Parallel (DDP):

4.2 Fully Sharded Data Parallel (FSDP)

As model get larger, storing full copies on each GPU becomes infeasible. Fully Sharded Data Parallel (FSDP) addresses this by:

Roughy, for each FSDP-wrapped layer:

  1. Before the forward pass,
    • GPUs run an all-gather to get the full parameters needed for that layer.
  2. Forward pass is computed.
  3. After the backward pass,
    • Gradients are reduced-scattered back to the GPUs holding the parameter shards.
  4. Finally, each GPU updates its local parameter shards.

The key difference is that FSDP repeatedly gathers and scatters parameters and gradients, rather than keeping full copies.

4.3 Tensor Parallelism

Data-parallel methods replicate the model and shard the data. Tensor Parallelism shards the model itself across GPUs:

For a big linear layer, i.e. Y = X @ W:

In practice, tensor parallelism is often combined with data parallelism to balance memory and computation. For example, in a multi-node setup, each node can run data parallelism, while within each node, tensor parallelism shards the model across GPUs. This is reasonable considering the high intra-node bandwidth (NVLink) compared to inter-node bandwidth (InfiniBand).

4.4 Pipeline Parallelism

There is a generic type of tensor parallelism called Model Parallelism, where different layers of the model are placed on different GPUs. For example, we have 4 GPUs and a model with 32 layers:

This is suboptimal because GPUs sit idle waiting for data from the previous GPU.

However, we can pipeline the execution:

  1. Split the input batch into micro-batches.
  2. While GPU 0 is processing micro-batch 2, GPU 1 can process micro-batch 1, and GPU 2 can process micro-batch 0.

For the same 4-GPU, 32-layer model, take the global batch and split it into 4 micro-batches:

Time Step GPU 0 GPU 1 GPU 2 GPU 3
1 MB 0: L1-8
2 MB 1: L1-8 MB 0: L9-16
3 MB 2: L1-8 MB 1: L9-16 MB 0: L17-24
4 MB 3: L1-8 MB 2: L9-16 MB 1: L17-24 MB 0: L25-32

Communication happens between GPUs to pass activations forward and gradients backward. The key is to keep all GPUs busy by overlapping computation and communication.


On a real box setup, not all GPUs are equally connected:

NCCL and similar libraries:

For example:

We prefer ring-based all-reduce for large tensors because it fully utilizes the available bandwidth. For small tensors, tree-based approaches can be faster due to lower latency. For a tree-based algorithm, we are bound by the depth of the tree (log N) rather than the number of GPUs (N).


6. Hiding communication latency

To maximize GPU utilization, we want to hide communication latency behind computation. Some strategies include:


7. Conclusion

When looking from afar, multi-GPU training is about two operations: compute and communicate. As models and datasets grow, communication increasingly becomes the bottleneck. Understanding the hardware topology, core communication patterns, and training strategies is crucial to designing efficient distributed training systems.

Starting to treat communication as a first-class citizen in your training architecture will pay dividends as you scale to larger models and datasets.