What problem does it solve?
Fully Sharded Data Parallelism (FSDP) in PyTorch enables memory-efficient, scalable training for very large models by sharding parameters and managing gradients across processes, including FSDP2 with per-parameter sharding, mixed precision, and CPU offloading.
Core Features & Use Cases
- Per-parameter sharding with DTensor-based memory layout to reduce memory footprint during training.
- Device mesh orchestration and FSDP2 integration for scalable, multi-node training of transformer-scale models.
- Pre-forward all-gather and post-forward/backward resharding to maximize throughput while minimizing peak memory consumption.
- Support for mixed precision and CPU offloading to balance compute and memory resources in heterogeneous environments.
- Use Cases: training large models (e.g., transformers) that exceed single-device memory budgets, migrating from FSDP1 workflows, and optimizing memory-performance tradeoffs in distributed setups.
Quick Start
Apply fully_shard to your PyTorch model with a defined device mesh and begin distributed training to leverage per-parameter sharding.