Skip to main content
QUICK REVIEW

[论文解读] PyTorch FSDP: Experiences on Scaling Fully Sharded Data Parallel

Yanli Zhao, Andrew Gu|arXiv (Cornell University)|Apr 21, 2023
Advanced Neural Network ApplicationsComputer Science被引用 12
一句话总结

本文介绍 PyTorch Fully Sharded Data Parallel (FSDP),这是一个原生的、行业级的解决方案,通过参数切分来训练大模型,具备延迟初始化、可配置的切分以及广泛的优化,在小模型上与 DDP 的性能相当,在更大模型上实现近线性 TFLOPS 的扩展性(测试范围达 512x80GB A100 GPU)。

ABSTRACT

It is widely acknowledged that large models have the potential to deliver superior performance across a broad range of domains. Despite the remarkable progress made in the field of machine learning systems research, which has enabled the development and exploration of large models, such abilities remain confined to a small group of advanced users and industry leaders, resulting in an implicit technical barrier for the wider community to access and leverage these technologies. In this paper, we introduce PyTorch Fully Sharded Data Parallel (FSDP) as an industry-grade solution for large model training. FSDP has been closely co-designed with several key PyTorch core components including Tensor implementation, dispatcher system, and CUDA memory caching allocator, to provide non-intrusive user experiences and high training efficiency. Additionally, FSDP natively incorporates a range of techniques and settings to optimize resource utilization across a variety of hardware configurations. The experimental results demonstrate that FSDP is capable of achieving comparable performance to Distributed Data Parallel while providing support for significantly larger models with near-linear scalability in terms of TFLOPS.

研究动机与目标

  • 推动需要一个行业级、框架原生的解决方案来训练超出单个 GPU 内存的极大模型。
  • 介绍 PyTorch FSDP 及其与 PyTorch 核心组件的协同设计,以提供非侵入式、高效的训练。
  • 开发和评估切分策略、初始化方法,以及内存/通信优化,以应对硬件异构性和大内存占用。
  • 展示 FSDP 在大规模 GPU 集群上对语言模型与推荐系统模型的有效性和可扩展性。

提出的方法

  • 将模型分解为 FSDP 单元并对参数进行切分,使每次仅有一个单元被完全实现。
  • 实现延迟初始化,使模型在伪设备上构建,在在真实 GPU 上实现实体化时回放初始化。
  • 提供多种切分策略(全切分与混合)并引入切分因子 F,以权衡内存占用与通信。
  • 使用 FlatParameter 将参数合并以实现高效的 AllGather/ReduceScatter,避免额外拷贝。
  • 通过视图和梯度钩子与 PyTorch autograd 紧密集成,以实现正确、自动的梯度流与降维。
  • 应用通信优化(重叠、前向/后向预取、梯度累积)和内存管理(CUDA 缓存分配器、速率限制器)。

实验结果

研究问题

  • RQ1如何设计一个原生 PyTorch 解决方案,以在异构硬件上最小化内存消耗并最大化吞吐量?
  • RQ2FSDP 是否能在小模型上达到与 DDP 相当的性能,并在更大模型上提供近乎线性的 TFLOPS 可扩展性?
  • RQ3需要哪些初始化、切分和内存管理技术来支持超过单个 GPU 内存的模型训练?
  • RQ4在全切分设置中,应该如何组织通信以最大化与计算的重叠?
  • RQ5在实际数据中心拓扑中,全切分与混合切分的取舍是什么?

主要发现

  • FSDP 可以在小型模型上匹配 DDP 的性能,同时实现显著更大模型的近线性 TFLOPS 可扩展性。
  • 基于 FlatParameter 的切分方法实现了参数级别的内存效率,在聚集/分散操作期间拷贝开销最小。
  • 延迟初始化和逐单元实体化允许构建极大模型,而无需事先分配全部内存。
  • 混合切分降低跨主机的流量,并可利用数据中心局部性,为中等规模模型提供可调的内存-吞吐权衡。
  • FSDP 在 PyTorch 2.0 中处于 beta,并在行业和研究场景中经过实战测试,相关产物可用于重复使用。
  • 实验显示在大规模 GPU 集群上具备可扩展性,测试范围达到 512 x 80GB A100 GPU。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。