pytorch-fsdp2

pytorch-fsdp2 is a skill for Claude Code from liortesta/ClawdAgent. It costs 61 tokens per session (2,675 once invoked), scanned A, a copy of pytorch-fsdp2, Apache-2.0.

A PyTorch feature that splits a model's parameters, gradients, and optimizer data across GPUs. FSDP2 also provides settings for mixed precision, CPU offloading, and distributed checkpoints.

In plain words
What is it for?
Use it to adapt a PyTorch training script for multi-GPU training, shard large models, combine data and tensor parallelism, and save distributed checkpoints.
Why use it?
A model may not fit in the memory of one GPU even when several GPUs are available. Sharding spreads its memory use across those GPUs during training.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Good fit Use it to adapt a PyTorch training script for multi-GPU training, shard large models, combine data and tensor parallelism, and save distributed checkpoints.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/liortesta/clawdagent/pytorch-fsdp2
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 liortesta/ClawdAgent --skill pytorch-fsdp2
Clone the repo
git clone --depth 1 https://github.com/liortesta/ClawdAgent

Made for: Claude Code.

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/liortesta/clawdagent/pytorch-fsdp2.svg)](https://agentmods.dev/skills/liortesta/clawdagent/pytorch-fsdp2)
Your own site
<a href="https://agentmods.dev/skills/liortesta/clawdagent/pytorch-fsdp2"><img src="https://agentmods.dev/badge/skills/liortesta/clawdagent/pytorch-fsdp2.svg" alt="Measured on agentmods" 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.
Origin 100% copy Near-identical to another mod 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 5d ago against content hash b540043bd17d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 5d 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

This is a copy

100% identical to pytorch-fsdp2 — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.claude/skills/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. 5d 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 liortesta/ClawdAgent (11 stars, last pushed 12d ago), licensed Apache-2.0. 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. It is 100% identical to pytorch-fsdp2, differing in 0 lines, and is treated as a copy.

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.

Orchestra-Research/AI-Research-SKILLs · 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 · 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