Allreduce is a collective operation in which every process contributes data, the processes combine it with a reduction such as sum or max, and every process receives the result. For example, ranks holding t0, t1, t2, and t3 all receive their combined sum. section 16.2
In distributed training, use allreduce after backpropagation and before the optimizer step to aggregate or average gradients across devices. Synchronized gradients let each replica update consistently instead of drifting into separate models. section 16.3
Summing values across ranks
With PyTorch, each rank can create tensor = torch.tensor([float(rank)]) and call dist.all_reduce(tensor, op=dist.ReduceOp.SUM). Every process then holds the sum; with ranks contributing 0, 1, and 2, the shared result is 3.0. Process output order may vary because multiprocessing is nondeterministic. section 16.2
Figure 16.3 Illustration of the broadcast (left) and allreduce (right) collective communication operations
Visualizes how allreduce combines each rank’s tensor and distributes the result back to every rank. section 16.2



