Skip to content

Data Parallelism

Definition

Data Parallelism — a method to accelerate training by replicating the same model on N devices, each processing its own shard of the batch, after which gradients are averaged and applied to all replicas.

Mechanism

flowchart LR
    D[Batch] --> S1[GPU 0: shard 1]
    D --> S2[GPU 1: shard 2]
    D --> S3[GPU 2: shard 3]
    S1 --> A[All-Reduce gradients]
    S2 --> A
    S3 --> A
    A --> U[Weights update]

Variants

  • DP (DataParallel) — an outdated approach in PyTorch with a single master process.
  • DDP (DistributedDataParallel) — one process per device, efficient all-reduce.
  • ZeRO / FSDP — sharding optimizer states, gradients, and parameters for memory savings.

Limitations

  • Efficiency drops with the increase in the number of devices due to communication overhead.
  • Does not help if the model does not fit on a single device — requires Model Parallelism.
  • Global Batch Size increases linearly, necessitating adjustments to Learning Rate.

See also