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 matches System Memory OOM on FSDP Checkpoint Save across every rank in a distributed run and reports which rank failed first, so you act on the initiating node instead of the loudest one.
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 crash log or traceback below and get the real root cause for YOUR run, not this generic entry. No account, no card. Logs are masked at ingress and never saved to account history.

training_logs.txt
No log to hand? Try one:

3 free diagnoses/day

Want 14 days on the Scale plan?

Request an evaluation code. A verified workplace organization activates up to 50 diagnoses a day, alerts, history, and follow-up questions. No credit card or automatic subscription.

Evaluate one incident

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`.

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

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

Evaluate Denpex on your own logs

Request a Scale evaluation code. A verified workplace organization activates 14 days with up to 50 diagnoses a day. Every account keeps its current diagnosis allowance and gets a verification path. No card or automatic subscription.

We send a single-use code tied to that address. Static provider and TLD rules do not reject valid addresses. Account trust determines the benefit after signup.

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.