In neural network training DP is the basic way to put several GPUs to work: the model is copied in full onto every device, the dataset is split into parts, and each copy computes gradients over its own share. The gradients are then averaged, and all copies of the weights match again.
How one step works
- the model is copied in full onto every device — from the GPU of a single machine to cluster nodes;
- the dataset is split into mini-batches: with a global batch of 512 across 8 GPUs each copy receives 64 examples;
- the forward and backward passes run locally, with no data exchange;
- gradients from all copies are averaged by the all-reduce collective operation;
- the optimiser takes a step, and all copies of the weights match again.
Throughput grows with the number of devices until exchanging gradients becomes the bottleneck. Averaging is the main part of the exchange: a collective communication library (for example NCCL) performs it over a fast network, usually InfiniBand or RoCE. In PyTorch this mode is implemented by DistributedDataParallel: it synchronises gradients between the copies of the model, and DistributedSampler helps split the data into portions.
DP, TP and PP
DP splits the data and keeps a full copy of the model on every device, so it only works when the model fits in the memory of a single GPU. Large models do not fit and are split into parts — these methods are combined with DP.
| Property | DP | TP | PP |
|---|---|---|---|
| What is split | data (batches) | tensors within a layer | layers into pipeline stages |
| Model on a device | full copy | part of a layer | part of the layers |
| Exchange between devices | gradients (all-reduce) | activations within a layer | activations between stages |
| When applicable | the model fits in GPU memory | the model does not fit whole | very deep models |
Sources
the term is written from these pagesVerified 9 Nov