-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Fix QwenImage txt_seq_lens handling #12702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. |
|
just a few comments, not a full review:
|
| raise ValueError(f"`txt_seq_lens` must have length {batch_size}, but got {len(txt_seq_lens)} instead.") | ||
| text_seq_len = max(text_seq_len, max(txt_seq_lens)) | ||
| elif encoder_hidden_states_mask is not None: | ||
| text_seq_len = max(text_seq_len, int(encoder_hidden_states_mask.sum(dim=1).max().item())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works if the attention mask is in the form of [True, True, True, ..., False, False, False]. While this is the case in the most common use case of text attention masks, it doesn't have to be the case.
If the mask is [True, False, True, False, True, False], self.pos_embed receives an incorrect sequence length
|
thanks @dxqb the idea was to remove |
What does this PR do?
txt_seq_lensplumbing from all QwenImage pipelines and modular steps; the transformer now infers text length from encoder inputs/masks and validates optional overrides.encoder_hidden_states_maskinside the double-stream attention, avoiding fullseq_len²masks while keeping padding tokens masked.txt_seq_lensvalues and encoder masks are handled safely.Fixes #12344
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.