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

Fix TrainingArguments regression with torch <2.0.0 for dataloader_prefetch_factor #29447

Conversation

ringohoffman
Copy link
Contributor

@ringohoffman ringohoffman commented Mar 5, 2024

What does this PR do?

dataloader_prefetch_factor was added to TrainingArguments in #28498 with the default value None, but versions of torch<2.0.0 do not accept None and will raise an error if num_workers == 0 and prefetch_factor != 2

Fixes https://discuss.huggingface.co/t/prefetch-factor-issue/74367/4

Also remove a superfluous check that duplicates the <2.0.0 check and the >=2.0.0 check.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@muellerz @amyeroberts

…fetch_factor

dataloader_prefetch_factor was added to TrainingArguments in huggingface#28498 with the default value None, but  versions of torch<2.0.0 do not accept None and will raise an error if num_workers == 0 and prefetch_factor != 2
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding!

Just some small comments

src/transformers/training_args.py Outdated Show resolved Hide resolved
src/transformers/training_args.py Outdated Show resolved Hide resolved
add back check for dataloader_prefetch_factor
@ringohoffman
Copy link
Contributor Author

🤔 these failures seem unrelated?

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for iterating!

Normally, I would say we should avoid conditional defaults, but as this keeps the behaviour backwards compatible with torch >= 2 I think the solution is acceptable

@amyeroberts amyeroberts merged commit 2890116 into huggingface:main Mar 6, 2024
21 checks passed
@ringohoffman ringohoffman deleted the add-torch-1.X-backwards-compatibility-prefetch_factor branch March 6, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants