Accept tensor ip_adapter_image_embeds in SD3 ControlNet inpainting - #14674
Open
Devam0311 wants to merge 1 commit into
Open
Accept tensor ip_adapter_image_embeds in SD3 ControlNet inpainting#14674Devam0311 wants to merge 1 commit into
Devam0311 wants to merge 1 commit into
Conversation
`StableDiffusion3ControlNetInpaintingPipeline.check_inputs` required `ip_adapter_image_embeds` to be a `list`, but the `__call__` docstring documents a tensor of shape `(batch_size, num_images, emb_dim)` and `prepare_ip_adapter_image_embeds` types it as `torch.Tensor` and calls `.chunk(2)` on it. Passing the documented tensor therefore always failed validation, so precomputed IP-Adapter embeddings could not be used at all. Validate the tensor's rank instead, matching the documented contract. Add regression tests for both the accepted tensor and the rejected rank. Ref huggingface#13611 (Issue 5) 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 5 of #13611.
StableDiffusion3ControlNetInpaintingPipelinecontradicts itself about the type ofip_adapter_image_embeds:__call__docstring (L1111)torch.Tensor… a tensor of shape(batch_size, num_images, emb_dim)"prepare_ip_adapter_image_embeds(L932)torch.Tensor | None, and calls.chunk(2)on itcheck_inputs(L780)listSo passing the documented tensor always failed validation, and precomputed IP-Adapter embeddings could not be used at all. Passing a list to satisfy
check_inputswould then break inprepare_ip_adapter_image_embeds, which calls.chunk(2).The base
StableDiffusion3Pipelinedoes not validate this argument incheck_inputsat all — the list check here appears to be a leftover from the older list-based IP-Adapter API.Solution
Validate the tensor's rank instead of its container type:
Testing
Two tests, driving
check_inputsdirectly:test_check_inputs_accepts_ip_adapter_image_embeds_tensor— the documented 3D tensor now passestest_check_inputs_rejects_ip_adapter_image_embeds_with_bad_ndim— a 2D tensor still raises, with the new messageVerified both catch the bug: with the fix reverted, both fail.
Before submitting
self-reviewskill on the diff?Self-review notes
Reviewed against
.ai/references/review-rules.mdandpipelines.md. No blocking issues.For the reviewer:
listto work around the old check would now fail later insideprepare_ip_adapter_image_embedsrather than early incheck_inputs. I judged that acceptable because the list path was already broken downstream — there is no working list-based caller to preserve — but flagging it since it is technically a behaviour change.ip_adapter_image/ip_adapter_image_embedsmutual-exclusion check above it untouched.Who can review?
@yiyixuxu @asomoza @hlky