pytorch-fsdp2

Integrate PyTorch FSDP2 fully_shard into training scripts for large models.

3|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/ihatesea69/HieuNghi-AI-Skills --skill pytorch-fsdp2-ihatesea69
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-fsdp2
Source: https://github.com/ihatesea69/HieuNghi-AI-Skills/tree/main/airesearch_skills/08-distributed-training/pytorch-fsdp2
Command: npx skills add https://github.com/ihatesea69/HieuNghi-AI-Skills --skill pytorch-fsdp2-ihatesea69

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enables the correct integration of PyTorch's Fully Sharded Data Parallelism (FSDP2) into training scripts, allowing models that exceed single-GPU memory to be trained efficiently.

Core Features & Use Cases

  • FSDP2 Integration: Adds FSDP2 (fully_shard) with proper initialization, sharding, and configuration.
  • Memory Optimization: Enables training of large models by sharding parameters, gradients, and optimizer states across GPUs.
  • Use Case: Training a massive language model that requires more GPU memory than available on a single device.

Quick Start

Integrate PyTorch FSDP2 into your existing training script by following the provided step-by-step procedure and contract.

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?

To train large PyTorch models exceeding single-GPU memory, you can use FSDP2 to shard parameters, gradients, and optimizer states across multiple GPUs. This integration enables efficient distributed training for massive models.

How does DTensor-based sharding work with PyTorch FSDP2?

DTensor-based sharding in FSDP2 works by distributing tensor computations across a DeviceMesh, enabling multi-dimensional parallelism. It configures initialization and sharding to efficiently manage memory and scale training.

Can I configure mixed precision and CPU offload in PyTorch distributed training?

Yes, you can configure mixed precision and offload settings in PyTorch distributed training using FSDP2. This Skill manages these configurations to optimize GPU memory usage during large model training.

What is the best way to integrate fully_shard into my existing training scripts?

The best way to integrate fully_shard is by following provided procedures to add FSDP2 to your training scripts. This involves configuring initialization, sharding, and distributed checkpointing for large models.

Does FSDP2 support distributed checkpointing for large model training?

Yes, FSDP2 supports distributed checkpointing for large model training. This Skill configures checkpointing alongside sharding and mixed precision to ensure training states are saved across distributed GPUs.

When do I need DeviceMesh composition for multi-dimensional parallelism in PyTorch?

You need DeviceMesh composition for multi-dimensional parallelism in PyTorch when scaling FSDP2 across multiple GPUs. It enables DTensor-based sharding to efficiently manage memory for massive models.