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

Add mixed precision evaluation #8036

Merged
merged 2 commits into from
Oct 26, 2020
Merged

Add mixed precision evaluation #8036

merged 2 commits into from
Oct 26, 2020

Conversation

luyug
Copy link
Contributor

@luyug luyug commented Oct 25, 2020

What does this PR do?

Add flag and code to do mixed precision forward in trainer's prediction_step function.
Let evaluation (and prediction) to run faster.

Who can review?

@sgugger

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.

Thanks for the PR! It's very clean for mixed-precision with torch >= 1.6! Two things though, I don't think we should add another argument and just use the existing fp16 parameter for this. With torch <= 1.5 and the flag fp16 passed, the model will be in FP16 precision, so evaluation is done in FP16.

@luyug
Copy link
Contributor Author

luyug commented Oct 26, 2020

I see your point; Apex will take care of the other case. Updated!

@luyug luyug requested a review from sgugger October 26, 2020 06:04
@sgugger sgugger merged commit c153bcc into huggingface:master Oct 26, 2020
@sgugger
Copy link
Collaborator

sgugger commented Oct 26, 2020

Thanks!

fabiocapsouza pushed a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
* Add mixed precision evaluation

* use original flag
fabiocapsouza added a commit to fabiocapsouza/transformers that referenced this pull request Nov 15, 2020
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.

None yet

2 participants