Home Knowledge Base Fully Sharded Data Parallel (FSDP)

Fully Sharded Data Parallel (FSDP) is the advanced distributed training technique that shards model parameters, gradients, and optimizer states across GPUs — each GPU stores only 1/N of the model (N=number of GPUs), gathering required parameters on-demand during forward/backward passes and immediately discarding them, reducing per-GPU memory from O(model_size) to O(model_size/N), enabling training of 100B+ parameter models on 8×40GB GPUs that would otherwise require 400GB+ per GPU, achieving 80-90% scaling efficiency despite increased communication overhead.

FSDP Sharding Strategy:

ZeRO Stages (DeepSpeed):

FSDP Implementation (PyTorch):

Communication Patterns:

Performance Optimization:

Hybrid Sharding:

Memory Breakdown:

Comparison with DDP:

Scaling to Extreme Sizes:

Debugging FSDP:

Fully Sharded Data Parallel is the memory-efficiency breakthrough that enables training of models 10-100× larger than GPU memory — by sharding all model state across GPUs and carefully orchestrating communication, FSDP makes training 100B+ parameter models accessible on modest GPU clusters, democratizing large-scale model training and enabling researchers to push the boundaries of model scale without requiring massive infrastructure investments.


Distributed AI Training — Scaling from 1 GPU to 100,000. Training frontier LLMs (GPT-4 class, 1–2 trillion parameters) requires distributing computation across thousands of GPUs because no single device has enough memory (80 GB HBM3 holds only 40B parameters in FP16) or compute (1 PFLOPS per GPU vs 10$^{24}$–$10^{25}$ FLOPs total training cost). The four parallelism strategies — data, tensor, pipeline, and expert — partition the workload differently, and production training runs combine all four simultaneously in a 4D parallelism configuration.

Distributed Training: 4D Parallelism Data × Tensor × Pipeline × Expert parallelism — combined for frontier model training Data Parallelism (DP / FSDP) Each GPU holds full model copy Different data batches per GPU All-reduce gradients after backward FSDP: shard parameters + gradients → memory per GPU: model/N + activations Scales: 8–1024 GPUs (near-linear) Bottleneck: all-reduce bandwidth Tensor Parallelism (TP) Split weight matrices across GPUs Each GPU computes partial GEMM All-reduce activations per layer Megatron-LM column/row parallel → memory per GPU: model/TP_degree Scales: 2–8 GPUs (within node) Bottleneck: NVLink latency per layer Pipeline Parallelism (PP) Split model layers across GPUs GPU 1: layers 1–20, GPU 2: 21–40... Micro-batches fill the pipeline 1F1B schedule minimizes bubble → memory per GPU: layers/PP_degree Scales: 4–64 GPUs (across nodes) Bottleneck: pipeline bubble (idle time) Expert Parallelism (EP) Each GPU holds subset of experts Router sends tokens to expert GPUs All-to-all communication pattern Load imbalance from routing → memory per GPU: experts/EP_degree Scales: 8–256 GPUs (MoE models) Bottleneck: all-to-all bandwidth GPT-4 training: DP=128 × TP=8 × PP=16 = 16,384 GPUs | Cost: 50–100M USD per training run MFU (Model FLOPs Utilization): 40–55% achievable — rest lost to communication + bubble + overhead

FSDP (Fully Sharded Data Parallel) — Memory-Efficient Training. Standard data parallelism replicates the entire model on each GPU — wasteful when models exceed GPU memory. FSDP (PyTorch) and DeepSpeed ZeRO shard model parameters, gradients, and optimizer states across data-parallel ranks. ZeRO Stage 3 reduces per-GPU memory from $16\Psi$ bytes (full replication with Adam FP16) to $16\Psi/N + \text{activations}$. For a 70B model on 64 GPUs: full replication needs 1,120 GB (impossible per GPU); FSDP needs 17.5 GB model memory per GPU + activations — fitting in 80 GB HBM3 with room for large batch sizes. The trade-off: FSDP adds an all-gather before each layer's forward pass and a reduce-scatter after each backward pass, increasing communication volume by 1.5$\times$ versus standard all-reduce.

Model Parallelism — Splitting Layers and Matrices. Tensor parallelism (Megatron-LM) splits the attention and FFN weight matrices column-wise (for the first linear) and row-wise (for the second linear), so each GPU computes a partial result and an all-reduce combines them. For an 8-way TP split: each GPU holds 1/8 of each weight matrix and performs 1/8 of the compute, but requires 2 all-reduce operations per transformer layer (one after attention, one after FFN). At 900 GB/s NVLink bandwidth and 4 ms per all-reduce, TP within a single 8-GPU node adds $<$10% overhead. Pipeline parallelism assigns consecutive layers to different GPUs; the 1F1B (one-forward-one-backward) micro-batch schedule achieves pipeline utilization of $(PP - 1) / PP$ per micro-batch, reaching 90%+ efficiency with 8+ micro-batches per global batch.

Silicon Photonics — Optical I/O for AI. As GPU cluster scale grows from 10,000 to 100,000+ devices, electrical SerDes I/O hits power and reach limits: 112 Gbps PAM4 over copper reaches only 1–2 meters at 10 pJ/bit — insufficient for rack-to-rack communication. Silicon photonics integrates optical modulators, waveguides, and photodetectors on a silicon chip, enabling 1.6 Tbps optical links at 5 pJ/bit over 2+ km of single-mode fiber. Co-packaged optics (CPO) places the photonic engine directly on the switch/GPU package, eliminating pluggable transceiver power overhead. Broadcom, Intel, Marvell, and Ayar Labs ship 800G–1.6T optical engines; next-generation AI clusters (2026+) will use 3.2T CPO to interconnect 100,000 GPUs at $<$1 µs fabric latency.

Transformer Architecture at Hardware Scale. A transformer layer comprises multi-head attention (MHA: $4 d^2$ parameters) and feed-forward network (FFN: $8 d^2$ parameters) for a total of $12 d^2$ parameters per layer. GPT-4 scale ($d = 12{,}288$, 120 layers) yields 1.8T parameters requiring 3.6 TB in FP16 — distributed across 16,000+ GPUs. Training at 55% MFU on 16,384 H100s at 989 TFLOPS FP16 each delivers 8.9 $\times 10^{18}$ FLOPs/s effective; a $10^{25}$ FLOP training run completes in 13 days at 95% uptime. The hardware cost: 16,384 $\times$ 30K USD = 500M USD capital, plus 10–20 MW power at 0.10 USD/kWh = 3–6M USD electricity per run.

fully sharded data parallel fsdpzero optimizer deepspeedsharded optimizer statefsdp memory efficiencyzero redundancy optimizer

Explore 500+ Semiconductor & AI Topics

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