What problem does it solve?
Adds PyTorch FSDP2 (fully_shard) to training scripts with correct init, sharding, mixed precision/offload config, and distributed checkpointing. Use when models exceed single-GPU memory or when you need DTensor-based sharding with DeviceMesh.
Core Features & Use Cases
- Bottom-up sharding: explicitly apply fully_shard to submodules before the root module to maximize memory efficiency and performance.
- DeviceMesh integration: leverage DeviceMesh to manage complex topology for multi-dimensional parallelism.
- Mixed precision & offload: configure MP and CPU offload to balance speed and memory.
- Checkpointing support: use DCP or distributed state-dict patterns for robust and scalable saves/loads.
- Use Case: training very large transformer models that exceed single-GPU memory while enabling deterministic sharded state handling.
Quick Start
Initialize distributed training with torchrun, apply fully_shard bottom-up to submodules, materialize parameters on GPU, and create the optimizer after sharding to enable DTensor-based training.