Distributed Model Training Explained: How Teams Train Models Too Big for One GPU

Distributed Model Training Explained: How Teams Train Models Too Big for One GPU

Distributed model training explained: the practice of training a single model across many GPUs, often spread across many machines, because the model is too large or the dataset too big for one device. The central question is how the work gets divided without the coordination cost eating the benefit, and the answer is that teams split the work along three dimensions, data, model and pipeline, and combine them so that each GPU does useful work while the communication between them stays manageable.

Distributed training is what makes modern large models possible. A model with hundreds of billions of parameters cannot fit on one GPU, and the dataset it needs would take years to process on a single machine.

Key takeaways

  • Distributed model training splits a training job across many GPUs so models too large for one device can be trained.
  • Data parallelism splits the batch; tensor parallelism splits the model layers; pipeline parallelism splits the model depth.
  • Most large training runs combine all three into a three-dimensional hybrid.
  • ZeRO removes the memory redundancy of data parallelism by partitioning optimiser state, gradients and parameters.
  • Communication and failure handling, not raw compute, are usually what limit a distributed run.

Why one GPU is not enough

Two limits force training onto many GPUs. The first is memory. Training a model needs far more memory than the weights alone, because the optimiser stores extra state for every parameter and the gradients need space too. With the Adam optimiser, a model can need roughly sixteen times its parameter count in bytes during training, so a 7-billion-parameter model can need over 100 GB.

The second limit is time. Even if a model fits on one GPU, processing trillions of tokens on a single device would take years. Best for: any model that does not fit on one GPU, or any dataset that would take too long to process on one machine.

Data parallelism: split the batch

Data parallelism is the simplest form of distributed training. Every GPU holds a complete copy of the model, and each one processes a different slice of the batch. After the backward pass, the GPUs exchange their gradients and average them, so every copy of the model gets the same update.

The strength of data parallelism is its simplicity. It needs no changes to the model code, and it scales well as long as the model fits on a single GPU. Its weakness is memory: every GPU holds a full copy of the model, the gradients and the optimiser state, so the redundancy grows with the number of devices. It also needs a fast network, because the gradient exchange happens every step.

Data parallelism is the starting point for almost every distributed setup, and it is often the only form needed for fine-tuning, where the model fits on one GPU. Our guide to tensor parallelism in LLMs covers what happens when the model no longer fits. Best for: models that fit on a single GPU, and teams that want the simplest distributed setup.

Tensor parallelism: split the layers

Tensor parallelism splits individual layers of the model across GPUs. A matrix multiplication, the core operation of a transformer layer, can be divided so that each GPU computes part of the result, and the parts are combined at the end of the layer. This lets a model that is too large for one GPU run across several, with each device holding only a slice of the weights.

The price is communication. Tensor parallelism needs GPUs to exchange partial results inside every layer, on both the forward and the backward pass, so it demands a very fast interconnect between the devices. In practice it is used within a single machine, where GPUs are connected by high-bandwidth links, and not across machines, where the network is slower.

Tensor parallelism is the right tool when a single layer is too large for one GPU. Best for: very large models where individual layers exceed one GPU’s memory, used inside a single high-bandwidth machine.

Pipeline parallelism: split the depth

Pipeline parallelism splits the model by depth, assigning different layers to different GPUs. The first GPU processes the early layers, passes its activations to the next GPU, which processes the next layers, and so on down the chain. While one micro-batch moves through the pipeline, the next one can enter behind it.

The weakness of pipeline parallelism is the bubble: the idle time at the start and end of each step, when some GPUs are waiting for work to arrive or for the last micro-batch to finish. The bubble wastes a fraction of the available compute, and it grows with the number of pipeline stages. Splitting the batch into many micro-batches reduces the bubble, but does not remove it.

Pipeline parallelism needs less communication than tensor parallelism, because GPUs only exchange activations at the boundaries between stages, so it works across machines. It is the natural complement to tensor parallelism: tensor parallelism splits within a machine, pipeline parallelism splits across machines. Our guide to pipeline parallelism for LLMs explains the scheduling in more detail. Best for: very deep models, where the layers can be spread across many machines.

A server room with rows of GPU racks and glowing network cabling in a data centre
Large training runs combine data, tensor and pipeline parallelism so each GPU does useful work while communication stays manageable.

ZeRO: removing the memory redundancy

ZeRO, the Zero Redundancy Optimizer, was introduced by Rajbhandari and colleagues at Microsoft in 2020 and is implemented in the DeepSpeed library. It addresses the main weakness of data parallelism: every GPU holds a full copy of the model state. ZeRO partitions that state across the data-parallel GPUs instead of replicating it, so the memory per GPU falls as more devices are added.

ZeRO works in three stages. Stage one partitions the optimiser state, which alone cuts memory roughly fourfold. Stage two adds gradient partitioning, cutting it roughly eightfold. Stage three partitions the parameters themselves, so memory per GPU falls in proportion to the number of devices. With stage three, a model of almost any size can be trained as long as the combined memory of the cluster is large enough.

