Use negative crop coordinates when building SDXL negative time ids - #14676
Open
Devam0311 wants to merge 1 commit into
Open
Use negative crop coordinates when building SDXL negative time ids#14676Devam0311 wants to merge 1 commit into
Devam0311 wants to merge 1 commit into
Conversation
`_get_add_time_ids` accepts `negative_crops_coords_top_left` and the aesthetic-score branch uses it, but the other branch built the negative time ids from `crops_coords_top_left`. Callers asking for different positive and negative crop conditioning silently got the positive coordinates in both, so negative micro-conditioning was wrong. Fixed in the SDXL img2img and inpaint pipelines, the modular SDXL img2img conditioning step, and the five pipelines that carry this method via `# Copied from`. Add a regression test asserting the negative time ids carry the negative crop coordinates. Ref huggingface#13610 (Issue 2) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XBYeq5vB4DNZDEaqUsroKR
This was referenced Sep 1, 2026
Contributor
|
Hi @Devam0311, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an issue (or gets the |
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 Issue 2 of #13610 (
stable_diffusion_xlmodel/pipeline review)._get_add_time_idsacceptsnegative_crops_coords_top_left, and the aesthetic-score branch uses it — but the other branch does not:So anyone requesting different positive and negative crop conditioning silently gets the positive crop coordinates on both branches, and negative micro-conditioning is wrong.
Reproduced on
mainwith the script from the issue:Solution
Use
negative_crops_coords_top_left, matching the aesthetic-score branch directly above it and the separate negative_get_add_time_idscall the text-to-image pipeline already makes.The issue names three files. Five more carry this method through
# Copied from, andutils/check_copies.pyrequires them to match, so all eight are updated together:pipeline_stable_diffusion_xl_img2img.py,pipeline_stable_diffusion_xl_inpaint.py,modular_pipelines/stable_diffusion_xl/before_denoise.py# Copied fromthe abovepipeline_controlnet_sd_xl_img2img.py,pipeline_controlnet_union_sd_xl_img2img.py,pipeline_pag_controlnet_sd_xl_img2img.py,pipeline_pag_sd_xl_img2img.py,pipeline_pag_sd_xl_inpaint.pyTesting
test_get_add_time_ids_uses_negative_crops_coords_top_leftasserts the negative time ids carry the negative crop coordinates.It drives the method through a lightweight stand-in rather than the dummy pipeline, as the issue's own reproduction does. The reason is concrete: this branch emits six time ids instead of five, and the dummy UNet's
add_embedding.linear_1is sized for the five-value aesthetic-score layout, so the real dummy pipeline raises on the embedding-dimension check before reaching the logic under test.Verified it catches the bug: with the fix reverted it fails.
Two sets of pre-existing failures in my environment, both reproducing identically on a clean checkout of
mainand unrelated to this change: theTestStableDiffusionXL*PipelineIPAdapterclasses (aModuleNotFoundErrorfrom an optional dependency I don't have installed), and onebefore_denoise.py_get_add_time_idscopy mismatch againstStableDiffusionXLPipeline— a different method from the one changed here.Before submitting
self-reviewskill on the diff?Self-review notes
Reviewed against
.ai/references/review-rules.mdandpipelines.md. No blocking issues.For the reviewer:
negative_crops_coords_top_lefton a non-aesthetic-score model. That is the point — the old output ignored the argument — but it will move pinned outputs for those callers.# Copied from; touching only the three would breakcheck_copies. Happy to split the copies into a follow-up if you'd rather review them separately.Who can review?
@yiyixuxu @asomoza @hlky