fix: resolve issue #13811#13813
Conversation
|
@sayakpaul Could you please review this PR? It follows up on #12855. Thanks a lot! |
|
@askserge could you do a review? |
There was a problem hiding this comment.
🤗 Serge says:
The fix is correct and well-motivated. _prepare_image_ids is designed to take a list of conditioning images for the same sample (each getting a unique T-coordinate offset: 10, 20, 30…). The old code incorrectly split the batch dimension into this list, causing batch element 0 to get T=10 and batch element 1 to get T=20, when they should all share the same T=10 coordinate structure.
The fix passes only the first batch element [cond_model_input[0:1]] to produce a single (1, H*W, 4) ID tensor, then .expand()s it across the batch — matching the pipeline's own pattern (which uses .repeat(batch_size, 1, 1) at line 683 of pipeline_flux2.py). Using .expand() instead of .repeat() is fine since the IDs are read-only downstream.
No issues found.
7 LLM turns · 7 tool calls · 29.0s · 59557 in / 1233 out tokens
|
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. |
|
@sayakpaul I have fixed the code formatting issues and also updated the same problem in |
What does this PR do?
Fixes #13811
I found an issue in the cond ids processing in train_dreambooth_lora_flux2_img2img.py in diffusers 0.38.0, around lines 1703-1709 of the package. This issue also exists in the main branch.
With the original code:
When batch size is 2, the output cond_model_input_ids looks like this:
However, cond ids within the same batch should not be different.
Flux2Pipeline._prepare_image_ids is designed for multiple conditioning images from the same sample.
With the fixed code:
The output becomes correct (same cond ids for the whole batch):
I'm sorry if I have misunderstood the underlying logic.
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.