Repository navigation
Recover legacy Torch checkpoints in zero_to_fp32 - #8901
Draft
Levius-Fubuki wants to merge 1 commit into
Draft
Levius-Fubuki wants to merge 1 commit into
Levius-Fubuki wants to merge 1 commit into
Conversation
Signed-off-by: levius <2114377220@qq.com>
This was referenced Oct 30, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Valid ZeRO checkpoints saved with
"checkpoint": {"checkpoint_serialization": false}fail inzero_to_fp32becauseparse_optim_statesunconditionally passesmmap=Truetotorch.load, which rejects legacy Torch serialization.Select mmap per optimizer shard using the standard-library ZIP detector. ZIP checkpoints retain the existing mmap path; legacy checkpoints use regular CPU loading. No source checkpoint rewrite, API/configuration change, or broad exception fallback is added. Legacy files cannot be memory-mapped and may require substantially more host memory; no speed or peak-memory improvement is claimed.
The regression writes real files with
TorchCheckpointEnginefor ZeRO-1/2/3 and legacy, ZIP, and mixed-shard serialization. Public eager/lazy recovery and indexed, sharded FP32 export must exactly match the original small tensors, including uneven partition padding.Validation: one Apple M3 CPU (8 cores), 16 GiB RAM, macOS 15.1 arm64; Python 3.12.14, torch 2.14.1, DeepSpeed source
fb5e960b(0.19.9+fb5e960b).DS_ACCELERATOR=cpu, CPU/Gloo; no GPU/accelerator driver used.DS_ACCELERATOR=cpu OMP_NUM_THREADS=1 PYTHONPATH=.:tests python -m pytest \ tests/unit/checkpoint/test_convert_checkpoint.py -k 'not TestCheckpointConvert' \ tests/unit/utils/test_get_optim_files.py --torch_ver=2.14 -q pre-commit run --files deepspeed/utils/zero_to_fp32.py tests/unit/checkpoint/test_convert_checkpoint.pysave_checkpoint(zero_to_fp32.pyandzero_to_torch.py) pass on legacy and ZIP ZeRO-3 checkpoints: 4 CLI checks.This restores compatibility with an existing serialization option. #6658 introduced mmap-based recovery; open #8376 concerns tied safetensors, #8378 frozen-parameter dtype, #8530 debug mode, #8681 ZeRO-0, and #6655 parallel conversion; none addresses this legacy-load failure.
zero_to_torchdelegates to this converter and benefits from the same fix. The universal converter and runtime Torch loader use ordinarytorch.loadand do not share this unconditional-mmap defect.Scope: local CPU/offline conversion with two DP shards and FP32 training masters. GPU training, offload, MoE/TP/PP and other accelerators were not validated. No training arithmetic or convergence change is introduced. AI assistance was used for investigation, implementation, testing and review.
The human submitter reviewed every changed line, ran the relevant tests, and confirmed the DCO signoff.
Local recheck on 2026-10-28, unchanged head
5e8d9e1f: Apple M3/macOS ARM64, Python 3.12.13, torch 2.14.1, CPU; the conversion and optimizer-file suites above report 23 passed, 7 deselected, and all applicable changed-file pre-commit hooks pass. No additional GPU validation is claimed.