Bookmarks

DP — data parallelism

A way of parallel processing in which data is divided between devices, while each device works with a full copy of the same model.

Also: data-parallel training, DP

checked 9 Nov

All terms

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

  1. the model is copied in full onto every device — from the GPU of a single machine to cluster nodes;
  2. the dataset is split into mini-batches: with a global batch of 512 across 8 GPUs each copy receives 64 examples;
  3. the forward and backward passes run locally, with no data exchange;
  4. gradients from all copies are averaged by the all-reduce collective operation;
  5. 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.

PropertyDPTPPP
What is splitdata (batches)tensors within a layerlayers into pipeline stages
Model on a devicefull copypart of a layerpart of the layers
Exchange between devicesgradients (all-reduce)activations within a layeractivations between stages
When applicablethe model fits in GPU memorythe model does not fit wholevery deep models

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • TPtensor parallelism

    TP splits the model itself — the tensors within a layer are laid out across GPUs, each computing its own share; in DP the model is kept whole on every GPU.

  • PPpipeline parallelism

    PP cuts the model into sequential stages that pass activations to one another; in DP the stage is the same on all devices.

In depth in the references

where the topic is covered in detail