Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix batch size in evaluation loop #16763

Merged
merged 2 commits into from
Apr 14, 2022
Merged

Fix batch size in evaluation loop #16763

merged 2 commits into from
Apr 14, 2022

Conversation

sgugger
Copy link
Collaborator

@sgugger sgugger commented Apr 13, 2022

What does this PR do?

The batch size used in the evaluation loop is wrong: it's using the per device batch size, which is different from the actual batch size when using DataParallel with more than one GPU. As a result, the test_evaluate test is failing for 2 GPUs (see #16716).

This PR fixes that.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 13, 2022

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

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Nice catch! Is the print intended?

@@ -2548,6 +2548,7 @@ def evaluation_loop(
# Number of losses has been rounded to a multiple of batch_size and in a distributed training, the number of
# samplers has been rounded to a multiple of batch_size, so we truncate.
if all_losses is not None:
print(all_losses)
Copy link
Member

Choose a reason for hiding this comment

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

Debug statement?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops! Thanks for catching.

@sgugger sgugger merged commit b151ddb into main Apr 14, 2022
@sgugger sgugger deleted the batch_size_eval branch April 14, 2022 13:22
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
* Fix batch size in evaluation loop

* remove debug statement
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants