Flux Control and HunyuanVideo LoRA converters swap the scale/shift halves of `lora_A` in `final_layer`
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Área
- machine-learning, testing
Línea de trabajo
Read loaders/lora_conversion_utils.py and the existing test_lora_bfl_final_layer_modulation test. The issue identifies both affected converters and proposes one test per converter, checking that only lora_B is swapped; run those tests to confirm the converted delta matches the expected scale/shift order. A pull request is already open for this issue.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
final_layer.adaLN_modulation.1 in the original checkpoints orders its output (shift, scale), and diffusers' norm_out.linear orders it (scale, shift), so the converters swap the two halves. For a LoRA only lora_B should be swapped: its rows are the layer's outputs. lora_A is (rank, in), so swapping its halves reorders the rank dimension and the converted delta is wrong.
Two converters in loaders/lora_conversion_utils.py swap both:
_convert_bfl_flux_control_lora_to_diffusers:swap_scale_shiftis applied for everylora_key, includinglora_A(weight and bias)._convert_hunyuan_video_lora_to_diffusers:remap_norm_scale_shift_swaps everyfinal_layer.adaLN_modulation.1key,lora_Aincluded.
The kohya Flux converter already swaps only lora_B. This is the same class of bug #15276 fixed for Flux2.
Reproduction
import torch
from diffusers.loaders.lora_conversion_utils import _convert_bfl_flux_control_lora_to_diffusers
RANK, INNER = 4, 3072
torch.manual_seed(0)
class FillingDict(dict):
# dummy tensors for the keys the converter pops that this repro doesn't care about
def pop(self, key, *default):
if key in self:
return super().pop(key)
if default:
return default[0]
return torch.zeros(21504, RANK) if ".lora_B." in key else torch.zeros(RANK, 8)
lora_A = torch.randn(RANK, INNER)
lora_B = torch.randn(2 * INNER, RANK) # rows: (shift, scale)
sd = FillingDict({
"final_layer.adaLN_modulation.1.lora_A.weight": lora_A.clone(),
"final_layer.adaLN_modulation.1.lora_B.weight": lora_B.clone(),
"double_blocks.0.img_attn.norm.query_norm.scale": torch.ones(1),
})
out = _convert_bfl_flux_control_lora_to_diffusers(sd)
A = out["transformer.norm_out.linear.lora_A.weight"]
B = out["transformer.norm_out.linear.lora_B.weight"]
shift, scale = (lora_B @ lora_A).chunk(2, dim=0)
expected = torch.cat([scale, shift])
print(torch.allclose(B @ A, expected, atol=1e-4), (B @ A - expected).abs().max().item())
print(torch.allclose(B @ lora_A, expected, atol=1e-4)) # lora_A left as is
Logs
False 39.052650451660156
True
The HunyuanVideo converter gives the same result (max error 17.05 in the equivalent check).
System Info
diffusers main @ 43e3002, torch 2.15.0, Python 3.12, macOS (CPU).
Who can help?
@sayakpaul
I have a fix with tests for both converters (swap only lora_B; one test per converter in the style of test_lora_bfl_final_layer_modulation, both fail on main) and can open a PR if you'd like. It may change the expected slices of the slow Flux Control LoRA integration tests, which I can't regenerate without a GPU.
- Lenguaje dominante
- Python
- Estrellas
- 34.9k
- Forks
- 7.5k
- Merge medio
- 3 d 16 h
- PR fusionados (30 d)
- 65
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de huggingface/diffusers
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
huggingface/diffusers#15363 ·
Los mantenedores suelen responder en 1 día
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeErrorPosiblemente ocupada @chessing234 la tomó hace 1 día. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
huggingface/diffusers#15337 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Multi-vector textual inversion uses only the first vector when the token has uppercase letters (transformers v5)Posiblemente ocupada @sunhouy la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
huggingface/diffusers#15313 ·
Los mantenedores suelen responder en 1 día
-
TCDScheduler advances the generator on the final step of a strength-truncated custom schedulePosiblemente ocupada @SIDDARTHAREDDY8 la tomó hace 5 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
huggingface/diffusers#15288 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
unload_textual_inversion(token) leaves the extra tokens of a multi-vector embedding behind, so it can't be loaded againPosiblemente ocupada @sohailshk la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
huggingface/diffusers#15211 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de huggingface/diffusers
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
Los mantenedores suelen responder en 1 día
-
Unused loot bag group names left in dreamcraft en_US.langPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. AbiertoStatus: Triage Suggestion
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
GTNewHorizons/GT-New-Horizons-Modpack#27789 ·
Los mantenedores suelen responder en 1 día
-
bug frontend sev-5
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
-
core good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
b4b code health next
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ESCOMP/CTSM#4330 · 1 comentario ·
Los mantenedores suelen responder en 1 día