pytorch-fsdp2

Implement PyTorch FSDP2 distributed training with DTensor sharding and checkpointing.

Updated Jan 12, 2026
One-click install
npx skills add https://github.com/MesferAli/XCircle --skill pytorch-fsdp2-mesferali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-fsdp2
Source: https://github.com/MesferAli/XCircle/tree/main/.claude/skills/pytorch-fsdp2
Command: npx skills add https://github.com/MesferAli/XCircle --skill pytorch-fsdp2-mesferali

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill enables efficient training of large PyTorch models that exceed single-GPU memory by correctly implementing PyTorch's Fully Sharded Data Parallelism (FSDP2).

Core Features & Use Cases

  • Memory Optimization: Distributes model parameters, gradients, and optimizer states across multiple GPUs to train models that wouldn't fit otherwise.
  • DTensor-based Sharding: Leverages PyTorch's DTensor for more inspectable and flexible per-parameter sharding.
  • Distributed Checkpointing: Integrates with PyTorch's Distributed Checkpoint (DCP) for robust saving and loading of distributed model states.
  • Use Case: Training a massive language model where the parameters alone require more than 100GB of VRAM.

Quick Start

Integrate PyTorch FSDP2 into your existing training script by following the step-by-step procedure outlined in the skill's documentation.

Frequently Asked Questions about pytorch-fsdp2

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

FAQPage Schema
How do I train large PyTorch models that exceed single-GPU memory capacity?

To train large PyTorch models exceeding single-GPU memory, distribute parameters, gradients, and optimizer states across multiple GPUs using fully sharded data parallelism. This partitions memory usage so models requiring over 100GB of VRAM can train efficiently.

What is DTensor-based sharding in PyTorch distributed training?

DTensor-based sharding is a PyTorch abstraction that enables more inspectable and flexible per-parameter sharding during distributed training. It distributes model components across a DeviceMesh to manage memory and parallelism explicitly.

How do I configure distributed checkpointing for FSDP2 models?

Configure distributed checkpointing for FSDP2 models by integrating PyTorch's Distributed Checkpoint (DCP) to save and load distributed model states. This ensures robust persistence of sharded parameters across multiple GPUs.

Can I combine FSDP2 with Tensor Parallelism for large model training?

Yes, FSDP2 enables composition with Tensor Parallelism for large model training. By utilizing DTensor and DeviceMesh abstractions, you can shard parameters across data and tensor dimensions simultaneously to maximize GPU memory optimization.

Does PyTorch FSDP2 support mixed precision and CPU offloading?

Yes, PyTorch FSDP2 supports mixed precision and CPU offloading configurations. These features allow you to further reduce GPU memory footprint during distributed training by offloading states or reducing parameter precision.