Skip to content

Retrofit PyTorch FSDP2 (fully_shard) into training scripts with bottom-up sharding, mixed precision, offload, and DCP checkpointing.

CCM score
57 of 100
skills.sh installs
1.1K
GitHub stars
14.9K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers initialization with torchrun, meta-device model construction, bottom-up fully_shard wrapping, and optimizer creation on DTensor parameters
  • Includes reshard_after_forward tuning, MixedPrecisionPolicy and CPUOffloadPolicy configuration, and gradient clipping for DTensor-based models
  • Enforces model(inputs) calls so FSDP2 hooks run, and prefers Distributed Checkpoint over plain torch.save for sharded state
  • Designed for models that exceed single-GPU memory or need DTensor sharding with DeviceMesh

Install

$ npx -y skills add orchestra-research/ai-research-skills --skill pytorch-fsdp2 -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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 sharding (more inspectable, simpler sharded state dicts) than FSDP1.
  • You may later compose DP with Tensor Parallel using DeviceMesh.

Avoid (or be careful) if:

  • You need strict backwards-compatible checkpoints across PyTorch versions (DCP warns against this).
  • You’re forced onto older PyTorch versions without the FSDP2 stack.

Alternatives (when FSDP2 is not the best fit)

Details

Repository
github.com/orchestra-research/ai-research-skills
Categories
AI Agents & LLM Apps, Data Science & Analytics
First seen
Jun 3, 2026

Questions

What does the pytorch-fsdp2 skill do?

It adds PyTorch FSDP2 (fully_shard) to training scripts, covering correct initialization, sharding, mixed precision and offload configuration, and distributed checkpointing. It is meant for models that exceed single-GPU memory or when you need DTensor-based sharding with DeviceMesh.

How do I install the pytorch-fsdp2 skill?

Run npx -y skills add orchestra-research/ai-research-skills --skill pytorch-fsdp2 -y in your project. Once installed, the agent can apply FSDP2 sharding and checkpointing to your PyTorch training loop.

When should I use FSDP2 instead of DDP or FSDP1?

Use FSDP2 when your model does not fit on one GPU, or when you want DTensor-based per-parameter sharding that is easier to inspect. The skill points to DistributedDataParallel for classic data parallel training and to the original FSDP1 wrapper as alternatives.

Which skills lead the category this skill is in?

This skill sits in the AI Agents & LLM Apps category on Claude Marketplaces, where microsoft-foundry, azure-ai and the google-agents-cli skills are listed as other top skills. Its own focus is PyTorch distributed training memory sharding.

More from orchestra-research/ai-research-skills

All 92

Similar to Pytorch Fsdp2

More AI Agents & LLM Apps