fix: reset dataloader index when dataset changes on resume#2519
Merged
yuki-97 merged 3 commits intoMay 21, 2026
Conversation
Contributor
Author
|
/ok to test 410b0f0 |
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 18, 2026 09:54
410b0f0 to
9627592
Compare
Contributor
Author
|
/ok to test 9627592 |
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 18, 2026 10:04
9627592 to
a6fe6ba
Compare
Contributor
Author
|
/ok to test a6fe6ba |
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 18, 2026 14:29
a6fe6ba to
e68e7bc
Compare
Contributor
Author
|
/ok to test e68e7bc |
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 19, 2026 04:24
e68e7bc to
6401a47
Compare
Contributor
Author
|
/ok to test 6401a47 |
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 19, 2026 07:01
7fba4d5 to
f748553
Compare
yuki-97
reviewed
May 19, 2026
yuki-97
left a comment
Contributor
There was a problem hiding this comment.
thanks for helping fix! some comments.
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 20, 2026 09:49
f748553 to
3f26781
Compare
When resuming a single-dataloader run with a different data.train.dataset_name, StatefulDataLoader.load_state_dict() silently skips the first N samples of the new dataset (N = samples_yielded from the previous run), or hard-crashes with StopIteration during iter() if len(new_dataset) <= N. Detect this in load_dataloader_state by reading the previous run's dataset_name out of the sibling config.yaml that the checkpointer already writes alongside train_dataloader.pt. When it differs from the current config, skip the state restore and print a warning so the swap is visible. The on-disk format of train_dataloader.pt is unchanged, so every existing checkpoint is automatically compatible. Applied to GRPO (sync + async), SFT, DPO, RM, Distillation. The multi-dataloader save path is intentionally left untouched in this PR. Signed-off-by: Linglin Jing <linglinj@nvidia.com>
jinglinglingling
force-pushed
the
fix/dataset-swap-skip-load
branch
from
May 20, 2026 09:50
3f26781 to
eaa5a40
Compare
Contributor
Author
|
/ok to test eaa5a40 |
yuki-97
approved these changes
May 21, 2026
yuki-97
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks @jinglinglingling . change to run L1 to make sure resume works well.
Contributor
|
/ok to test fc0138c |
yuki-97
enabled auto-merge (squash)
May 21, 2026 05:23
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.
What does this PR do ?
When resuming a single-dataloader run with a different
data.train.dataset_name,StatefulDataLoader.load_state_dict()silently skips the first N samples of the new dataset (where N =samples_yieldedfrom the previous run), or hard-crashes withStopIterationduringiter()iflen(new_dataset) <= N.This PR tags each
train_dataloader.ptsave with the activedataset_nameand skips the state restore when it differs from the current config, printing a warning so the swap is visible. Legacy saves (raw state dict) are still loaded as before for backward compatibility.Applied to GRPO (sync + async), SFT, DPO, RM, Distillation. The multi-dataloader save path is intentionally left untouched in this PR.
Issues
N/A
Usage
No new API. Behavior is automatic:
Previously, step 2 would silently skip the first N samples of
gsm8k(or crash ifN >= len(gsm8k)). Now the new dataset starts from index 0 and a warning is printed.Before your PR is "Ready for review"
Pre checks:
tests/unit/algorithms/test_sft.py: 5 passedtests/unit/algorithms/test_dpo.py: 4 passedtests/unit/algorithms/test_rm.py: 3 passedtests/unit/algorithms/test_distillation.py: 10 passedtests/unit/algorithms/test_grpo.py: running at PR time, relying on CIAdditional Information
isinstancefallback.{"state": <state>, "dataset_name": <name>}.