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

[bug]: FLUX.1 diffusers-format LoRAs with text-encoder layers fail to load

Aperta Adatta ai principianti
#10,024 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

Direzione di ricerca

Inizia in invokeai/backend/patches/lora_conversions/flux_diffusers_lora_conversion_utils.py a lora_model_from_flux_diffusers_state_dict. Rifletti il percorso kohya mappando text_encoder. a FLUX_LORA_CLIP_PREFIX e text_encoder_2. a FLUX_LORA_T5_PREFIX. Esegui lo script repro fornito per confermare che l'AssertionError è scomparso e i layer text-encoder si caricano.

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

A FLUX.1 diffusers-format LoRA that also trains the text encoders fails to load:

  File "invokeai/backend/patches/lora_conversions/flux_diffusers_lora_conversion_utils.py", line 288, in lora_layers_from_flux_diffusers_grouped_state_dict
    assert len(grouped_state_dict) == 0
AssertionError

diffusers' FLUX LoRA layout keeps the CLIP layers under text_encoder., next to the transformer. layers. OneTrainer additionally writes T5 layers under text_encoder_2.. lora_model_from_flux_diffusers_state_dict converts transformer keys only, so any text-encoder key is left over and trips the closing assert. The whole LoRA is rejected, transformer layers included.

The kohya path already applies FLUX text-encoder layers through FLUX_LORA_CLIP_PREFIX / FLUX_LORA_T5_PREFIX.

What you expected to happen

text_encoder.* maps to the CLIP prefix and text_encoder_2.* to the T5 prefix, as the kohya lora_te1_ / lora_te2_ keys do. At minimum, unknown keys are reported with their names instead of a bare AssertionError.

How to reproduce the problem
import torch

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


def peft(prefix: str, d: int) -> dict:
    return {f"{prefix}.lora_A.weight": torch.randn(4, d), f"{prefix}.lora_B.weight": torch.randn(d, 4)}


sd = peft("transformer.transformer_blocks.0.attn.to_out.0", 3072) | peft(
    "text_encoder.text_model.encoder.layers.0.self_attn.q_proj", 768
)
lora_model_from_flux_diffusers_state_dict(sd, alpha=None)
Additional context

OneTrainer writes FLUX.1 LoRAs with trained CLIP and T5 in exactly this layout.

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.