pytorch-fsdp2

Add PyTorch FSDP2 sharding and distributed checkpointing to training scripts.

Updated Feb 15, 2026
One-click install
npx skills add https://github.com/ricable/mcai --skill pytorch-fsdp2-ricable
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-fsdp2
Source: https://github.com/ricable/mcai/tree/main/.agents/skills/pytorch-fsdp2
Command: npx skills add https://github.com/ricable/mcai --skill pytorch-fsdp2-ricable

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you upgrade an existing PyTorch training loop to use FSDP2 when model parameters, gradients, or optimizer state no longer fit on one GPU.

Core Features & Use Cases

  • Bottom-up sharding of transformer blocks and root modules for efficient distributed training.
  • DTensor-aware optimizer setup after sharding so updates happen on the correct parameters.
  • Mixed precision, CPU offload, DeviceMesh composition, and distributed checkpointing with DCP.
  • Use case: training large language models or other memory-heavy networks across multiple GPUs with resumable checkpoints.

Quick Start

Use this skill to retrofit a PyTorch training script with FSDP2 sharding, DTensor-safe optimization, and distributed checkpointing.

Frequently Asked Questions about pytorch-fsdp2

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

FAQPage Schema
How do I add PyTorch FSDP2 sharding to a training script to prevent OOM errors?

Prevent OOM errors by retrofitting your PyTorch training script with FSDP2 bottom-up module sharding. This splits parameters, gradients, and optimizer state across GPUs using DeviceMesh-based parallelism for memory-heavy networks.

When do I need distributed checkpointing with DCP for PyTorch training?

You need distributed checkpointing with DCP when training large models across multiple GPUs and require resumable checkpoints. It enables checkpoint portability and safe save/load operations for sharded DTensor parameters.

Can I use mixed precision and CPU offload with FSDP2 sharding?

Yes, you can configure mixed precision and CPU offload with FSDP2 sharding. The Skill applies these memory optimizations alongside DeviceMesh composition and bottom-up module sharding for large distributed transformer training.

How does DTensor parameter handling affect optimizer construction after sharding?

DTensor parameter handling requires optimizer construction after sharding so updates target the correct parameters. This Skill ensures DTensor-aware optimizer setup following bottom-up module sharding to maintain correct distributed updates.

What are the limitations of applying FSDP2 to existing PyTorch training loops?

FSDP2 application requires existing PyTorch training loops to support DTensor parameter handling and hook-safe model invocation. It targets distributed transformer and large-model workflows needing bottom-up module sharding and DeviceMesh-based parallelism.