Distributed checkpointing

On this page 7

Distributed checkpointing is the practice of saving and restoring the full training state of a model that is sharded across many accelerators, with each process writing and reading its own portion in parallel. In AI infrastructure, it is the mechanism that lets a multi-week training run on thousands of GPUs survive hardware failures, resume after preemption and change cluster size without starting over.

A checkpoint for a large language model contains far more than the weights. It includes optimizer states, learning-rate scheduler position, random number generator states and data loader progress, and for mixed-precision training with Adam the optimizer states alone are often two to three times the size of the weights. Writing that state from a single process would take too long and would not fit in one node’s memory, so the work is distributed.

How distributed checkpointing writes sharded state

Each rank in the job writes only the tensor shards it owns, together with metadata that records which global tensor, offset and shape every shard belongs to. A coordinator, usually rank zero, writes a global metadata file that maps logical parameter names to physical files, so the checkpoint can be reassembled later.

The typical save sequence follows a small number of well-defined phases, and modern frameworks overlap several of them with training to reduce stall time.

PhaseWhat happensTypical cost driver
PlanningRanks agree on which shards each writes and deduplicate replicasNumber of ranks and tensors
StagingShards are copied from GPU memory to host memoryPCIe bandwidth and tensor size
PersistingHost buffers are written to the storage systemStorage throughput and file count
CommitMetadata is finalized and the checkpoint is marked completeCoordination latency
Phases of a distributed save

The commit step is essential for correctness. A checkpoint that lacks a completed metadata record must be treated as invalid, because a crash during persisting can leave some shards written and others missing.

Checkpoint formats and resharding

Checkpoint formats differ mainly in whether they can be loaded on a different parallel layout. This capability, called resharding or topology-independent loading, matters whenever a job restarts on a different number of GPUs or switches between tensor, pipeline and data parallelism settings.

LayoutDescriptionResharding supportTypical use
ConsolidatedOne full state dictionary gathered on one rankEasy but slow to produceSmall models, final export
Rank-local shardedEach rank saves its own shard as-isOnly on the identical topologyFast fault recovery
Topology-independent shardedShards saved with global offsets and metadataLoad on any compatible layoutLarge runs with elastic training
Checkpoint layout options

Frameworks such as PyTorch Distributed Checkpoint, the checkpointing utilities in Megatron-style training stacks and DeepSpeed universal checkpoints implement the topology-independent approach. When FSDP or ZeRO partitions optimizer states, the loader must map each saved shard onto the new partitioning, which requires accurate global offsets in the metadata.

Synchronous, asynchronous and in-memory checkpointing

The main engineering trade-off is between training stall time and recovery guarantees. A synchronous save blocks every rank until data reaches durable storage, which is simple but can pause a large job for minutes.

StrategyTraining stallDurabilityTrade-off
Synchronous to storageFull write durationHigh once completeSimple but slow at scale
Asynchronous to storageOnly the staging copyHigh after background writeNeeds spare host memory
In-memory peer replicationSecondsSurvives single-node lossLost if many nodes fail
TieredSeconds for frequent savesCombines both levelsMore complex orchestration
Checkpointing strategies compared

Asynchronous checkpointing is now the common default for large runs: training resumes once tensors are copied to pinned host memory, and a background thread persists them. Tiered schemes keep frequent in-memory snapshots for fast recovery and less frequent durable copies on a parallel file system or object storage.

Choosing checkpoint frequency and storage

Checkpoint interval is a cost optimization between lost work and save overhead. A widely used first-order approximation, attributed to Young and Daly, sets the optimal interval near the square root of two times the save cost times the mean time between failures.

  • Measure the mean time between failures of the actual cluster, because it falls as the GPU count grows.
  • Measure the true stall time per save, not only the total write time.
  • Size storage for burst bandwidth, since thousands of ranks write simultaneously.
  • Keep several recent checkpoints, because the newest one may contain corrupted state or a loss spike.
  • Prefer fewer, larger files on object storage to avoid metadata bottlenecks.

On clusters with thousands of accelerators, failures can occur several times per day, so intervals of tens of minutes are common for frontier training, while smaller jobs may save every few hours.

Failure modes and verification

Most checkpoint incidents come from incomplete, inconsistent or unverified saves rather than from the storage system itself. A recovery path that has never been exercised should be considered untested and unreliable.

SymptomLikely causeMitigation
Load fails with missing shardsCrash before commitAtomic commit marker and retention of prior checkpoint
Loss jumps after resumeData loader or RNG state not restoredSave sampler position and seeds
Save stalls the clusterStorage bandwidth saturatedAsynchronous writes and staggered persistence
Cannot resume on new GPU countRank-local formatTopology-independent format
Common problems

Mature teams run regular restore drills and compare the loss curve after resume with the uninterrupted run, which confirms that the training trajectory is bit-for-bit or statistically identical.

Stripped to the essentials

Training a large AI model can take weeks on thousands of chips. Sooner or later, one of those chips breaks. Without a saved copy, all that work would be lost.

Distributed checkpointing is a regular save point for the whole job. Each chip saves its own piece at the same time, like a team where every member files their own pages. A shared index records where every piece belongs. After a crash, the job reloads the pieces and continues from the last save.

Where it is applied

A research team trains a 70-billion-parameter language model on 1,024 GPUs using tensor, pipeline and data parallelism. With Adam optimizer states in mixed precision, one checkpoint is close to one terabyte. Early in the run, the cluster loses a node roughly twice a day.

The team configures asynchronous sharded checkpoints every 30 minutes to in-memory peer replicas and a durable copy to object storage every two hours. Each save now stalls training for about ten seconds instead of several minutes.

When a network switch fails and 64 GPUs drop out, the job restarts on 960 GPUs with a smaller data-parallel degree. Because the format is topology-independent, the loader reshards the state automatically, and the run loses under half an hour of progress.