Applying fully_shard only to the top-level root model
Sharding only the root forces FSDP2 to all-gather the entire model at once; shard each transformer block first, then the root.
Operator task guide
PyTorch FSDP2 replaces FSDP1 FlatParameter wrapping with per-parameter DTensor sharding via fully_shard(). Most FSDP2 OOMs happen when a model is materialized on CPU/GPU before sharding instead of using torch.device("meta") initialization, or when unsharded forward/backward peaks lack activation checkpointing.
For FSDP2 hangs or DTensor errors during backward or Distributed Checkpoint (DCP) saves, verify all ranks call fully_shard in identical module order, wrap sub-blocks before the root module, and enable TORCH_DISTRIBUTED_DEBUG=DETAIL alongside Flight Recorder.
Reviewed . Reference guidance is not a diagnosis of your workload.
Avoid allocating full unsharded weights on every rank GPU at once. Construct on meta, apply fully_shard bottom-up on transformer blocks then root, and materialize or load sharded DCP weights afterward.
python3 -c "import torch; print(torch.__version__, hasattr(torch.distributed.fsdp, 'fully_shard'))"Inspect torch.cuda.memory_summary() for CUDA OOMs versus host dmesg/sacct MaxRSS if CPUOffloadPolicy killed the process silently with SIGKILL (-9).
dmesg -T | grep -iE 'Killed process|Out of memory|memory cgroup'
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:TrueIf ranks hang inside backward all-gather or reduce-scatter, check that no rank takes a conditional branch skipping a sharded submodule and enable TORCH_DISTRIBUTED_DEBUG=DETAIL.
export TORCH_DISTRIBUTED_DEBUG=DETAIL
export TORCH_NCCL_TRACE_BUFFER_SIZE=2000
export TORCH_NCCL_DUMP_ON_TIMEOUT=1Confirm reshard_after_forward=True on transformer blocks when VRAM is tight, and apply selective or full activation checkpointing on transformer layers rather than shrinking global batch size prematurely.
| Signal | What it means | Next action |
|---|---|---|
| CUDA OOM during model construction or from_pretrained | Full unsharded model loaded per rank before fully_shard. | Initialize inside torch.device("meta") context, shard with fully_shard, then materialize/load. |
| CUDA OOM during forward/backward despite sharded weights | Activation memory or unsharded layer peak exceeded HBM. | Enable activation checkpointing and verify reshard_after_forward=True. |
| DTensor mesh / shape mismatch across ranks | Inconsistent tensor parallel / FSDP device mesh or conditional forward. | Verify uniform module calls across ranks and consistent DeviceMesh dimensions. |
| Worker killed with exit code -9 under CPUOffloadPolicy | Host RAM / cgroup exhausted by offloaded parameters/optimizer. | Check sacct MaxRSS and lower host memory pressure or pin_memory usage. |
Sharding only the root forces FSDP2 to all-gather the entire model at once; shard each transformer block first, then the root.
Weight sharding saves static parameter memory, not long-sequence activations.
Checkpoints and state_dict APIs differ between FSDP1 and FSDP2 (use torch.distributed.checkpoint).
Compare DTensor sharding failures with ZeRO-3 inflight parameter traps.
Model weights, optimizer states, gradients, and FSDP sharding memory.
Fix host RAM exhaustion and distributed checkpoint save failures.
Isolate which rank died before the collective timed out.
DDP replicates the entire model on every GPU. FSDP1 shards parameters into flattened 1D FlatParameters. FSDP2 uses per-parameter DTensors via fully_shard(), eliminating FlatParameter metadata complexity and simplifying mixed-precision and TP composability.
FSDP2 integrates natively with PyTorch DTensor, torch.compile, and tensor parallelism. DeepSpeed ZeRO-3 offers mature NVMe/CPU offload pipelines (ZeRO-Infinity) and built-in pipeline/offload configs.
The usual culprits are loading weights onto GPU before calling fully_shard (fix with meta-device init), large sequence activations without activation checkpointing, or holding reshard_after_forward=False on memory-bound runs.
Use PyTorch Distributed Checkpoint (torch.distributed.checkpoint) with get_model_state_dict / get_optimizer_state_dict rather than naive torch.save on DTensor weights.
Get the likely cause, supporting evidence, and next safe steps with the same cloud reasoning used by paid plans. A crash the engine recognizes is answered in seconds, then checked by an independent AI review that updates this page when it finishes. A crash it does not recognize waits for the AI's own answer, which can take a few minutes. No account, card, or installation. Logs are masked at Denpex API ingress and are not saved to account history.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
No credit card. No automatic subscription. See whether Denpex helps with an incident you already understand.
Up to 50 diagnoses a day for 30 days. Verify your work email to activate an eligible company evaluation, then replay a resolved incident and compare the evidence and next steps with your team's confirmed cause.
Use the three free diagnoses to review your error and relevant evidence. Keep reference guidance separate from the cause and recovery status of your own workload.
Diagnose your incident