pytorch-fsdp

Guide PyTorch FSDP training by sharding parameters, gradients, and optimizer state across distributed workers.

Updated May 14, 2026
One-click install
npx skills add https://github.com/SethyPagna/Secretary-Jarvis --skill pytorch-fsdp-sethypagna
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-fsdp
Source: https://github.com/SethyPagna/Secretary-Jarvis/tree/main/src/capabilities/optional-skills/mlops/pytorch-fsdp
Command: npx skills add https://github.com/SethyPagna/Secretary-Jarvis --skill pytorch-fsdp-sethypagna

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps engineers train large PyTorch models efficiently by splitting parameters, gradients, and optimizer states across workers so memory pressure drops and distributed training becomes practical.

Core Features & Use Cases

  • FSDP Training Guidance: Learn how to apply PyTorch FSDP and FSDP2 to real models using bottom-up sharding, device meshes, and the right collectives.
  • Performance and Memory Optimization: Use mixed precision, CPU offloading, prefetching, and sharded state handling to improve throughput and reduce peak memory use.
  • Debugging and Migration Help: Diagnose distributed training issues, understand hook behavior, and migrate from FSDP1 to FSDP2 with clearer parameter semantics.
  • Use Case: A team training a transformer that no longer fits on a single GPU can use this Skill to shard each layer, coordinate all-gather and reduce-scatter operations, and keep training stable at scale.

Quick Start

Ask the Skill to explain how to shard your PyTorch model with FSDP2 and recommend the correct setup for your device mesh, precision, and optimizer.

Frequently Asked Questions about pytorch-fsdp

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

FAQPage Schema
How do I use PyTorch FSDP to shard a model that is too large for a single GPU?

PyTorch FSDP shards model parameters, gradients, and optimizer states across distributed workers to reduce memory pressure. You apply bottom-up sharding to your layers and coordinate all-gather and reduce-scatter operations to enable large-scale training.

What is the difference between FSDP1 and FSDP2 for distributed training?

FSDP2 migration provides clearer parameter semantics and DTensor-aware parameter handling compared to FSDP1. Moving to FSDP2 improves how model states are managed and sharded across device meshes during distributed training.

Can I use mixed precision and CPU offloading with PyTorch FSDP?

Mixed precision and CPU offloading are fully supported in PyTorch FSDP workflows. Combining these techniques with prefetching and sharded state handling improves training throughput and reduces peak memory use.

How do I set up a device mesh for PyTorch FSDP training?

Setting up a device mesh for PyTorch FSDP requires correct device-mesh placement to coordinate distributed workers. You configure the mesh based on your available CPU, CUDA, or XPU systems to ensure proper sharding and communication.

Why does my PyTorch FSDP training fail during distributed collectives?

Distributed training failures often stem from incorrect device-mesh placement or misconfigured all-gather and reduce-scatter coordination. Diagnose hook behavior and verify safe integration with torch.distributed APIs to stabilize training.

When should I use PyTorch FSDP instead of standard distributed training?

PyTorch FSDP is necessary when your large-scale model no longer fits on a single GPU. By sharding parameters, gradients, and optimizer states across workers, FSDP makes distributed training practical and reduces memory pressure.