[blip-2] Fix dtype mismatch when keep in fp32 #37068
Merged
zucchini-nlp merged 4 commits intohuggingface:mainfrom Mar 28, 2025
Merged
[blip-2] Fix dtype mismatch when keep in fp32 #37068zucchini-nlp merged 4 commits intohuggingface:mainfrom
zucchini-nlp merged 4 commits intohuggingface:mainfrom
Conversation
Contributor
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
9 tasks
hmellor
approved these changes
Mar 28, 2025
Member
hmellor
left a comment
There was a problem hiding this comment.
LGTM!
I have confirmed that the vLLM test now passes on the latest commit of this PR 🚀
ArthurZucker
approved these changes
Mar 28, 2025
Collaborator
ArthurZucker
left a comment
There was a problem hiding this comment.
Let's add a test please! 🤗
Member
Author
|
Test is already added, slow tests were failing on |
Collaborator
|
Let's merge then! |
ArthurZucker
pushed a commit
that referenced
this pull request
Mar 28, 2025
* fix fp32 BLIP2 * no need to reorder that * check for `Noneness` as well before casting dtype
4 tasks
zucchini-nlp
added a commit
to zucchini-nlp/transformers
that referenced
this pull request
May 14, 2025
* fix fp32 BLIP2 * no need to reorder that * check for `Noneness` as well before casting dtype
soghomon-b
pushed a commit
to soghomon-b/transformers
that referenced
this pull request
Aug 24, 2025
* fix fp32 BLIP2 * no need to reorder that * check for `Noneness` as well before casting dtype
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.
What does this PR do?
Seems that BLIP2
keep_in_fp32_moduleswas not picking up correctly until 36722 (thus no errors up to today). Now that thequery_tokensare actually kept in 32, we are getting dtype mismatch error in inference. (reported by @hmellor)This PR fixes by casting inputs to correct dtypes, and keeping
qformerinfp32as well. The fix was tested with slow BLIP-2 tests and vLLM tests