Fix stateful dataloader checkpoint cache after loading - #4244
Open
MrCapricornLiu wants to merge 1 commit into
Open
Fix stateful dataloader checkpoint cache after loading#4244MrCapricornLiu wants to merge 1 commit into
MrCapricornLiu wants to merge 1 commit into
Conversation
Signed-off-by: Chenghao Liu <chliu@stu.pku.edu.cn>
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.
Loading a stateful dataloader checkpoint updates the underlying loader but leaves the adapter's cached state unchanged. Saving again before reading another batch therefore writes the previous cursor. A fresh adapter can replay data; an adapter that had advanced further can skip data after restoration.
Refresh the cache after
load_state_dictsucceeds. The regression covers shard, dispatcher and skip loaders with zero or two workers, both fresh and reused adapters, and checks the actual remaining samples after another save/load.Validation: the 12 new cases fail before the fix, and all 49 data-loader tests pass afterward. An
Accelerator.save_state/load_statetraining check passes on CPU and eight H800 GPUs, matching data order and SGD momentum updates against uninterrupted training. Repository Ruff lint/format and applicable pre-commit checks pass.