Home Knowledge Base FSDP (Fully Sharded Data Parallel)

FSDP (Fully Sharded Data Parallel) is the PyTorch-native strategy for training large models across multiple GPUs by sharding model parameters, gradients, and optimizer states across all workers — reducing per-GPU memory by up to Nx (where N is GPU count) compared to standard data parallelism, enabling training of models that would not fit in a single GPU's memory.

Why Not Standard Data Parallel?

FSDP Memory Savings

StrategyParametersGradientsOptimizer StatesTotal (per GPU)
DDPFull copyFull copyFull copy~16× model size
ZeRO Stage 1FullFullSharded~12×
ZeRO Stage 2FullShardedSharded~8×
FSDP / ZeRO Stage 3ShardedShardedSharded~16×/N

How FSDP Works

1. Initialization: Model parameters are sharded — each GPU holds only 1/N of parameters. 2. Forward Pass: Before computing a layer, FSDP all-gathers that layer's parameters from all GPUs. 3. Compute: Forward computation using full parameters. 4. Free: After forward, full parameters freed — only shard retained. 5. Backward Pass: Same all-gather for each layer, compute gradients, then reduce-scatter gradients. 6. Optimizer Step: Each GPU updates only its shard of parameters.

PyTorch FSDP API

from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
model = FSDP(
    model,
    sharding_strategy=ShardingStrategy.FULL_SHARD,
    mixed_precision=MixedPrecision(param_dtype=torch.bfloat16),
    auto_wrap_policy=size_based_auto_wrap_policy,
)

Key Configuration

FSDP vs. DeepSpeed ZeRO

FSDP is the standard approach for training large language models on GPU clusters — it democratizes large model training by making billion-parameter models trainable on commodity multi-GPU setups that would otherwise require expensive model parallelism engineering.

fsdp fully shardedfully sharded data parallelpytorch fsdpmulti gpu trainingsharded parameter

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.