• Myle Ott's avatar
    Add FullyShardedDataParallel (FSDP) (#413) · 15512d9e
    Myle Ott authored
    Recent work by [Microsoft](https://arxiv.org/abs/1910.02054) and [Google](https://arxiv.org/abs/2004.13336
    
    ) has shown that data parallel training can be made significantly more efficient by sharding the model parameters and optimizer state across data parallel workers. These ideas are encapsulated in the new **`FullyShardedDataParallel` (FSDP)** wrapper, which is a drop-in replacement for PyTorch's `DistributedDataParallel` (DDP) wrapper.
    
    Compared to PyTorch DDP:
    * FSDP shards parameters (FP16 + FP32) and optimizer state across data parallel GPUs
    * FSDP with `reshard_after_forward=False` has the same communication cost as PyTorch DDP and is similar to ZeRO-2
    * FSDP with `reshard_after_forward=True` increases total communication by 50% and is similar to ZeRO-3:
        * all-gather parameters at start of forward pass and start of backward pass
        * reduce-scatter grads at end of backward pass
    Co-authored-by: default avatarMin Xu <24926999+min-xu-ai@users.noreply.github.com>
    Co-authored-by: default avatarSam Shleifer <sshleifer@gmail.com>
    15512d9e
parameter.pyi 561 Bytes