Skip to content

Add mixed precision evaluation#8036

Merged
sgugger merged 2 commits intohuggingface:masterfrom
luyug:fp16_eval
Oct 26, 2020
Merged

Add mixed precision evaluation#8036
sgugger merged 2 commits intohuggingface:masterfrom
luyug:fp16_eval

Conversation

@luyug
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

sgugger commented Oct 26, 2020

Thanks!

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.

2 participants