Fix Flux2 DreamBooth prior preservation prompt repeats#13415
Open
azolotenkov wants to merge 1 commit intohuggingface:mainfrom
Open
Fix Flux2 DreamBooth prior preservation prompt repeats#13415azolotenkov wants to merge 1 commit intohuggingface:mainfrom
azolotenkov wants to merge 1 commit intohuggingface:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a prior-preservation batch size mismatch in the Flux2 DreamBooth LoRA training example scripts by adjusting how many times static text embeddings are repeated when --with_prior_preservation is enabled.
Changes:
- Adjust
num_repeat_elementsto uselen(prompts) // 2under--with_prior_preservation(sincecollate_fndoubles prompts). - Apply the same fix to both Flux2 DreamBooth LoRA variants (standard + klein).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/dreambooth/train_dreambooth_lora_flux2.py | Fixes prompt-embed repeat count for prior preservation when using static (non-custom) prompts. |
| examples/dreambooth/train_dreambooth_lora_flux2_klein.py | Same repeat-count fix in the klein variant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
27c01ea to
b6cb7b1
Compare
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 prior-preservation batch size mismatch in the
Flux2 DreamBooth LoRAscripts.When custom instance prompts are not used,
prompt_embedsalready contains concatenated instance + class embeddings under--with_prior_preservation, butcollate_fnalso doublesprompts, so repeating bylen(prompts)over-expands text embeddings by 2x and no longer matches the latent batch size.This applies the same fix pattern as #13396 to:
train_dreambooth_lora_flux2.pytrain_dreambooth_lora_flux2_klein.pyBefore submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul