[bug]: FLUX final-layer modulation LoRA layer is not converted (FLUX.1 diffusers: load fails, FLUX.2 BFL: layer skipped)
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
- Ambito
- backend, machine-learning
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
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 fornorm_out.linear, so the closingassert 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.pyhasfinal_layer.linear → proj_out(line 111) but nothing forfinal_layer.adaLN_modulation.1. The key stays BFL-named and does not resolve onFlux2Transformer2DModel("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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di invoke-ai/InvokeAI
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
[enhancement]: Bump PyPatchMatch to latestForse già presa @dunkeroni l’ha presa 10 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
invoke-ai/InvokeAI#9826 · 2 reazioni · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di invoke-ai/InvokeAI
Issue simili
-
freshness freshness:observed-only
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
thoroc/context-radar#282 ·
-
bug P2 rust
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
area: web
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
gabe-santana/arkdraw#25 ·
-
bug require-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
expressjs/expressjs.com#2549 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
codercops/discord-bot#101 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno