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

[Auto Parallel] fix data stream bug of dist.to_static #9077

Merged
merged 1 commit into from
Sep 5, 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
7 changes: 6 additions & 1 deletion paddlenlp/trainer/auto_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ def _wrap_for_auto(self, model, train_dataloader):
if self.args.to_static:
unified_strategy = dist.Strategy()
unified_strategy._from_legacy_strategy(self.args.strategy)
model = dist.to_static(model, dist_loader, self.criterion, self.optimizer, strategy=unified_strategy)
# dist.to_static() obtains the input spec information through next(dataloader), but this has side effects
# on the passed-in dataloader, altering the state of the sampler of the dataloader. In some cases, once
# the state of the sampler is changed, it cannot be reverted. Therefore, a temporary dataloader is
# constructed here to avoid side effects on the dataloader used for actual training.
temp_loader = self._wrap_for_dist_loader(self.get_train_dataloader())
model = dist.to_static(model, temp_loader, self.criterion, self.optimizer, strategy=unified_strategy)

self.model_wrapped = model
return model, dist_loader
Expand Down
Loading