pytorch-fsdp2

仓库创建 2025年11月3日最近提交 1 个月前SkillHot 收录 22 天前
▸ 精选理由

解决单卡内存瓶颈并支持混合精度与 checkpoint,适合大模型训练工程师。

▸ 风险提示

需要配置分布式环境与权限,调试复杂且依赖特定 PyTorch 版本

这个 Skill 做什么

教你在训练脚本中正确集成 PyTorch FSDP2,实现模型分片、混合精度与分布式检查点。

教你在训练脚本里正确集成 PyTorch 的 FSDP2(fully_shard),包含初始化、模型分片、混合精度/内存 offload 和分布式检查点方案。当模型大到单卡放不下或需要用 DTensor/DeviceMesh 做细粒度分片时用得上,能把显存和通信成本降到可训练范围。特别强调初始化顺序、分片策略和可靠的分布式 checkpoint,避免训练中重启丢状态。

▸ 展开 SKILL.md 英文原文

Adds PyTorch FSDP2 (fully_shard) to training scripts with correct init, sharding, mixed precision/offload config, and distributed checkpointing. Use when models exceed single-GPU memory or when you need DTensor-based sharding with DeviceMesh.

开发编程FSDP2参数分片分布式训练通用
1.1w
Stars
821
Forks
40
仓库内 Skill
+761
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/Orchestra-Research/AI-Research-SKILLs/main/08-distributed-training/pytorch-fsdp2/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/Orchestra-Research/AI-Research-SKILLs/main/08-distributed-training/pytorch-fsdp2/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# Skill: Use PyTorch FSDP2 (`fully_shard`) correctly in a training script

This skill teaches a coding agent how to **add PyTorch FSDP2** to a training loop with correct initialization, sharding, mixed precision/offload configuration, and checkpointing.

> FSDP2 in PyTorch is exposed primarily via `torch.distributed.fsdp.fully_shard` and the `FSDPModule` methods it adds in-place to modules. See: `references/pytorch_fully_shard_api.md`, `references/pytorch_fsdp2_tutorial.md`.

---

## When to use this skill

Use FSDP2 when:
- Your model **doesn’t fit** on one GPU (parameters + gradients + optimizer state).
- You want an eager-mode sharding approach that is **DTensor-based per-parameter shardi
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有