Fix incorrect batch temporal IDs for cond_model_input in Flux2 Klein img2img training#13923
Merged
sayakpaul merged 1 commit intoJun 12, 2026
Conversation
…n img2img training `train_dreambooth_lora_flux2_klein_img2img.py` passed the whole batch to `Flux2KleinPipeline._prepare_image_ids` as a list of reference images, so each independent training sample got a different temporal id (T=10, 20, 30, ...) as if they were multiple references of one instance. Each batch element is an independent sample with a single conditional image, so they must share the same temporal id. Generate ids for one sample and expand across the batch. This is the Flux2 Klein counterpart of the same bug/fix in `train_dreambooth_lora_flux2_img2img.py` (huggingface#13811). Fixes huggingface#13866
sayakpaul
approved these changes
Jun 12, 2026
|
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. |
Member
|
Failing tests are unrelated. |
DN6
pushed a commit
that referenced
this pull request
Jul 1, 2026
…n img2img training (#13923) `train_dreambooth_lora_flux2_klein_img2img.py` passed the whole batch to `Flux2KleinPipeline._prepare_image_ids` as a list of reference images, so each independent training sample got a different temporal id (T=10, 20, 30, ...) as if they were multiple references of one instance. Each batch element is an independent sample with a single conditional image, so they must share the same temporal id. Generate ids for one sample and expand across the batch. This is the Flux2 Klein counterpart of the same bug/fix in `train_dreambooth_lora_flux2_img2img.py` (#13811). Fixes #13866
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 #13866
train_dreambooth_lora_flux2_klein_img2img.pybuilds the conditional-image position ids wrong for a batch:_prepare_image_idsis meant for multiple reference images of one instance — it assigns each list element a different temporal coordinate (T = scale + scale*i→ 10, 20, 30, …). But here each batch element is an independent training sample with a single conditional image, so they all get spurious cross-sample temporal offsets instead of the sameT.Fix: generate ids for one sample and
expandacross the batch, so every sample sharesT = 10. This is the Flux2 Klein counterpart of the same bug/fix intrain_dreambooth_lora_flux2_img2img.py(#13811).Verification
Flux2KleinPipeline._prepare_image_idson a(3, 4, 4, 4)input (CPU, no weights):Before submitting
Who can review?
@sayakpaul @linoytsaban