Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[bug]: FLUX final-layer modulation LoRA layer is not converted (FLUX.1 diffusers: load fails, FLUX.2 BFL: layer skipped)

Aperta Adatta ai principianti
#10,022 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, pytorch

Direzione di ricerca

Inizia in invokeai/backend/patches/lora_conversions/flux_diffusers_lora_conversion_utils.py all'assert alla linea 288 e aggiungi una regola per norm_out.linear. Poi aggiorna la map di flux_bfl_peft_lora_conversion_utils.py per includere final_layer.adaLN_modulation.1 con metà scambiate. Esegui lo script di riproduzione dell'issue per confermare che l'AssertionError scompare e la risoluzione del modulo restituisce True.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Is there an existing issue for this problem?
  • I have searched the existing issues
Install method

Manual (dev checkout)

Operating system

Windows

GPU vendor

Not GPU-specific (reproduced on CPU)

GPU model

No response

GPU VRAM

No response

Version number

main at 0ddc9df91b

What happened

The final-layer modulation (norm_out.linear in diffusers naming, final_layer.adaLN_modulation.1 in BFL naming) is not converted for FLUX:

  • FLUX.1, diffusers keys: the whole LoRA fails to load. lora_layers_from_flux_diffusers_grouped_state_dict (invokeai/backend/patches/lora_conversions/flux_diffusers_lora_conversion_utils.py) has no rule for norm_out.linear, so the closing assert len(grouped_state_dict) == 0 (line 288) fires. Diffusers-format LoRAs that train every linear layer contain this layer. OneTrainer's FLUX.1 LoRA preset trains every layer by default.
  • FLUX.2, BFL keys: the layer is skipped. The BFL→diffusers map in flux_bfl_peft_lora_conversion_utils.py has final_layer.linear → proj_out (line 111) but nothing for final_layer.adaLN_modulation.1. The key stays BFL-named and does not resolve on Flux2Transformer2DModel ("Failed to find module").

Both directions need the two output halves swapped. diffusers' AdaLayerNormContinuous splits the projection into (scale, shift), while BFL's LastLayer splits it into (shift, scale). The halves of lora_up / lora_B rows therefore swap on conversion.

What you expected to happen

norm_out.linear maps to final_layer.adaLN_modulation.1 for FLUX.1, and back for FLUX.2, with the halves swapped. The LoRA loads and the layer is applied.

How to reproduce the problem
import torch
from diffusers import Flux2Transformer2DModel

import invokeai.backend.model_manager.load  # noqa: F401
from invokeai.backend.patches.lora_conversions.flux_bfl_peft_lora_conversion_utils import (
    lora_model_from_flux2_bfl_peft_state_dict,
)
from invokeai.backend.patches.lora_conversions.flux_diffusers_lora_conversion_utils import (
    lora_model_from_flux_diffusers_state_dict,
)

# FLUX.1, diffusers names: norm_out.linear (3072 -> 6144)
sd = {"transformer.norm_out.linear.lora_A.weight": torch.randn(4, 3072), "transformer.norm_out.linear.lora_B.weight": torch.randn(6144, 4)}
try:
    lora_model_from_flux_diffusers_state_dict(sd, alpha=None)
except AssertionError:
    print("FLUX.1 diffusers: AssertionError (norm_out.linear left unconsumed)")

# FLUX.2 Klein 9B, BFL names: final_layer.adaLN_modulation.1 (4096 -> 8192)
p = "diffusion_model.final_layer.adaLN_modulation.1"
patch = lora_model_from_flux2_bfl_peft_state_dict({f"{p}.lora_A.weight": torch.randn(4, 4096), f"{p}.lora_B.weight": torch.randn(8192, 4)}, alpha=None)
with torch.device("meta"):
    model = Flux2Transformer2DModel(num_layers=8, num_single_layers=24, attention_head_dim=128, num_attention_heads=32, joint_attention_dim=12288)
for key in patch.layers:
    target = key.removeprefix("lora_transformer-")
    print("FLUX.2 BFL:", key, "-> module exists:", target in dict(model.named_modules()))

Output on main:

FLUX.1 diffusers: AssertionError (norm_out.linear left unconsumed)
FLUX.2 BFL: lora_transformer-final_layer.adaLN_modulation.1 -> module exists: False
Additional context

Once norm_out.linear passes, a full-layer FLUX.1 dev LoRA runs into #10023 next.

Found while checking every LoRA layout OneTrainer writes (b08db37) against main: OneTrainer's own savers run on meta-device models of the real architectures, then identification, LoRALoader and LayerPatcher module resolution on the InvokeAI model.

Discord username

No response

Lingua principale
TypeScript
Stelle
28.8k
Fork
3.1k
Merge medio
3g 2h
PR unite (30g)
159

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di invoke-ai/InvokeAI

Tutte le issue di invoke-ai/InvokeAI

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.