pytorch-fsdp2

pytorch-fsdp2 is a skill for Claude Code from Orchestra-Research/AI-Research-SKILLs. It costs 61 tokens per session (2,675 once invoked), scanned A, original, MIT.

Guidance for using PyTorch FSDP2, a feature that splits a model's parameters, gradients, and optimizer data across GPUs. DTensor is PyTorch's representation for tensors distributed across devices, and DeviceMesh describes how those devices are arranged.

In plain words
What is it for?
Use it when a model cannot fit on one GPU or when you need parameter sharding with PyTorch's newer FSDP2 system. It also covers distributed checkpointing and combining data parallelism with tensor parallelism.
Why use it?
It helps fit models that exceed the memory of one GPU while keeping sharding, mixed precision, offloading, and checkpoints configured correctly. This removes common setup errors in distributed training scripts.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the distributed-training plugin — 6 skills shipped together

Good fit Use it when a model cannot fit on one GPU or when you need parameter sharding with PyTorch's newer FSDP2 system. It also covers distributed checkpointing and combining data parallelism with tensor parallelism.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/orchestra-research/ai-research-skills/pytorch-fsdp2
About the project

AI Research Skills Library is a collection of reusable instructions that guide AI agents through research and machine-learning engineering tasks, from finding ideas and writing papers to training, evaluation, and deployment. It is for configuring agents such as Claude Code, Codex, and Gemini to perform research workflows.

Orchestra-Research/AI-Research-SKILLs · 12,587 stars · on GitHub · orchestra-research.com

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Orchestra-Research/AI-Research-SKILLs --skill pytorch-fsdp2
Clone the repo
git clone --depth 1 https://github.com/Orchestra-Research/AI-Research-SKILLs

Made for: Claude Code.

Or install distributed-training, the plugin that ships this one along with the rest of its 6 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pytorch-fsdp2

README.md
[![agentmods](https://agentmods.dev/badge/skills/orchestra-research/ai-research-skills/pytorch-fsdp2/github.svg)](https://agentmods.dev/skills/orchestra-research/ai-research-skills/pytorch-fsdp2)
Your own site
<a href="https://agentmods.dev/skills/orchestra-research/ai-research-skills/pytorch-fsdp2"><img src="https://agentmods.dev/badge/skills/orchestra-research/ai-research-skills/pytorch-fsdp2/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pytorch-fsdp2

Your own site · 80×15
<a href="https://agentmods.dev/skills/orchestra-research/ai-research-skills/pytorch-fsdp2"><img src="https://agentmods.dev/badge/skills/orchestra-research/ai-research-skills/pytorch-fsdp2.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,675 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 18 Mar 2026
  • Snyk pass 16 Feb 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00061 $0.02675
Opus 5 $0.00030 $0.01337
Sonnet 5 $0.00012 $0.00535
Haiku 4.5 $0.00006 $0.00267

Measured 13d ago against content hash b540043bd17d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

pytorch-fsdp2 scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 13d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

2 near-identical copies found in the catalogue:

08-distributed-training/pytorch-fsdp2/SKILL.md · 232 lines

How it starts

The opening of the file, as written. The whole thing — 232 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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)

  • DistributedDataParallel (DDP): Use the standard data-parallel wrapper when you want classic distributed data parallel training.
  • FullyShardedDataParallel (FSDP1): Use the original FSDP wrapper for parameter sharding across data-parallel workers.

Reference: references/pytorch_ddp_notes.md, references/pytorch_fsdp1_api.md.


Contract the agent must follow

  1. Launch with torchrun and set the CUDA device per process (usually via LOCAL_RANK).
  2. Apply fully_shard() bottom-up, i.e., shard submodules (e.g., Transformer blocks) before the root module.
  3. Call model(input), not model.forward(input), so the FSDP2 hooks run (unless you explicitly unshard() or register the forward method).
  4. Create the optimizer after sharding and make sure it is built on the DTensor parameters (post-fully_shard).
  5. Checkpoint using Distributed Checkpoint (DCP) or the distributed-state-dict helpers, not naïve torch.save(model.state_dict()) unless you deliberately gather to full tensors.

Read the full file on GitHub · 232 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 13d ago First seen · 232 lines · 61 tokens per session scan A b540043bd17d

Subscribe to this mod's changes

pytorch-fsdp2 is a skill published in the GitHub repository Orchestra-Research/AI-Research-SKILLs (12,587 stars, last pushed 2mo ago), licensed MIT. It adds 61 tokens to every session and 2,675 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

pytorch-fsdp2

Adds PyTorch FSDP2 (fullyshard) 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.

OpenLAIR/dr-claw · 61 tokens

pytorch-fsdp2

Adds PyTorch FSDP2 (fullyshard) 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.

liortesta/ClawdAgent · 61 tokens

pytorch-fsdp2

Adds PyTorch FSDP2 (fullyshard) 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.

OpenLAIR/dr-claw-plugin-cc · 61 tokens

pytorch-fsdp2

Adds PyTorch FSDP2 (fullyshard) 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.

ihatesea69/HieuNghi-AI-Skills · 61 tokens

pytorch-fsdp

Expert guidance for Fully Sharded Data Parallel training with PyTorch FSDP - parameter sharding, mixed precision, CPU offloading, FSDP2.

davila7/claude-code-templates · 37 tokens

huggingface-accelerate

Simplest distributed training API. 4 lines to add distributed support to any PyTorch script. Unified API for DeepSpeed/FSDP/Megatron/DDP. Automatic device placement, mixed precision (FP16/BF16/FP8). Interactive config, single launch command. HuggingFace ecosystem standard.

davila7/claude-code-templates · 69 tokens