-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
enable low-precision pipeline #31625
Conversation
Related to #31342 but I dont quite get your changes - what exactly does it fix? When I tested all the pipelines in fp16 none of them had issues outputting logits |
Hi @aliencaocao , FP16 works fine but BF16 is not acceptable for numpy, you can see: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addding this @jiqing-feng ! Left a few comments ! Nice tests =)
Hi @SunMarc. I have fixed all your comments; please review them. BTW, the failed tests are due to the connection error, not related to my changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating ! Just a few nits !
Co-authored-by: Marc Sun <[email protected]>
Co-authored-by: Marc Sun <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating @jiqing-feng !
Hi @amyeroberts , would you please review this PR? Thx! |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Hi @amyeroberts . I have passed all tests, do you mind take a review and merge it? Thx! |
Hi @amyeroberts . This PR should be ready to merge, please take a review, thx! |
Hi @jiqing-feng, thanks for opening this PR! I'll get to reviewing it soon, but will likely be in a few days. |
Hi @amyeroberts . Do you mind reviewing this PR? Thx. |
Hi @amyeroberts . Do you think it could be merged? |
@amyeroberts , could you help review this PR? Thx. |
@SunMarc , do you have a suggestion any other people from HF can help review and merge this PR? Seems @amyeroberts has no bandwidth on this these serval months. Thx. |
Sorry for the delay @yao-matrix! @Rocketknight1 is managing the pipeline; Matt, would you mind reviewing this PR when you have a second? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this PR seems good to me! However, I prefer if outputs.dtype in (torch.bfloat16, torch.float16)
rather than if outputs.dtype == torch.bfloat16
, so we can catch float16
as well.
Other than that, I'm happy with it!
if self.framework == "pt" and outputs.dtype == torch.bfloat16: | ||
# To enable using bf16 | ||
outputs = outputs.float().numpy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a regression to me! The previous code worked with both torch.bfloat16
and torch.float16
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Rocketknight1 , thanks for your review, I have fixed it by your comments. |
Hi @Rocketknight1 , do you mind helping to re-run the tests? Thx. |
Hi @jiqing-feng, another PR at #33554 touched the same files. I'm sorry - I didn't realize that it was doing the same thing as this PR! That PR has been merged, so I've merged this PR with the code there to avoid conflicts. |
@jiqing-feng tests pass now and this looks good - are you okay for us to merge it? Also cc @LysandreJik for final review, but no rush! |
Yes, please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me! Thank you @jiqing-feng!
* enable low-precision pipeline * fix parameter for ASR * reformat * fix asr bug * fix bug for zero-shot * add dtype check * rm useless comments * add np.float16 check * Update src/transformers/pipelines/image_classification.py Co-authored-by: Marc Sun <[email protected]> * Update src/transformers/pipelines/token_classification.py Co-authored-by: Marc Sun <[email protected]> * fix comments * fix asr check * make fixup * No more need for is_torch_available() --------- Co-authored-by: Marc Sun <[email protected]> Co-authored-by: Matt <[email protected]> Co-authored-by: Matt <[email protected]>
Hi @amyeroberts @Narsil .
As the previous PR #31444 mentioned, it could enable low-precision pipelines by converting the outputs to
float()
. I followed the codes in here. Do you mind taking a review? Thx!