Restore full training state in checkpoint writer engines - #8502
Conversation
Signed-off-by: Rui <1685901819@qq.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 960efec32a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| def load(self, path: str, map_location=None): | ||
| sd = torch.load(path, map_location=map_location) | ||
| sd = torch.load(path, map_location=map_location, weights_only=False) |
There was a problem hiding this comment.
Add the required sign-off trailer
Commit 8f7c35c4db8f386ff9f742234159b9d44ad16b34 is a non-merge commit, but its message contains no Signed-off-by trailer, violating the repository's commit requirements; add the configured author's sign-off before merging.
AGENTS.md reference: AGENTS.md:L8-L8
Useful? React with 👍 / 👎.
FastCheckpointEngineandDecoupledCheckpointEnginecan save complete ZeRO-3 training checkpoints but fail to restore them under PyTorch's default weights-only loader, which rejects DeepSpeed's ownZeroStageEnum.Pass
weights_only=Falsein bothload()methods, matching the existingTorchCheckpointEnginebehavior for trusted complete training checkpoints. The production change is limited to these two calls.Fixes #8500.
Regression coverage
TestCheckpointWriterResumecovers synchronous/asynchronous Python writers and legacy/ZIP serialization. It runs real ZeRO-3 training, saves step 1, and performs the next optimizer step to commit pending asynchronous writes. A fresh engine must restore the saved parameters and step count; its next Adam update must match uninterrupted training with zero tolerance. This checks the observable effect of restoring optimizer state, not only successful deserialization.The asynchronous case uses a real subprocess. The only environment patch supplies the single-node launcher's
CROSS_RANK/CROSS_SIZEvalues.Current-base checks on
71d316d608a56af2fcc27b84b14cf854b7052effplus this fix (2026-09-13):TestOtherOptimizerCheckpoint::test_checkpoint_fp32_optimizer: 1 passed with two ranks.git diff --checkpassed.Run the new regression from the source checkout with its test dependencies installed:
The explicit version options describe the tested PyTorch installation; adjust them for another environment.
Full-model integration evidence
The same production fix was previously tested on base
29d0abbc21f11da806ca14970fa8b3ddb757a152with the complete pretrained Qwen3.5-0.8B language model: 24 decoder layers, 752,393,024 trainable language-model parameters, BF16, ZeRO-3, PyTorch AdamW, sequence length 32, microbatch 1 per GPU. Hardware/software: one/four RTX 3090 24 GiB GPUs, driver 580.173.02, PyTorch 2.12.1+cu126, Transformers 5.10.4, NCCL.Synchronous/asynchronous writer × one/four GPUs gave four baseline deserialization failures and four successful fixed runs. All restored model parameters, the training step count, and all model parameters after the next update matched the uninterrupted reference exactly. These full-model GPU runs used ZIP serialization and excluded the vision branch. Current-base regression results are listed separately above.
Compatibility and scope
Full pickle deserialization requires self-produced or otherwise trusted checkpoints;
weights_only=Falsemust not be treated as safe for untrusted files. This restores the existing complete-checkpoint convention without adding a public API or changing the file format. An allowlist or a tensor/primitive-only format would require a separate compatibility design.#6751 updated other load sites but did not cover these two calls. #7742 addresses asynchronous process reliability, a different failure mode. Multi-node, AIO/GDS, NVMe offload, long-run convergence, and the full DeepSpeed suite were not tested.