-
Notifications
You must be signed in to change notification settings - Fork 31.3k
Correctly support resuming from checkpoint with a dataset without length #33544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Correctly support resuming from checkpoint with a dataset without length #33544
Conversation
|
Very impressive PR @muupan! I'm pinging @muellerzr and @SunMarc to take a look; Zach is off for a few weeks and will take a look as soon as he's back, thank you for your patience 🙏 |
6f83505 to
bc56f1c
Compare
|
It seems like the code got broken after rebasing with main, where #34198 renamed the variable |
|
Let us know when it is done ! |
|
Are you still up to finish the PR @muupan ? Otherwise, I'll add it as a good second issue so the community can pick that up ! |
|
Hi, sorry for the long delay—I’m still interested in finishing this PR. I’ll try fixing it within a week. |
e28dd5c to
82fb75f
Compare
|
@SunMarc I have fixed the rebasing error and added a small fix and comments. It is ready for review. |
82fb75f to
c81d9e1
Compare
c81d9e1 to
0181b10
Compare
What does this PR do?
There is an inconsistency in
Trainer's behavior between training from scratch and resuming from checkpoint when the given dataset has no length likedatasets.IterableDataset. For a reproducible example, see #26413 (comment) . This PR fixes the inconsistency by correctly supporting resuming from checkpoint with such a dataset.Fixes #26413
Current behavior
When training starts with a dataset without length, Trainer assumes one epoch is equal to
max_stepssteps and tries to train for that many steps. There are two possible scenarios.max_stepssteps, Trainer increments the current epoch and re-iterate the dataset.When resuming from a checkpoint, Trainer simply skips the first batches until
global_stepof the checkpoint. In scenario A, there is no problem. In scenario B, the dataset raises StopIteration during the skipping, but Trainer does not re-iterate the dataset. Instead, it just finishes training with a warning. This is inconsistent from what happens in training from scratch, and it contradicts with what the documents aboutmax_stepssays:transformers/src/transformers/training_args.py
Lines 301 to 304 in ac5a055
Solution
This PR modifies the skipping behavior so that Trainer now re-iterates the dataset until it catches up
global_step. A caveat is that it does not support theignore_data_skipoption, as Trainer does not know what epoch to start from. I am also concerned that the logic is becoming too complicated.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@ArthurZucker