Abstract
Training massive Large Language Models (LLMs) requires efficient distributed strategies like Fully Sharded Data Parallel (FSDP). Traditional "eager mode" FSDP implementations often obscure communication operations from compilers, preventing optimal computation-communication overlap. We present SimpleFSDP, a PyTorch-native framework that utilizes torch.compile to optimize the entire training graph. By treating communication as standard primitives, SimpleFSDP enables automated bucketing and reordering, resulting in up to 68% higher throughput and 28% lower memory usage on Llama 3 models.
Introduction
The scale of modern LLMs necessitates sharding parameters, gradients, and optimizer states across vast GPU clusters. While FSDP is the standard for this, its traditional implementation relies on specialized hooks that act as "black boxes" for compilers. This lack of visibility prevents compilers from optimizing the overlap between computation and communication, leading to idle GPU time and inefficient memory management. SimpleFSDP addresses this by making communication operations traceable and optimizable within the PyTorch ecosystem.
Methodology
SimpleFSDP achieves FSDP semantics using native PyTorch primitives, allowing torch.compile to "see" the full execution graph.
Traceable Communication
Instead of manual hooks, SimpleFSDP employs DTensor for sharding and the parametrization API to handle parameter all-gathers. This transformation ensures that communication operations appear as standard differentiable operations to the compiler. To manage memory, parameter all-gathers are wrapped in selective activation checkpointing, ensuring parameters are released immediately after use and re-gathered only when necessary during the backward pass.
TorchInductor Optimizations
The framework introduces two key optimizations within the TorchInductor backend:
- Bucketing: Small communication operations are merged into larger ones to mitigate network latency overhead.
- Reordering: Communication tasks are automatically rescheduled (prefetched) to overlap with independent mathematical computations.
SimpleFSDP supports both manual wrapping, where users define modules, and auto-wrapping, which uses a greedy profiling-based algorithm to determine optimal bucketing and reordering.
Experimental Results
We evaluated SimpleFSDP using the Llama 3.1 model series (8B, 70B, and 405B) on the C4 dataset using a cluster of 128 NVIDIA H100 GPUs.
Performance and Throughput
For the Llama 3.1 405B model, SimpleFSDP achieved a 68.67% improvement in throughput (tokens per second) compared to the standard FSDP2 eager-mode implementation. Even when compared to "FSDP-compile"—which only compiles mathematical operations—SimpleFSDP provided an additional 6-8% performance boost by optimizing communication overlap.
Memory Efficiency
On the 8B model, SimpleFSDP demonstrated a 28.54% reduction in peak memory usage. The framework successfully scaled to the 405B model, proving the viability of compiler-based FSDP at the largest scales of AI training.
Discussion
The primary advantage of SimpleFSDP is the "power of visibility." By making communication traceable, the compiler can perform hardware-specific optimizations, such as fusing kernels across communication boundaries. Furthermore, the use of native primitives ensures "composability," allowing SimpleFSDP to be easily integrated with Tensor Parallelism (TP) and Pipeline Parallelism (PP). Unlike many compiled frameworks, SimpleFSDP maintains eager-mode debuggability, facilitating rapid iteration for researchers.
Limitations and Future Work
The current auto-wrapping heuristic relies on a simplified profiling model that may not fully account for complex network topologies. Additionally, "graph breaks" caused by non-traceable code can limit optimization scope. Future work will focus on more sophisticated overlapping algorithms for multi-dimensional parallelism and the development of automated "auto-parallelism" engines.
Conclusion
SimpleFSDP demonstrates that a compiler-centric approach to FSDP can significantly enhance training efficiency for massive models. By leveraging torch.compile and native PyTorch primitives, it provides a simpler, more performant, and highly composable framework for large-scale AI research.
Summary updated