ZImageTransformer2D: Only build attention mask if seqlens are not equal#12955
Merged
yiyixuxu merged 1 commit intohuggingface:mainfrom Mar 24, 2026
Merged
ZImageTransformer2D: Only build attention mask if seqlens are not equal#12955yiyixuxu merged 1 commit intohuggingface:mainfrom
yiyixuxu merged 1 commit intohuggingface:mainfrom
Conversation
Member
|
Cc: @JerryWu-code who contributed the model. |
Contributor
Author
|
More relevant with new higher compute model |
Contributor
Author
|
We've been running this in production for Turbo for a while |
02ae19d to
b6d107a
Compare
Contributor
Author
|
👀 |
b6d107a to
83bfc42
Compare
83bfc42 to
85c0e03
Compare
Contributor
|
looks good to me |
85c0e03 to
5fe6bbd
Compare
yiyixuxu
approved these changes
Mar 24, 2026
Collaborator
yiyixuxu
left a comment
There was a problem hiding this comment.
thanks
sorry this slipped through
|
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. |
dxqb
added a commit
to Nerogar/OneTrainer
that referenced
this pull request
Mar 24, 2026
speeds up Z-image by up to 25% because of huggingface/diffusers#12955 it speeds up attention, so the most benefit get higher resolutions. speed-up for 512px is not that much.
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?
Fixes a small performance regression for Z Image Turbo.
Basically just sets attn_mask to None when it would otherwise be all ones, which is always the case for Z Image Turbo where guidance_scale==1 for typical usage.
On an H100 this improves performance by about 4%, using AttentionBackendName._NATIVE_CUDNN.
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@yiyixuxu or @sayakpaul probably