mixle.utils.parallel.dcp_checkpoint module¶
Sharded distributed checkpoints via torch.distributed.checkpoint (DCP) – replaces pickle-broadcast at scale.
Note
This is a provisional API with experimental multi-node behavior. Complete-state and failure semantics are covered on CPU; resharding and throughput at multi-node GPU scale still require retained hardware receipts.
The gather-to-root + pickle-broadcast that TorchRunEncodedData uses to move a model cannot save a
model that does not fit (and is not folded on) one rank. DCP saves each rank’s shard of the (FSDP2-sharded) model
+ optimizer state in parallel to a checkpoint directory, and loads it back sharded – the standard frontier
checkpoint, and the resume hook for StreamingTokenEncodedData.
CUDA / multi-GPU path: implemented against the torch 2.4+ DCP and distributed-state-dict APIs, but not verified without retained hardware receipts.
- class AsyncTrainingCheckpoint(future, path, generation, rank, world_size, payload, _complete=False)[source]
Bases:
objectDCP asynchronous save plus atomic sidecar/manifest finalization.
- async_save_training_state(module, optimizer, path, *, step, scheduler=None, scaler=None, loader_state=None, parallel_plan=None, typed_scheduler_state=None, extra=None)[source]
Start DCP’s native async save;
wait()surfaces write failures.
- load_sharded(module, optimizer, path)[source]
Load a sharded checkpoint from
pathintomodule+optimizerin place (resumable training).
- load_training_metadata(path, *, rank_local_transform=None)[source]
Decode metadata without ever assigning an old rank’s local state to a new rank.
- load_training_state(module, optimizer, path, *, scheduler=None, scaler=None, restore_rng=True, allow_world_size_change=False, rank_local_transform=None)[source]
Restore complete training state and return its non-tensor metadata.
- save_frozen_training_state(model_state, optimizer_state, path, *, step, loader_state=None, parallel_plan=None, typed_scheduler_state=None, extra=None)[source]
Transactionally save already-frozen model and optimizer state dictionaries.
- save_sharded(module, optimizer, path)[source]
Save a sharded
(model, optimizer)checkpoint topath– every rank writes its own shard in parallel.
- save_training_state(module, optimizer, path, *, step, scheduler=None, scaler=None, loader_state=None, parallel_plan=None, typed_scheduler_state=None, extra=None)[source]
Synchronously save complete, reshardable training state.