Skip to content

System Memory OOM on FSDP Checkpoint Save

When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g., 8 GPUs), this creates 8 redundant copies of the full model in CPU RAM, instantly exhausting system memory.

Quick answer

When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory.

Symptom
The training job suddenly gets OOM killed by the OS (dmesg shows python process killed) during the checkpoint saving phase.
Root cause
When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g.
Recommended fix
Enable rank0_only in FullStateDictConfig FSDP.set_state_dict_type(model, StateDictType.FULL_STATE_DICT, FullStateDictConfig(offload_to_cpu=True, rank0_only=True)) This restricts the full model gathering process to Rank 0 only, drastically reducing the CPU memory footprint during checkpointing.
How Denpex helps
Denpex investigates System Memory OOM on FSDP Checkpoint Save using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
Memory#CPU OOM

What this failure is

System Memory OOM on FSDP Checkpoint Save is a Memory failure seen during ML training runs. When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g., 8 GPUs), this creates 8 redundant copies of the full model in CPU RAM, instantly exhausting system memory. Common tags: CPU OOM.

Live diagnosis, no signup

Is this what broke your run? Paste your log.

You're reading about System Memory OOM on FSDP Checkpoint Save. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.

Before uploading, review cloud data handling and local options.

training_logs.txt
No log to hand? Try one:

Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.

3 free diagnoses/day

Why it happens (the mechanism)

Engineers often assume `offload_to_cpu=True` automatically implies that only Rank 0 needs the state, or they monitor GPU memory for OOMs and get confused when the process is killed for System RAM OOM. PyTorch does not default to `rank0_only=True` because some users may want each rank to save a copy.

What you'll observe

  • Killed
  • MemoryError
  • out of memory in torch.cat

Common symptoms and what they mean

SymptomWhy it happens
The training job suddenly gets OOM killed by the OS (dmesg shows python process killed) during the checkpoint saving phase.When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g., 8 GPUs), this creates 8 redundant copies of the full model in CPU RAM, instantly exhausting system memory.
GPU memory looks fine, but CPU memory spikes massively right before the crash.When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g., 8 GPUs), this creates 8 redundant copies of the full model in CPU RAM, instantly exhausting system memory.
The crash happens simultaneously across multiple nodes or local ranks.When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g., 8 GPUs), this creates 8 redundant copies of the full model in CPU RAM, instantly exhausting system memory.

Which systems are affected

  • PyTorch FSDP
  • CPU RAM

How to confirm this is the problem

Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.

  • ✓Check `dmesg -T` for OOM Killer invoking on the python process.
  • ✓Monitor `htop` or system memory metrics during the `model.state_dict()` call.
  • ✓Verify the `StateDictConfig` passed to `FSDP.set_state_dict_type`.

Root cause

  • When using `FullStateDictConfig(offload_to_cpu=True)` without setting `rank0_only=True`, FSDP instructs every single rank to independently gather and reconstruct the full model parameters into its own CPU memory. For a large model and multiple ranks on a node (e.g., 8 GPUs), this creates 8 redundant copies of the full model in CPU RAM, instantly exhausting system memory.

The fix and how to prevent it

Searchable error signature

search key
The training job suddenly gets OOM killed by the OS (dmesg shows python process killed) during the checkpoint saving phase.
out of memory in torch.cat

Use this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.

The fix and the prevention pattern

The root cause is on this page and stays free. A free account adds the exact remediation steps, saved history, and the fix on every entry in the encyclopedia.

Sign up free. Unlock the full analysis

No credit card. Daily allowance follows verified trust tier. Instant access.

Diagnose this failure in VS Code

Select the traceback or open the failed terminal, then run Denpex locally to see the initiating rank, collateral failures, exact fix, and verification command without uploading the log.

Install the free VS Code extension

Don't just read the fix, diagnose your run

The encyclopedia tells you what went wrong. Denpex tells you what went wrong in YOUR training run. With your logs, your config, and your stack.