FLUX Speed Improvements (~10% speedup) #7399
Merged
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.
Summary
This PR includes several small speed improvements to FLUX inference:
torch.nn.functional.rms_norm(...)
rather than the custom implementationapply_rope(...)
.view(...)
over.reshape(...)
to be sure that the underlying tensor data is contiguous and shared.After these changes, some operations are now run at a lower precision than before, which results in slight differences in the generated images.
Speedup
Configuration: 1024x1024, 15 steps
Before:
After:
Image Change
Left=before, Right=after
Prompt: "An architecture rendering of the reception area of a corporate office with modern decor."
Prompt: "A pixar cartoon rendering of a frog with big eyes watching a frog."
Prompt: "A portrait photo of a man with blonde hair and glasses wearing a suit and tie."
QA Instructions
Checklist
What's New
copy (if doing a release after this PR)