---
title: "Fully Sharded Data Parallel: faster AI training with fewer GPUs"
description: "Fully Sharded Data Parallel (FSDP) shards model parameters, gradients and optimizer states across data-parallel GPU workers."
url: "https://swe.quest/articles/fully-sharded-data-parallel-faster-ai-training-with-fewer-gpus-9a4d28846db69a7b"
canonical: "https://engineering.fb.com/2021/07/15/open-source/fsdp/"
source: "Meta Engineering"
published: "2021-07-15"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 8
tags: ["model-training","python"]
---

# Fully Sharded Data Parallel: faster AI training with fewer GPUs

A post on [Meta Engineering](https://swe.quest/sources/meta.md), published 2021-07-15, 8 min read, Deep dive. Original: [https://engineering.fb.com/2021/07/15/open-source/fsdp/](https://engineering.fb.com/2021/07/15/open-source/fsdp/)

## Summary

Fully Sharded Data Parallel (FSDP) shards model parameters, gradients and optimizer states across data-parallel GPU workers. It does this by decomposing DDP's all-reduce into reduce-scatter and all-gather steps, gathering each layer's full weights just in time for the forward and backward passes and then discarding them. It produces results identical to PyTorch DDP, overlaps communication with computation, can offload optimizer state to CPU, and is meant to scale to trillions of parameters. It is available through FairScale, fairseq, VISSL and PyTorch Lightning, with caveats around nested wrapping, consistent weight initialization, optimizer parameter groups, mixed precision and checkpointing.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- PyTorch DistributedDataParallel
- collective communication (all-reduce)
- neural network training loop ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))
- mixed precision training ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))

## Keywords

FSDP, FairScale, PyTorch, ZeRO-3, fairseq, VISSL, PyTorch Lightning, DistributedDataParallel

## Related posts

- [Accelerate Large Model Training using PyTorch Fully Sharded Data Parallel](https://swe.quest/articles/accelerate-large-model-training-using-pytorch-fully-sharded-data-parallel-513a65557fbde722.md): Hugging Face · 2022-05-02 · Hard · 12 min read · Model training, Machine learning, Python, Performance engineering
  Hugging Face Accelerate exposes PyTorch FullyShardedDataParallel (FSDP), which shards parameters, gradients and optimizer states across GPUs (ZeRO stage 2/3) with optional CPU offload, and does so without changes to training code.
- [Accelerate ND-Parallel: A guide to Efficient Multi-GPU Training](https://swe.quest/articles/accelerate-nd-parallel-a-guide-to-efficient-multi-gpu-training-b84f16c2d8888d39.md): Hugging Face · 2025-08-08 · Hard · 18 min read · Model training, Distributed systems, Python
  Accelerate's ParallelismConfig, also exposed through Axolotl config fields, lets you compose data parallelism, FSDP, tensor parallelism and context parallelism in one training setup.
- [From DeepSpeed to FSDP and Back Again with Hugging Face Accelerate](https://swe.quest/articles/from-deepspeed-to-fsdp-and-back-again-with-hugging-face-accelerate-15016dbd4b4a46b2.md): Hugging Face · 2024-06-13 · Hard · 6 min read · Model training, Machine learning, Python
  DeepSpeed ZeRO-3 and PyTorch FSDP gave different training results on Mistral-7B loaded in bfloat16 because DeepSpeed silently upcasts flattened parameters and optimizer state to fp32, while FSDP keeps them in the loaded dtype.
- [Accelerate Large Model Training using DeepSpeed](https://swe.quest/articles/accelerate-large-model-training-using-deepspeed-d18dbe7623c821c0.md): Hugging Face · 2022-06-28 · Medium · 8 min read · Model training, Python, Performance engineering
  Hugging Face Accelerate can enable DeepSpeed ZeRO data parallelism, which shards optimizer states, gradients and parameters across GPUs and optionally offloads them to CPU, with no or minimal code changes.
- [Ulysses Sequence Parallelism: Training with Million-Token Contexts](https://swe.quest/articles/ulysses-sequence-parallelism-training-with-million-token-contexts-a21775c0b516e85a.md): Hugging Face · 2026-03-09 · Hard · 13 min read · Model training, LLMs, Distributed systems, Hardware
  Ulysses Sequence Parallelism, part of Snowflake's Arctic Long Sequence Training protocol, enables training on contexts of hundreds of thousands to millions of tokens.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
