Added support for bfloat16 to zero-shot classification pipeline#33554
Merged
Rocketknight1 merged 3 commits intohuggingface:mainfrom Sep 18, 2024
Merged
Added support for bfloat16 to zero-shot classification pipeline#33554Rocketknight1 merged 3 commits intohuggingface:mainfrom
Rocketknight1 merged 3 commits intohuggingface:mainfrom
Conversation
Member
Rocketknight1
left a comment
There was a problem hiding this comment.
Hey, the idea looks good but remember that this code can also run TensorFlow pipelines! I added a suggestion where we gate your line behind if self.framework == "pt", which should make the tests pass. I also used .float() so we can avoid the import torch at the top, which causes TF problems again.
Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
Contributor
Author
|
@Rocketknight1 Makes sense, thanks for the improvements, I've committed them all. |
Rocketknight1
approved these changes
Sep 18, 2024
Member
Rocketknight1
left a comment
There was a problem hiding this comment.
Yes, LGTM now. Thank you for the fix, it's really appreciated!
|
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. |
BernardZach
pushed a commit
to BernardZach/transformers
that referenced
this pull request
Dec 5, 2024
…ingface#33554) * Added support for bfloat16 to zero-shot classification pipeline * Ensure support for TF. Co-authored-by: Matt <Rocketknight1@users.noreply.github.com> * Remove dependency on `torch`. Co-authored-by: Matt <Rocketknight1@users.noreply.github.com> --------- Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #33386 and adds support for models that output logits in
torch.bfloat16in the zero-shot classification pipeline by casting logits totorch.float32before they are converted tonumpyfloats (instead of attempting a direct conversion, which is currently not possible and raisesTypeError: Got unsupported ScalarType BFloat16).@Rocketknight1