pytorch-fsdp

Implement PyTorch FSDP training with sharding, mixed precision, and CPU offloading.

19|4|Updated Apr 22, 2026
One-click install
npx skills add https://github.com/carterwayneskhizeine/hermes-agent-windows-R --skill pytorch-fsdp-carterwayneskhizeine
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-fsdp
Source: https://github.com/carterwayneskhizeine/hermes-agent-windows-R/tree/main/optional-skills/mlops/pytorch-fsdp
Command: npx skills add https://github.com/carterwayneskhizeine/hermes-agent-windows-R --skill pytorch-fsdp-carterwayneskhizeine

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires torch>=2.0, transformers, and includes references (resource) components.

What problem does it solve?

This Skill helps you design, implement, and debug Fully Sharded Data Parallel (FSDP) training in PyTorch so you can scale to larger models while controlling memory usage and runtime stability.

Core Features & Use Cases

  • FSDP design guidance: Understand how parameter sharding, all-gather/reshard flows, and gradient reduce-scatter work to prevent stalls and incorrect training behavior.
  • Mixed precision & performance tuning: Choose mixed-precision and execution settings that balance throughput and numerical stability.
  • FSDP1 vs FSDP2 direction: Get practical pointers for modern FSDP2 (fully_shard) workflows, including DTensor-based sharding and hook-driven unshard/reshard behavior.
  • Use Case: You want to train a Transformer on limited GPU memory; use this Skill to structure your model sharding plan (bottom-up), set the correct mesh strategy, and troubleshoot hangs caused by mismatched collectives.

Quick Start

Ask the AI: explain how to apply PyTorch FSDP2 (fully_shard) to a Transformer bottom-up with a 1D or 2D DeviceMesh, and what to check when training hangs during forward or backward.

Frequently Asked Questions about pytorch-fsdp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does PyTorch FSDP parameter sharding and gradient reduce-scatter work?

PyTorch FSDP shards parameters across ranks, performing all-gather to unshard for forward and backward passes, then reduce-scatter for gradients. This reduces memory while maintaining correct distributed training semantics across devices.

How do I apply FSDP2 fully_shard to a Transformer bottom-up with a DeviceMesh?

To apply FSDP2 with fully_shard, structure your Transformer sharding plan bottom-up using a 1D or 2D DeviceMesh. This hook-driven workflow uses DTensor-based sharding to manage unshard and reshard behavior efficiently during training.

Why does PyTorch distributed training hang during forward or backward passes?

Distributed training hangs during forward or backward passes are typically caused by mismatched collectives across ranks. You must verify that your sharding strategy and DDP collectives are correctly synchronized to prevent stalls and incorrect training behavior.

What is the best way to configure mixed precision for FSDP to balance throughput and stability?

Configuring mixed precision for FSDP requires choosing execution settings that balance throughput and numerical stability. You need to select appropriate mixed-precision options to ensure stable training while optimizing runtime performance.

Can I use CPU offloading with PyTorch FSDP to train large models on limited GPU memory?

Yes, you can use CPU offloading with PyTorch FSDP to train large models on limited GPU memory. Proper offloading considerations help reduce memory consumption while maintaining correct distributed semantics during training.

What distinguishes FSDP2 fully_shard from FSDP1 for distributed training?

FSDP2 fully_shard uses a hook-aware workflow with DTensor-based sharding, whereas FSDP1 relies on traditional parameter sharding. FSDP2 provides a more modern approach to managing unshard and reshard flows for large-scale models.