Skip to content
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

[Bug fix] fix skip consumed_samples twice bug #8980

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion paddlenlp/trainer/auto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from paddlenlp.trainer import Trainer

from ..utils.batch_sampler import DistributedBatchSampler as NlpDistributedBatchSampler

Check warning on line 29 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L29

Added line #L29 was not covered by tests
from ..utils.log import logger
from .argparser import strtobool
from .trainer import SCALER_NAME, SCHEDULER_NAME, TRAINER_STATE_NAME, TRAINING_ARGS_NAME
Expand Down Expand Up @@ -309,12 +310,23 @@

# Skip past any already trained steps if resuming training
# We use consumed_samples to reset the status
if steps_trained_in_current_epoch > 0:
if isinstance(train_dataloader._dataloader, paddle.io.DataLoader) and isinstance(

Check warning on line 313 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L313

Added line #L313 was not covered by tests
train_dataloader._dataloader.batch_sampler, NlpDistributedBatchSampler
):
if step == 0:
if steps_trained_progress_bar is not None:
steps_trained_progress_bar.update(steps_trained_in_current_epoch)
steps_trained_progress_bar.close()
steps_trained_progress_bar = None
self._load_rng_state(resume_from_checkpoint)
step += steps_trained_in_current_epoch
elif steps_trained_in_current_epoch > 0:

Check warning on line 323 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L316-L323

Added lines #L316 - L323 were not covered by tests
steps_trained_in_current_epoch -= 1
if steps_trained_progress_bar is not None:
steps_trained_progress_bar.update(1)
if steps_trained_in_current_epoch == 0:
self._load_rng_state(resume_from_checkpoint)
self.timers and self.timers("read-data").start()

Check warning on line 329 in paddlenlp/trainer/auto_trainer.py

View check run for this annotation

Codecov / codecov/patch

paddlenlp/trainer/auto_trainer.py#L329

Added line #L329 was not covered by tests
continue
elif steps_trained_progress_bar is not None:
steps_trained_progress_bar.close()
Expand Down
Loading