set_ip_adapter_scale(float) raises "Cannot assign 1 scale_configs to 2 IP-Adapter" when several IP-Adapters are loaded

Aberta Para iniciantes
#15,210 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python, pytorch
Domínio
machine-learning

Direção de pesquisa

Leia set_ip_adapter_scale em IPAdapterMixin e ModularIPAdapterMixin, além de FluxIPAdapterMixin.set_ip_adapter_scale, para conhecer o comportamento de difusão existente. A issue identifica a ordem da verificação de comprimento e fornece uma pequena reprodução com um pipeline; adicione testes para passar um float com dois adapters de teste carregados e confirme que a escala é aplicada a ambos.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Describe the bug

With more than one IP-Adapter loaded, set_ip_adapter_scale(0.6) raises ValueError: Cannot assign 1 scale_configs to 2 IP-Adapter. instead of applying the scale to every adapter. A list with one value per adapter works.

set_ip_adapter_scale already has a branch meant to repeat a single config for every adapter (elif len(scale_configs) == 1: scale_configs = scale_configs * len(attn_processor.scale)), but it comes after the length check, so it never runs. A single float was broadcast before #7668, and the Flux version (FluxIPAdapterMixin.set_ip_adapter_scale) still broadcasts it. The same code is in ModularIPAdapterMixin.set_ip_adapter_scale.

I'd like to send a PR that checks the single-config case first (a two-line swap in both mixins) plus a test.

Reproduction

Shown with the tiny test pipeline and two test IP-Adapters so it runs in seconds; it goes through the same set_ip_adapter_scale code as load_ip_adapter("h94/IP-Adapter", ...) with two weight_names on SD1.5.

# Run from the root of a diffusers checkout (uses the test helpers for a tiny pipeline and IP-Adapter weights).
from tests.models.unets.test_models_unet_2d_condition import create_ip_adapter_state_dict
from tests.pipelines.stable_diffusion.test_stable_diffusion import StableDiffusionPipelineTesterConfig

cfg = StableDiffusionPipelineTesterConfig()
pipe = cfg.pipeline_class(**cfg.get_dummy_components())
state_dicts = [create_ip_adapter_state_dict(pipe.unet) for _ in range(2)]
pipe.load_ip_adapter(state_dicts, subfolder=["", ""], weight_name=["", ""], image_encoder_folder=None)

pipe.set_ip_adapter_scale([0.6, 0.6])  # works
pipe.set_ip_adapter_scale(0.6)  # ValueError
Context

I found this while testing set_ip_adapter_scale with two IP-Adapters loaded.

Logs
ValueError: Cannot assign 1 scale_configs to 2 IP-Adapter.
System Info
- 🤗 Diffusers version: 0.42.0.dev0 (main @ 84532a058)
- Platform: macOS-26.6.2-arm64-arm-64bit
- Running on Google Colab?: No
- Python version: 3.12.11
- PyTorch version (GPU?): 2.15.0 (False)
- Huggingface_hub version: 2.4.0
- Transformers version: 5.22.2
- Accelerate version: 1.15.0
- PEFT version: 0.21.2
- Safetensors version: 0.8.0
- xFormers version: not installed
- Accelerator: Apple M5 Pro
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No
Who can help?

@asomoza @yiyixuxu

Linguagem predominante
Python
Estrelas
34.9k
Forks
7.5k
Merge médio
2d 16h
PRs com merge (30d)
57

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de huggingface/diffusers

Todas as issues de huggingface/diffusers

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.