KEMBAR78
Fix batch size in evaluation loop by sgugger · Pull Request #16763 · huggingface/transformers · GitHub
Skip to content

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.

@sgugger sgugger requested a review from LysandreJik April 13, 2022 17:16
@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?

# 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
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