PyTorch Distributed: Experiences on Accelerating Data Parallel Training
Shen Li††{}^{\textbf{\textdagger}} Yanli Zhao††{}^{\textbf{\textdagger}} Rohan Varma††{}^{\textbf{\textdagger}} Omkar Salpekar††{}^{\textbf{\textdagger}} Pieter Noordhuis Teng Li††{}^{\textbf{\textdagger}} Adam Paszke‡‡{}^{\textbf{\textdaggerdbl}} Jeff Smith††{}^{\textbf{\textdagger}} Brian Vaughan††{}^{\textbf{\textdagger}} Pritam Damania††{}^{\textbf{\textdagger}} Soumith Chintala††{}^{\textbf{\textdagger}} {shenli This work was conducted when Pieter Noordhuis was an employee at Facebook. yanlizhao rvarm1 {jeffksmith bvaughan pritam.damania ††{}^{\textbf{\textdagger}}Facebook AI ‡‡{}^{\textbf{\textdaggerdbl}}University of Warsaw
Abstract
This paper presents the design, implementation, and evaluation of the PyTorch distributed data parallel module. PyTorch is a widely-adopted scientific computing package used in deep learning research and applications. Recent advances in deep learning argue for the value of large datasets and large models, which necessitates the ability to scale out model training to more computational resources. Data parallelism has emerged as a popular solution for distributed training thanks to its straightforward principle and broad applicability. In general, the technique of distributed data parallelism replicates the model on every computational resource to generate gradients independently and then communicates those gradients at each iteration to keep model replicas consistent. Despite the conceptual simplicity of the technique, the subtle dependencies between computation and communication make it non-trivial to optimize the distributed training efficiency. As of v1.5, PyTorch natively provides several techniques to accelerate distributed data parallel, including bucketing gradients, overlapping computation with communication, and skipping gradient synchronization. Evaluations show that, when
中文速览
深度学习模型越训越大、数据越来越多,单张GPU早已不够用,PyTorch因此需要一套高效的分布式数据并行(Distributed Data Parallel,DDP)方案。PyTorch团队将DDP封装成一个标准的nn.Module,让开发者只需改动一行代码就能把单机训练扩展到多机多卡,同时在底层采用了三项关键优化:把梯度打包成桶(bucket)批量通信、让AllReduce通信与反向传播计算流水线重叠、以及在梯度累积时跳过不必要的同步。在32到256块GPU的实验中,这套方案达到了接近线性的加速比,合理设置桶大小可带来超过2倍的额外提速,跳过同步则能大幅摊薄通信开销而几乎不损失收敛质量。这项工作不仅揭示了一套被工业界大规模采用的分布式训练系统的内部机制——仅Facebook内部就有超过60%的生产GPU时长跑在这套方案上——也为后续优化分布式训练提供了可复现的基准和经验总结。
原文 arXiv:2006.15704;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2006.15704v1