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

[bug]: Anima kohya LoRAs: layers outside the DiT blocks are not applied

Aperta Adatta ai principianti
#10,028 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
85/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/anima_lora_conversion_utils.py presso _convert_kohya_unet_key (riga 80). Leggi la funzione e lo script repro fornito per vedere quali chiavi rimangono appiattite. Aggiungi mappatura per final_layer_linear, final_layer_adaln_modulation_1, t_embedder_1_linear_1, x_embedder_proj_1 alle loro forme punteggiate. Esegui lo snippet per confermare che la lista dei layer corrisponda ai nomi punteggiati attesi.

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

In an Anima kohya LoRA, the layers outside the DiT blocks are never applied. _convert_kohya_unet_key (invokeai/backend/patches/lora_conversions/anima_lora_conversion_utils.py:80) only un-flattens blocks_N_… (and the llm_adapter_ prefix). Every other key keeps its flattened name: final_layer_linear, final_layer_adaln_modulation_1/2, t_embedder_1_linear_1/2, x_embedder_proj_1. The resulting dotted patch never resolves them, and each one logs "Failed to find module for LoRA layer key".

The LoRA still loads and works, just without those layers. That makes it weaker than trained, and the only signal is the per-layer warnings.

What you expected to happen

Non-block kohya keys map to final_layer.linear, final_layer.adaln_modulation.1, t_embedder.1.linear_1, x_embedder.proj.1 and so on, as the block keys do. A kohya parsing tree like the Krea-2 one (kohya_key_utils) would cover them.

How to reproduce the problem
import torch

import invokeai.backend.model_manager.load  # noqa: F401
from invokeai.backend.patches.lora_conversions.anima_lora_conversion_utils import lora_model_from_anima_state_dict


def lora(prefix: str) -> dict:
    return {f"{prefix}.lora_down.weight": torch.randn(4, 64), f"{prefix}.lora_up.weight": torch.randn(64, 4)}


sd = {}
for k in ("blocks_0_self_attn_q_proj", "final_layer_linear", "final_layer_adaln_modulation_1", "t_embedder_1_linear_1", "x_embedder_proj_1"):
    sd |= lora(f"lora_unet_{k}")
print(list(lora_model_from_anima_state_dict(sd, alpha=None).layers))

Output on main:

['lora_transformer-blocks.0.self_attn.q_proj', 'lora_transformer-final_layer_linear', 'lora_transformer-final_layer_adaln_modulation_1', 'lora_transformer-t_embedder_1_linear_1', 'lora_transformer-x_embedder_proj_1']
Additional context

In a LoRA trained on every layer these are 6 of 454 layers (about 1 % of the trained weights).

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 4h
PR unite (30g)
161

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.