The trade-off is extra communication, because a GPU must fetch the parameters it does not hold before each forward pass. In practice the cost is modest compared with the memory saved. Best for: large-model training where data parallelism alone runs out of memory, and teams that want to avoid the complexity of model parallelism where possible.

Comparing distributed training strategies

Strategy What it splits Main strength Main weakness
Data parallelism The batch Simple, scales well Full model copy on every GPU
Tensor parallelism Individual layers Handles layers too big for one GPU Needs very fast interconnect
Pipeline parallelism The model’s depth Works across machines Idle bubble wastes compute
ZeRO Optimiser state, gradients, parameters Removes memory redundancy Extra parameter-fetch communication
Hybrid (3D) parallelism Batch, layers and depth together Scales to the largest models Complex to configure and debug
Federated learning Data across separate owners Data never leaves its owner Slow, unreliable links, uneven data

Best for: most large training runs, a hybrid of data, tensor and pipeline parallelism, with ZeRO handling the memory. Data parallelism alone suits fine-tuning; federated learning suits training on data that cannot be centralised.

Communication: the real bottleneck

In distributed training, the GPUs are rarely the bottleneck. Communication is. Every step requires GPUs to exchange gradients, activations or parameters, and the time spent moving data can exceed the time spent computing. The interconnect matters more than the GPU model: a cluster with fast links between GPUs trains faster than a cluster with faster GPUs and a slow network.

Two techniques reduce the communication burden. Gradient compression sends less data by quantising or sparsifying the gradients, at a small cost to accuracy. Overlapping communication with computation hides the transfer time by starting the exchange of one layer’s gradients while the next layer is still computing.

Measure the communication share of each step. If it is under a quarter of the step time, the setup is healthy. If it is over half, the cluster is spending more time talking than training. Best for: any team scaling beyond a handful of GPUs. Measure communication early, before it becomes the bottleneck.

Failures: planning for the inevitable

At the scale of hundreds of GPUs, failures are not rare events; they are routine. A GPU overheats, a network link drops, a node crashes, and the whole job stops. The mean time between failures for a large cluster is measured in hours, not weeks, so a training run that lasts a month will fail many times.

The defence is checkpointing: saving the model state regularly so the job can resume from the last good point instead of starting over. Checkpoints should be frequent enough that a failure costs minutes rather than hours. Automated restart, where the job detects the failure, replaces the broken node and resumes from the checkpoint, turns a multi-hour outage into a short pause.

Monitoring matters as much as checkpointing. Track the loss curve, the gradient norms and the hardware utilisation, and alert on anything that deviates from the expected pattern. Our guide to GPU cluster architecture covers the hardware and networking choices that make large runs reliable. Best for: every distributed run. Assume failures, checkpoint often, and automate the restart.

A distributed training checklist

  • Confirm the model does not fit on one GPU, or the dataset is too large for one machine, before distributing.
  • Choose the parallelism strategy: data parallelism first, then add tensor and pipeline parallelism as the model grows.
  • Enable ZeRO to remove memory redundancy before adding model parallelism.
  • Check the interconnect: fast links within a machine for tensor parallelism, reliable links across machines for the rest.
  • Estimate the communication share of each step and keep it under a quarter of the step time.
  • Set the global batch size deliberately, and scale the learning rate to match it.
  • Checkpoint frequently, store checkpoints off the training nodes, and test the restore process.
  • Automate restart so a node failure pauses the run rather than ending it.
  • Monitor loss, gradient norms and GPU utilisation, and alert on deviations.
  • Run a small-scale pilot on a few GPUs before committing the full cluster.

Frequently asked questions

How many GPUs do I need for distributed training?

It depends on the model and the dataset. Fine-tuning a 7-billion-parameter model can work on a handful of GPUs, while pre-training a model with hundreds of billions of parameters needs hundreds or thousands. Start from the memory requirement, then add GPUs until the training time fits your schedule.

Is distributed training faster than single-GPU training?

Yes, up to a point. Adding GPUs reduces the time per step, but the benefit shrinks as communication grows, and beyond a certain scale the extra GPUs add more coordination cost than compute. The scaling efficiency of a run is the fraction of the ideal speedup actually achieved, and good setups reach 70 to 90 per cent.

What is the difference between data and model parallelism?

Data parallelism splits the batch across GPUs, with each GPU holding a full copy of the model. Model parallelism splits the model itself across GPUs, so each device holds only part of the weights. Data parallelism is simpler and is used first; model parallelism is needed when the model does not fit on one GPU.

What is ZeRO?

ZeRO, the Zero Redundancy Optimizer, is a memory optimisation introduced by Microsoft researchers in 2020 and implemented in DeepSpeed. It partitions the optimiser state, gradients and parameters across data-parallel GPUs instead of replicating them, so the memory per GPU falls as more devices are added.

Why do distributed training runs fail so often?

Because a run with hundreds of GPUs has hundreds of points of failure, and the mean time between failures for a large cluster is measured in hours. Frequent checkpointing, automated restart and good monitoring turn failures from disasters into short pauses.

Latest articles

Scroll to Top