Partially enabled FP16 reasoning in the Qwen Image Models#12522
Open
Icbears wants to merge 2 commits intoComfy-Org:masterfrom
Open
Partially enabled FP16 reasoning in the Qwen Image Models#12522Icbears wants to merge 2 commits intoComfy-Org:masterfrom
Icbears wants to merge 2 commits intoComfy-Org:masterfrom
Conversation
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.
The original reasoning code for Qwen Image models cannot run correctly with float16 precision, which results in completely black outputs:
#10800
#10668
#10751
Because of this limitation, GPUs without native bfloat16 support are forced to run the model in float32, leading to noticeably slower generation.
The attached updated reasoning code enables parts of the attention computation in Qwen Image models to run safely in float16 without producing black images. Specifically, the following components can now use float16: image K, image V, text Q, text V, and the joint cross attention. When bfloat16 is selected, the code automatically falls back to native bfloat16 on supported GPUs.
I tested this improvement on a Tesla V100, and for the Qwen Image Edit 2511 model with 4-steps lora, the second-generation of the image ran in roughly half the time compared with the original implementation. In this test, I edited a 512×512 image. With the original float32‑only code, the second‑generation step took approximately 41 seconds, whereas the proposed float16‑enabled version reduced this to about 23 seconds.


