Files
ethanfel-ComfyUI-LoRA-Optim…/tests
EthanfelandClaude Opus 4.8 9cd56c5c83 fix(krea2): normalize LoRA keys to model-native form (fixes silent drop + likely the crash)
Krea 2 LoRAs come in trainer/diffusers key forms that DON'T match the model's
weights, and ComfyUI had no krea2 key normalizer so they passed through raw:
  - 'krea_2' trainer: diffusion_model.transformer_blocks.N.attn.to_q ...
  - diffusers:        transformer.transformer_blocks.N.attn.to_q ..., text_fusion.*,
                      img_in/txt_in/final_layer/time_embed/time_mod_proj
The diffusers 'transformer.*' keys were mis-routed by ComfyUI's FLUX branch
(flux_to_diffusers) to non-existent double_blocks QKV tuple-offset targets, so
most of the LoRA was silently DROPPED — and the bogus offset target is the prime
suspect for the merge crash (Form-2-only merges work; adding a 'transformer.*'
LoRA crashes).

Add _normalize_keys_krea2 (+ register in the dispatcher) mapping both forms to
the model-native diffusion_model.blocks.N.attn.{wq,wk,wv,wo,gate} + mlp.* +
txtfusion.{layerwise,refiner}_blocks + first/last/tmlp/tproj/txtmlp. Mapping
verified key-by-key (name AND shape) against the real krea2_turbo model:
224/224 (trainer) and 264/264 (diffusers) modules map exactly. +4 tests, 288 pass.
No version bump.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-24 00:51:32 +02:00
..