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

update dataloader wrappers to have total_batch_size attribute #493

Merged

Conversation

pacman100
Copy link
Contributor

What does this PR do?

  1. A requirement was to get resulting batch size post accelerator.prepare call. Adding total_batch_size to provide the resulting batch_size across devices.
my_dataloader = accelerator.prepare(my_dataloader)
accelerator.print(f"The resulting batch_size across devices is {my_dataloader.total_batch_size}")

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jul 7, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Sounds like a useful addition, but I'd prefer have this as a property and no new arguments in the init that aren't really used to influence the behavior of the class.

src/accelerate/data_loader.py Outdated Show resolved Hide resolved
src/accelerate/data_loader.py Outdated Show resolved Hide resolved
@pacman100 pacman100 marked this pull request as ready for review July 7, 2022 22:01
@pacman100 pacman100 requested a review from muellerzr July 7, 2022 22:01
Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

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

Very clean!

src/accelerate/data_loader.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@muellerzr muellerzr 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 this! Seems quite useful indeed. My main concern here is that everything is documented properly given we're adding a new property to every dataloader type.

Worrying about the XLA wrapper in the docs is something we can discuss a bit later.

src/accelerate/data_loader.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

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

Great work!

@pacman100 pacman100 merged commit cfb2a3e into huggingface:main Jul 8, 2022
@pacman100 pacman100 deleted the smangrul/dataloader-total-batch-size branch July 8, 2022 15:46
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.

4 participants