Repository navigation
Conversation
Fixes deepspeedai#8952. Human-reviewed AI-assisted fix; validation is documented in the pull request. 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. |
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.
Fixes #8952.
Repeated conversion into one output directory can leave a stale index that selects the previous checkpoint, even when the newly written single file contains the correct weights. This fix keeps the directory consistent with the successful latest export.
Change
After all new shards and the optional index have been written, remove obsolete standard converter output names: the PyTorch/safetensors single files, indexes and exactly numbered shard filenames. Preserve the files in the new export, unrelated configuration/tokenizer/backup files, and directories.
Both serialization formats are considered: retaining old safetensors while writing new PyTorch weights (or vice versa) can let format preference select stale weights. No general prefix deletion or directory clearing is used.
The existing converter and tutorial document replacement behavior. Users retaining multiple variants should use separate output directories.
This does not make export transactional: a failed write may already have overwritten same-name files. Cleanup does not begin until serialization/index writing succeeds; concurrent export/loading is outside the supported scenario. No checkpoint input format, dtype conversion, reconstruction algorithm or public signature changes.
Validation
Base:
8d4f29c75f4a4b30d4db00a94b4aebfdff5107f3.Linux x86_64; Python 3.11.15; torch 2.12.1+cu126; huggingface_hub 1.31.0; safetensors 0.8.0; RTX 3090 (up to two GPUs used), CUDA runtime 12.6, driver 580.178.04.
19 passed on CPU/Gloo and 19 passed on GPU/NCCL. New real-engine checkpoint regressions exercise both output formats, sharded→single, single→sharded, changed shard count, format switches, unrelated-file/directory preservation, and exact values from an independent directory loader.
Additional standalone GPU smoke: two actual optimizer steps and two checkpoints with FP32 ZeRO-3 on two GPUs. Sharded FP32 old checkpoint → unsharded BF16 new checkpoint failed before the fix for both formats (max weight error 0.08115236461162567); both pass afterward with zero error against the BF16-rounded latest snapshot. The same fixed smoke passes for ZeRO-2 on two GPUs, both formats. The small CPU public-API reproduction changes from loading all 1s to the requested all 2s.
All applicable pre-commit hooks pass on the three changed files:
After committing,
python ci/tests_fetcher.py --base origin/masterselected 3 test files in itstests/unit/v1scope. This is a selection preview, not executed upstream CI; the targeted regression commands above provide the local validation.No full DeepSpeed suite, multi-node, CPU/NVMe offload, tensor/pipeline parallelism, MoE or concurrent-writer validation. No performance, memory or convergence claim: the fix changes output artifact selection, not tensor arithmetic.
Sibling paths and duplicate check
The legacy FP32 API and dtype-selectable API/CLI share this output writer. ZeRO-1/2 use one reconstruction path and ZeRO-3 another before converging here. Both output formats are covered. In-memory recovery APIs are unchanged.
No matching open replacement fix was found in live issue/PR searches. #8376 covers tied safetensors, #8378 frozen dtype, #8530 debug behavior, #8681 BF16 stage 0, #8901 legacy serialization, and #6655 reconstruction parallelism. #8501 concerns source-tag selection, while this bug is stale output selection; #8502 concerns loading full training state. None of those changes is included here.
AI assistance was used for investigation, implementation.