﻿# FSDP rank-only checkpoint output does not mean rank-only state gathering

Distinguish collective full optimizer-state gathering from rank-only dictionary output and file writing in the named FSDP checkpoint API family.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/pytorch-fsdp-collective-checkpoint-participation/
Language: en

A checkpoint branch runs only on the designated writer rank. It calls an FSDP full-state helper, while other ranks continue training, and gathering stalls before any file appears. The mistake is applying the storage-writer condition to an operation that still requires distributed state from the other members.

## Name the exact checkpoint API

Record the FSDP API family, state representation and installed version. The [FSDP reference](https://docs.pytorch.org/docs/2.15/fsdp.html) explicitly documents full_optim_state_dict as collective across ranks even with rank0_only enabled. This article examines that named contract, not every FSDP generation or checkpoint helper. Do not mix assumptions from another API simply because both return a state dictionary. Save whether the intended artifact contains model weights, optimizer state or additional continuation data.

## Separate gathering from file writing

All required ranks participate in the collective gathering call; only the designated writer receives the populated result under the documented rank-only configuration. The others can receive empty dictionaries without being optional participants. Place rank-conditional file output after the required gathering boundary rather than around the whole operation. The [checkpoint state guide](/journal/bytecheckpoint-load-time-resharding-state-scope-evidence/) explains why a full-state label must still identify exactly which application state was included and restored.

## Budget the populated output location

The FSDP reference describes CPU offload and rank-only full-state configuration as memory-saving choices at different locations. Gathered output still needs capacity where it materializes, and the operation can communicate before storage I/O begins. Record host memory, device memory and gathering state separately. An empty dictionary elsewhere does not imply no communication occurred. The [memory-tier guide](/journal/fg2-dask-cuda-spill-task-buffer-granularity/) offers adjacent context for distinguishing relocated data from eliminated demand.

## Preserve snapshot and aliasing boundaries

The full optimizer-state documentation warns that returned tensors are not cloned and can alias application state. Define when updates stop, when the returned state is persisted and when mutation may resume. An asynchronous writer must not silently observe tensors changing under it. Keep file publication separate from state extraction. A populated dictionary is not yet a validated durable checkpoint, and a successfully written model file does not automatically include optimizer, data-loader or random-generator state needed for the next update.

## Verify participation and restored meaning

Use a disposable sharded model with recognizable optimizer state. Have every required rank enter the named gather, inspect populated versus empty outputs and save only from the intended writer. Restore through the supported path and verify the declared state inventory and a meaningful continuation. The [distributed checkpoint reference](https://docs.pytorch.org/docs/2.15/distributed.checkpoint.html) describes a different set of save/load contracts, including rank consistency requirements; switching to that family requires reviewing those contracts instead of retaining assumptions from local serialization.

## Keep the migration claim narrow

The API used here is not a recommendation to adopt a legacy interface over the runtime's current recommended checkpoint path. Preserve deprecation and compatibility information when selecting an implementation. Acceptance means the named operation has correct participants, coherent extracted state and validated persistence. It does not establish automatic conversion between FSDP representations, crash durability of any filesystem or complete application recovery from a rank-only file merely because gathering eventually returned without an error.
