pytorch-fsdp

Implements fully sharded data-parallel training for large PyTorch models.

Updated Aug 22, 2026
One-click install
npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill pytorch-fsdp-vivekgoquest
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: pytorch-fsdp
Source: https://github.com/vivekgoquest/hermes-agent-stable/tree/main/optional-skills/mlops/pytorch-fsdp
Command: npx skills add https://github.com/vivekgoquest/hermes-agent-stable --skill pytorch-fsdp-vivekgoquest

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Training large models often exceeds single-GPU memory, and configuring PyTorch FSDP correctly (wrapping policies, sharding strategies, mixed precision, checkpointing) is error-prone without authoritative reference material. ## Core Features & Use Cases - FSDP Pattern Catalog: Provides roughly 157k characters of runnable FSDP snippets covering wrapping, sharding strategies, checkpointing, and mixed precision in references/common-patterns.md. - Official Documentation References: Includes extracted PyTorch docs on FSDP2 (fully_shard), DistributedDataParallel internals, torch.distributed backends, and the Join context manager for uneven inputs. - Use Case: When migrating a training script from DDP to FSDP2, load the reference files to apply fully_shard bottom-up per layer, configure a DeviceMesh, and set up sharded state dict checkpointing correctly. ## Quick Start Ask the agent to help convert your PyTorch training script to use FSDP2 fully_shard with mixed precision and sharded checkpointing.

Frequently Asked Questions about pytorch-fsdp

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

FAQPage Schema
How do I apply PyTorch FSDP2 fully_shard to a model?▼

Apply fully_shard bottom-up: call it on each sublayer (e.g., each Transformer layer) before calling it on the root model. Each call groups parameters for a single all-gather, and the root call groups remaining parameters like embeddings and output projections.

What is the difference between FSDP1 and FSDP2 in PyTorch?▼

FSDP2 uses DTensor-based per-parameter sharding on dim-0 instead of FSDP1's flat-parameter sharding, giving simpler reasoning about sharded state and communication-free sharded state dicts. FSDP2 also removes record_stream memory management and exposes manual prefetching and collective scheduling APIs.

Which torch.distributed backend should I use for GPU training?▼

Use the NCCL backend for distributed training with CUDA GPUs, including InfiniBand hosts since NCCL supports GPUDirect. Use Gloo for CPU training or as a fallback if NCCL encounters problems, though Gloo runs slower on GPUs.

Does FSDP2 support full state dict checkpointing?▼

FSDP2 does not directly support full state dicts; it produces sharded state dicts containing DTensors. Convert them using DTensor.full_tensor() or PyTorch Distributed Checkpoint's distributed state dict APIs.

Why does distributed training hang with uneven inputs across ranks?▼

Hangs occur when ranks run different numbers of iterations, leaving collective calls unmatched. Use the generic Join context manager (torch.distributed.algorithms.Join) to shadow collectives of joined processes until all ranks finish.