Handle prompt embedding concat in Qwen dreambooth example#13387
Open
chenyangzhu1 wants to merge 6 commits intohuggingface:mainfrom
Open
Handle prompt embedding concat in Qwen dreambooth example#13387chenyangzhu1 wants to merge 6 commits intohuggingface:mainfrom
chenyangzhu1 wants to merge 6 commits intohuggingface:mainfrom
Conversation
sayakpaul
reviewed
Apr 3, 2026
| return prompt_embeds_mask.to(device=prompt_embeds.device) | ||
|
|
||
|
|
||
| def _pad_prompt_embedding_pair( |
Member
There was a problem hiding this comment.
Would maybe also add a comment on how this is only relevant during prior preservation.
Author
There was a problem hiding this comment.
Done.
I added the following comment
# These helpers only matter for prior preservation, where instance and class prompt
# embedding batches are concatenated and may not share the same mask/sequence length.
Member
|
@bot /style |
Contributor
|
Style bot fixed some files and pushed the changes. |
|
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. |
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?
When running the
train_dreambooth_lora_qwen_image.pyscript with the--with_prior_preservationflag, the training crashes during the text embedding extraction phase. Fixing two distinct bugs related to tensor concatenation at L1323 and L1324.Solution
To resolve these issues, the tensor concatenation logic needs to handle dynamic padding and missing masks dynamically:
None), reconstruct it as an all-ones tensor based on its corresponding embedding's sequence length.None: After concatenation, if the merged mask consists entirely of 1s, fold it back toNone.Fixes #13386
Before submitting
train_dreambooth_lora_qwen_image.pycrashes with--with_prior_preservationdue to tensor concatenation errors #13386documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul
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.