Repository navigation
Conversation
Contributor
|
Hi @sohailshk, thanks for the PR! It does not appear to link an issue it fixes.
See the contribution guide for more details. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an existing issue, the author box is ticked, or the |
This branch has not been deployed
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
set_ip_adapter_scale()raising aValueErrorwhen it is given a single scale while more than one IP-Adapter is loaded.Problem
In
IPAdapterMixin.set_ip_adapter_scaleandModularIPAdapterMixin.set_ip_adapter_scale, a single scale is wrapped into a one-element list and is meant to be broadcast across all loaded IP-Adapters. But the length-mismatch check ran first:With 2 adapters loaded,
len(scale_configs) == 1andlen(attn_processor.scale) == 2, so the first branch always raised and theelifbroadcast branch was unreachable for any case where it was needed (it could only trigger when a single adapter was loaded, where it is a no-op).Passing a list (
[0.5, 0.5]) works, so only the single-scale shorthand was broken.Fix
Swap the order of the two branches so the single-scale broadcast is handled first, and the
ValueErroris only raised for a real mismatch (e.g. 2 scales for 3 adapters). Applied in both places the logic is duplicated insrc/diffusers/loaders/ip_adapter.py(IPAdapterMixinandModularIPAdapterMixin).Behavior is unchanged for lists with a matching length, and for genuine mismatches the same error is still raised.
Tests
tests/pipelines/testing_utils/ip_adapter.py: newtest_ip_adapter_single_scale_multi_adapterin the shared IP-Adapter tester mixin. It loads two adapters, callsset_ip_adapter_scale(0.5), and asserts every IP-Adapter attention processor ends up withscale == [0.5, 0.5]. Every pipeline using the mixin picks it up.tests/modular_pipelines/stable_diffusion_xl/test_modular_pipeline_stable_diffusion_xl.py: the same check for the modular SDXL pipeline.Before submitting
Who can review?
@yiyixuxu @sayakpaul