PyTorch 入门指南
学习 PyTorch
图像和视频
音频
后端
强化学习
在生产环境中部署 PyTorch 模型
Profiling PyTorch
代码变换与FX
前端API
扩展 PyTorch
模型优化
并行和分布式训练
边缘端的 ExecuTorch
推荐系统
多模态

分布式与并行训练教程

分布式训练是一种模型训练范式,它通过将训练工作负载分散到多个工作节点上,从而显著提高训练速度和模型精度。虽然分布式训练可以用于任何类型的机器学习模型训练,但对于大规模模型和计算密集型任务(如深度学习),使用分布式训练最为有益。

在 PyTorch 中,有几种方法可以执行分布式训练,每种方法在某些特定用例中都有其优势:

了解更多关于这些选项的信息,请参阅分布式概述

学习 DDP

DDP 入门视频教程

关于如何使用 DistributedDataParallel 入门并进阶到更复杂主题的逐步视频系列

代码视频

https://pytorch.org/tutorials/beginner/ddp_series_intro.html?utm_source=distr_landing&utm_medium=ddp_series_intro

分布式数据并行入门

本教程简要而温和地介绍了 PyTorch 的 DistributedData Parallel。

代码

https://pytorch.org/tutorials/intermediate/ddp_tutorial.html?utm_source=distr_landing&utm_medium=intermediate_ddp_tutorial

使用 Join Context Manager 进行不均匀输入的分布式训练

本教程介绍了 Join 上下文管理器,并演示了其与 DistributedData Parallel 结合使用的场景。

代码

https://pytorch.org/tutorials/advanced/generic_join.html?utm_source=distr_landing&utm_medium=generic_join

学习 FSDP

FSDP 入门指南

本教程演示了如何在 MNIST 数据集上使用 FSDP 进行分布式训练。

代码

https://pytorch.org/tutorials/intermediate/FSDP_tutorial.html?utm_source=distr_landing&utm_medium=FSDP_getting_started

FSDP 高级指南

在本教程中,您将学习如何使用FSDP微调HuggingFace (HF) T5模型以进行文本摘要。

代码

https://pytorch.org/tutorials/intermediate/FSDP_advanced_tutorial.html?utm_source=distr_landing&utm_medium=FSDP_advanced

学习张量并行 (TP)

大规模 Transformer 模型的 Tensor Parallel (TP) 训练

本教程演示了如何使用 Tensor Parallel 和 Fully Sharded Data Parallel 在数百到数千个 GPU 上训练一个类似 Transformer 的大型模型。

代码

https://pytorch.org/tutorials/intermediate/TP_tutorial.html

学习 DeviceMesh

设备网格入门指南

在本教程中,您将了解 DeviceMesh 以及它如何帮助分布式训练。

代码

https://pytorch.org/tutorials/recipes/distributed_device_mesh.html?highlight=devicemesh

学习 RPC

分布式 RPC 框架入门指南

本教程演示了如何开始使用基于 RPC 的分布式训练。

代码

https://pytorch.org/tutorials/intermediate/rpc_tutorial.html?utm_source=distr_landing&utm_medium=rpc_getting_started

使用分布式 RPC 框架实现参数服务器

本教程将引导您通过一个简单的示例,使用 PyTorch 的分布式 RPC 框架实现一个参数服务器。

代码

https://pytorch.org/tutorials/intermediate/rpc_param_server_tutorial.html?utm_source=distr_landing&utm_medium=rpc_param_server_tutorial

使用异步执行实现批量 RPC 处理

在本教程中,您将使用 @rpc.functions.async_execution 装饰器构建批处理 RPC 应用程序。

代码

https://pytorch.org/tutorials/intermediate/rpc_async_execution.html?utm_source=distr_landing&utm_medium=rpc_async_execution

结合 Distributed DataParallel 与分布式 RPC 框架

在本教程中,您将学习如何将分布式数据并行与分布式模型并行相结合。

代码

https://pytorch.org/tutorials/advanced/rpc_ddp_tutorial.html?utm_source=distr_landing&utm_medium=rpc_plus_ddp

自定义扩展

使用 Cpp 扩展自定义 Process Group 后端

在本教程中,您将学习如何实现一个自定义的 ProcessGroup 后端,并通过 C++ 扩展将其集成到 PyTorch 分布式包中。

代码

https://pytorch.org/tutorials/intermediate/process_group_cpp_extension_tutorial.html?utm_source=distr_landing&utm_medium=custom_extensions_cpp

本页目录