pytorch-fsdp

Implement PyTorch FSDP and FSDP2 training with per-parameter sharding and CPU offloading.

Updated May 3, 2026
One-click install
npx skills add https://github.com/JuanMS20/solviora-agent --skill pytorch-fsdp-juanms20
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytorch-fsdp
Source: https://github.com/JuanMS20/solviora-agent/tree/main/optional-skills/mlops/pytorch-fsdp
Command: npx skills add https://github.com/JuanMS20/solviora-agent --skill pytorch-fsdp-juanms20

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Guides PyTorch developers to implement Fully Sharded Data Parallel (FSDP) training and FSDP2 configurations including per-parameter sharding, memory optimization, and CPU offloading.

Core Features & Use Cases

  • Advanced guidance on configuring FSDP2 for large models and complex training pipelines.
  • Troubleshooting memory, shard placement, and optimization strategies for distributed training.
  • Use Case: You are training a transformer model across multiple GPUs and nodes, and you want to shard parameters, manage memory, and optimize communication to scale efficiently.

Quick Start

Provide a simple PyTorch FSDP setup example enabling parameter sharding and pre-/post-forward hooks to manage shards during training.

Frequently Asked Questions about pytorch-fsdp

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

FAQPage Schema
How do I configure PyTorch FSDP for distributed transformer training across multiple GPUs?

Configure PyTorch FSDP for distributed transformer training by applying Fully Sharded Data Parallel wrappers to shard parameters across GPUs. This enables per-parameter sharding, mixed precision, and pre- and post-forward hooks to manage memory efficiently.

What is the difference between FSDP and FSDP2 for memory optimization?

FSDP2 provides advanced per-parameter sharding configurations for large models, improving upon standard FSDP memory optimization. It allows finer control over shard placement and communication overhead during multi-node, multi-GPU training workflows.

How do I offload parameters to CPU when using PyTorch Fully Sharded Data Parallel?

Offload parameters to CPU during PyTorch Fully Sharded Data Parallel training by enabling CPU offloading configurations. This reduces GPU memory usage by transferring sharded parameters to host memory when they are not actively computing.

Why does my PyTorch FSDP training workflow run out of memory on multi-node setups?

PyTorch FSDP training workflows run out of memory on multi-node setups due to suboptimal shard placement or communication overhead. Troubleshoot by adjusting per-parameter sharding configurations, enabling CPU offloading, and verifying device mesh integration.

Can I use PyTorch FSDP with the Hugging Face transformers library?

Yes, you can use PyTorch FSDP with the Hugging Face transformers library. FSDP supports integration with transformers and distributed APIs for torch versions 2.0 and above to scale large model training efficiently.

What is the best way to optimize communication overhead in distributed PyTorch training?

Optimize communication overhead in distributed PyTorch training by using FSDP2 configurations with device meshes and process groups. Proper per-parameter sharding placement minimizes communication overhead during multi-node multi-GPU training workflows.