fix: preserve incomplete flash checkpoints - #9963
Open
LeterTao wants to merge 1 commit into
Open
Conversation
Collaborator
|
Hi, thanks for your contribution! Can you check if this PR works in your scenario:https://github.com/modelscope/ms-swift/pull/9990/changes#diff-52addf56cb07f73a14e0e9c60c0f533c601ff29e09b7e22b8540fc93bb851d70R727 |
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.
Problem
When Flash Checkpoint is enabled, Swift writes checkpoint metadata such as
trainer_state.jsonbefore calling DLRover to persist the checkpoint.If DLRover returns
success=False, it may only indicate that asynchronouspersistence has not completed yet. However, Swift currently removes the entire
checkpoint directory in this case, deleting
trainer_state.jsonand otheralready-written files.
As a result, checkpoint recovery may fail even though the checkpoint is still
being persisted asynchronously.
Fix
Stop recursively deleting the checkpoint directory when DLRover reports that
the latest checkpoint is not finished.
The existing
dlrover_latest.txtmechanism remains responsible for identifyingthe latest complete checkpoint. Incomplete checkpoint directories are preserved
but are not selected during resume.
Validation
python -m compileall -q swift/trainers/mixin.pygit diff --check