Data Parallelism
Volume IV, Chapter 19 — Part I. Distributed training via data parallelism: gradient aggregation, AllReduce, synchronous SGD theory, communication complexity, and scaling efficiency analysis.
Prerequisites
Table of Contents
- Learning Objectives
- Prerequisites
- Notation
- Core Intuition
- Single-Device Training Recap
- Data Parallelism Formulation
- Gradient Aggregation and AllReduce
- Synchronous Distributed SGD
- Communication Complexity
- Scaling Efficiency and Amdahl's Law
- Effective Batch Size and Learning Rate
- Worked Examples
- Connection to the Broader Curriculum
- Common Pitfalls and Misconceptions
- Research Perspective
- Summary of Takeaways
- Exercises
Learning Objectives
After reading this chapter, you should be able to:
- Define data parallelism: replicate model, partition data across devices.
- Derive synchronous gradient averaging: .
- Explain AllReduce as the communication primitive for gradient aggregation.
- Analyze communication volume vs. ring AllReduce .
- Apply Amdahl's law to parallel training efficiency.
- Relate effective batch size to learning rate scaling rules.
Prerequisites
- Gradient Descent — SGD update
- Backpropagation — gradient computation
Notation
- — Number of parallel workers (GPUs)
- — Mini-batch on worker
- — Local gradient on worker
- — Averaged global gradient
- — Shared model parameters
Core Intuition
Training large models requires multiple GPUs. Data parallelism is the simplest strategy: replicate the full model on each device, split the mini-batch across devices, compute local gradients, average gradients, and apply synchronized update.
This is equivalent to Gradient Descent on a larger effective batch — but requires communication (AllReduce) that can become the bottleneck at scale.
Series context. Volume IV, Chapter 19 (Parallelism). Orthogonal to Flash Attention (memory) and Quantization (precision).
Interactive: Distributed Training Parallelism
Each GPU gets a copy of the full model, different data batch
GPU 0
↕ AllReduce gradients
GPU 1
↕ AllReduce gradients
GPU 2
↕ AllReduce gradients
GPU 3
↕ AllReduce gradients
Single-Device Training Recap
Definition 1 (SGD Update).
Each step: forward + backward on batch , then update.
Data Parallelism Formulation
Definition 2 (Data Parallel Setup). devices, each holds copy of . Mini-batch split into with .
Algorithm:
- Each device computes local gradient
- AllReduce: compute average
- Each device updates:
Theorem 1 (Equivalence). Synchronized data parallel SGD with averaged gradients is equivalent to SGD on full batch (assuming deterministic ops).
Proof. .
Gradient Aggregation and AllReduce
Definition 3 (AllReduce). Collective operation: each of processes holds vector ; after AllReduce, all processes hold (or average).
Definition 4 (Ring AllReduce). Arrange GPUs in ring; pass gradient chunks in steps. Bandwidth-optimal: each GPU sends/receives × gradient size total.
Proposition 1. Naive AllReduce: data transferred. Ring AllReduce: per device regardless of (bandwidth-limited).
Synchronous Distributed SGD
Definition 5 (Synchronous Training). All devices wait for slowest before update — straggler problem.
Definition 6 (Asynchronous Training). Devices update independently with stale gradients — convergence complications.
Production LLM training uses synchronous data parallelism with gradient accumulation for large effective batches (Scaling Laws).
Communication Complexity
Definition 7 (Communication Time).
for ring AllReduce (factor 2 for send + receive).
Definition 8 (Compute Time).
Proposition 2. Training is communication-bound when — common for small models on fast GPUs or large .
Scaling Efficiency and Amdahl's Law
Definition 9 (Strong Scaling Efficiency).
where is time with devices.
Theorem 2 (Amdahl's Law). If fraction of work is parallelizable:
Sequential overhead (communication, I/O) limits speedup.
Proposition 3. For LLM training with large batches, and achievable up to hundreds of GPUs with optimized AllReduce.
Effective Batch Size and Learning Rate
Definition 10 (Effective Batch Size). .
Proposition 4 (Linear Scaling Rule). When increasing by factor , scale learning rate (up to stability limit) — preserves SGD dynamics approximately.
Proposition 5 (Square Root Scaling). Alternative: — more conservative, better for large .
See Gradient Descent and Scaling Laws.
Worked Examples
Example 1: AllReduce Volume
, FP32, : gradient size 28 GB; ring AllReduce 56 GB total transferred across network.
Example 2: Effective Batch
, local batch 2, accumulation 4: .
Connection to the Broader Curriculum
- Gradient Descent — base algorithm
- Scaling Laws — compute-optimal batch sizes
- Backpropagation — local gradient computation
- Quantization — quantized AllReduce
Common Pitfalls and Misconceptions
Pitfall 1: Assuming linear speedup to arbitrary .
Pitfall 2: Ignoring straggler effects in synchronous training.
Pitfall 3: Not scaling learning rate with batch size.
Pitfall 4: Confusing data parallelism with model/tensor parallelism.
Research Perspective
Distributed data parallelism underpins virtually all large-scale neural network training. Ring AllReduce (Baidu, 2017) established bandwidth-optimal gradient aggregation. Horovod (Sergeev & Balso, 2018) standardized collective communication across heterogeneous clusters. Megatron-LM and subsequent systems combine data parallelism with tensor and pipeline parallelism for models that exceed single-device memory. ZeRO (Rajbhandari et al., 2020) shards optimizer states across devices, reducing per-GPU memory while preserving the data-parallel abstraction. Gradient compression and error-feedback methods remain active research directions for bandwidth-constrained environments.
Summary of Takeaways
- Data parallel — Replicate model, split batch
- Gradient — Average via AllReduce
- Ring AllReduce — bandwidth
- Efficiency — Amdahl limits speedup
- Batch scaling — Effective batch
Exercises
Exercise 1. Prove Theorem 1.
Exercise 2. Derive ring AllReduce communication volume.
Exercise 3. Compute vs for given config.
Exercise 4. Amdahl: if 5% sequential, max speedup at ?
Exercise 5. Linear vs. sqrt learning rate scaling.
Exercise 6. Compare data vs. model parallelism for 70B model.
Exercise 7. Gradient accumulation equivalence.
Exercise 8. Connect to Scaling Laws compute budget.