Distributed Training
Distributed training uses multiple devices or machines to train a model. The goal can be larger model capacity, larger batch size, faster wall-clock time, or memory fit.
For data parallel training with workers, each worker computes a gradient on a local mini-batch:
The synchronized gradient is:
The effective batch size is:
where is the number of gradient accumulation steps.
Parallelism Types
- Data parallelism: replicate the model, shard data, synchronize gradients.
- Tensor or model parallelism: split layers or matrix operations across devices.
- Pipeline parallelism: split model stages and stream micro-batches through them.
- Sharded data parallelism: shard parameters, gradients, and optimizer state.
- Expert parallelism: route tokens or examples to different experts.
Scaling Limit
Training speed is limited by compute, communication, memory, input pipeline, and scheduler overhead:
Adding devices helps only when the added parallelism reduces the dominant term more than it adds communication and coordination overhead.
Checks
- Does single-device training produce a sensible loss curve before scaling out?
- Is reported, including accumulation and world size?
- Are learning rate schedule and warmup adjusted for the effective batch size?
- Are gradient accumulation steps counted consistently across workers?
- Are gradients synchronized at the intended frequency?
- Does checkpoint state include distributed sampler, optimizer shards, and global step?
- Is the bottleneck compute, communication, input pipeline, memory, or scheduler queue time?