Flux3 LoRAs in the original (BFL / ComfyUI) format fail to load or lose their modulation, embedder and final-layer weights
Maintainer antworten meist innerhalb von 1 Tag
@kartik-911 arbeitet bereits daran.
Seit 30.11.2026.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- backend, machine-learning
Rechercherichtung
Start in src/diffusers/loaders/lora_conversion_utils.py at _convert_non_diffusers_flux3_lora_to_diffusers; compare its key handling with convert_flux3_transformer_checkpoint_to_diffusers in src/diffusers/loaders/single_file_utils.py and the Flux2, Flux kohya, and Wan converters. Add or extend converter tests for module renames, AdaLN shift/scale handling, alpha and lora_down/lora_up keys, and ignored extras. Done means the reported original-format LoRAs load with their LoRA modules mapped and scaling preserved, while remaining unsupported keys are reported.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Describe the bug
Flux3LoraLoaderMixin.lora_state_dict sends any state dict with diffusion_model.* keys to _convert_non_diffusers_flux3_lora_to_diffusers (src/diffusers/loaders/lora_conversion_utils.py). That converter only renames the block-internal names (content_mode_blocks, single_blocks, q_proj / k_proj / v_proj / attn_out / mlp_in / mlp_out) and passes every other key through. That causes three problems.
-
LoRA on non-block modules is dropped. The single-file converter for the same model,
convert_flux3_transformer_checkpoint_to_diffusers(src/diffusers/loaders/single_file_utils.py), also renames these modules:original (BFL / ComfyUI) diffusers *_stream_modulations.<mode>.lin*_stream_modulations.<mode>.linearemb_in.<mode>x_embedders.<mode>txt_incontext_embeddertime_in.in_layer/time_in.out_layertimestep_embedder.linear_1/linear_2ref_time_in.in_layer/ref_time_in.out_layertarget_timestep_embedder.linear_1/linear_2final_layer.image.linearproj_outfinal_layer.image.adaLN_modulation.1norm_out.linear(shift/scale halves swapped)LoRA keys on those modules keep their original names.
load_lora_adapterthen only logs "Loading adapter weights from state_dict led to unexpected keys" and loads the adapter without them. -
Files with non-LoRA extras fail to load at all. Keys that are not LoRA weights are passed through too, such as a training-only
pdd.heads, full-weightnorm.*_norm.diffdeltas, orref_time_in.*.set_weight.load_lora_weightsthen raisesValueError: Invalid LoRA checkpoint. Make sure all LoRA param names contain 'lora' substring. -
.alphais ignored, andlora_down/lora_upare not recognised. Alpha keys are passed through and then ignored, so a file withalpha != rankloads at the wrong strength. A file that useslora_down/lora_upand has no extras fails with anIndexErroringet_peft_kwargs, because no LoRA keys are found.
Affected public files
I read the safetensors headers from the Hub and loaded each file's key layout (meta tensors, full-size model) through load_lora_weights:
| file | on main |
|---|---|
NoiseToNova/Flux-3-Klein-turbo-pdd-4_8-steps (...-comfy.safetensors), the most-downloaded Flux3 LoRA |
fails: "Invalid LoRA checkpoint" (pdd.heads). With that key removed, the LoRA on early_stream_modulations.image.lin, single_stream_modulations.image.lin, emb_in.image and final_layer.image.adaLN_modulation.1 is still dropped. |
WAS/flux3_klein (flux3_image_klein_distill_r16.safetensors) |
fails: "Invalid LoRA checkpoint" (86 norm .diff keys). It also uses lora_down / lora_up and has LoRA on all of the modules in the table except ref_time_in. |
terminusresearch/flux-3-klein-image-distilled-lora-extract (distilled-comfy.safetensors) |
fails: "Invalid LoRA checkpoint" (norm .diff keys and ref_time_in.*.set_weight). Same layout as the WAS file. |
jejunepixels/Hammershoi-Flux3-LoRA (ai-toolkit, block LoRA only) |
loads correctly |
LoRAs saved by diffusers or SimpleTuner (transformer.mode_blocks...) are not affected.
Reproduction
CPU, tiny random Flux3 transformer from the test config, runs in a few seconds. It uses load_lora_into_transformer, so it shows the dropped modules without the extras that make load_lora_weights fail first:
import torch
from peft.tuners.lora import LoraLayer
from diffusers import Flux3Transformer2DModel
from diffusers.loaders.lora_pipeline import Flux3LoraLoaderMixin
torch.manual_seed(0)
model = Flux3Transformer2DModel(
in_channels=4, cond_in_channels=4, num_layers=1, num_single_layers=1, attention_head_dim=16,
num_attention_heads=2, joint_attention_dim=32, timestep_channels=32, axes_dims_rope=[4, 4, 4, 4],
).eval()
# original module name -> diffusers module name (as convert_flux3_transformer_checkpoint_to_diffusers renames them)
original_to_diffusers = {
"content_mode_blocks.image.0.q_proj": "mode_blocks.image.0.attn.to_q",
"early_stream_modulations.image.lin": "early_stream_modulations.image.linear",
"single_stream_modulations.txt.lin": "single_stream_modulations.txt.linear",
"emb_in.image": "x_embedders.image",
"txt_in": "context_embedder",
"time_in.in_layer": "timestep_embedder.linear_1",
"final_layer.image.linear": "proj_out",
"final_layer.image.adaLN_modulation.1": "norm_out.linear",
}
modules = dict(model.named_modules())
state_dict = {}
for original, diffusers in original_to_diffusers.items():
out_features, in_features = modules[diffusers].weight.shape
state_dict[f"diffusion_model.{original}.lora_A.weight"] = torch.randn(2, in_features)
state_dict[f"diffusion_model.{original}.lora_B.weight"] = torch.randn(out_features, 2)
Flux3LoraLoaderMixin.load_lora_into_transformer(Flux3LoraLoaderMixin.lora_state_dict(state_dict), transformer=model)
with_lora = {n for n, m in model.named_modules() if isinstance(m, LoraLayer)}
print("dropped:", [d for d in original_to_diffusers.values() if d not in with_lora])
Output on main:
Loading adapter weights from state_dict led to unexpected keys found in the model: emb_in.image.lora_A.weight, emb_in.image.lora_B.weight, txt_in.lora_A.weight, txt_in.lora_B.weight, time_in.in_layer.lora_A.weight, time_in.in_layer.lora_B.weight, final_layer.image.linear.lora_A.weight, final_layer.image.linear.lora_B.weight, final_layer.image.adaLN_modulation.1.lora_A.weight, final_layer.image.adaLN_modulation.1.lora_B.weight, early_stream_modulations.image.lin.lora_A.weight, early_stream_modulations.image.lin.lora_B.weight, single_stream_modulations.txt.lin.lora_A.weight, single_stream_modulations.txt.lin.lora_B.weight.
dropped: ['early_stream_modulations.image.linear', 'single_stream_modulations.txt.linear', 'x_embedders.image', 'context_embedder', 'timestep_embedder.linear_1', 'proj_out', 'norm_out.linear']
Adding state_dict["pdd.heads"] = torch.zeros(1) and loading through a pipeline's load_lora_weights gives the "Invalid LoRA checkpoint" error instead.
Alpha: with diffusion_model.content_mode_blocks.image.0.q_proj.alpha = 1.0 and rank 4, the loaded update is scaled by 1.0 instead of alpha / rank = 0.25.
Proposed fix
In _convert_non_diffusers_flux3_lora_to_diffusers:
- Apply the module renames of
convert_flux3_transformer_checkpoint_to_diffusersto LoRA module names. Forfinal_layer.image.adaLN_modulation.1, swap the shift/scale halves oflora_Bonly, as done for Flux2 in #15276 and for Flux Control / HunyuanVideo in #15307. - Fold
.alphaintolora_A/lora_B, and acceptlora_down/lora_up, as the other non-diffusers converters do. - Drop the non-LoRA extras (norm
.diff,*.set_weight,pdd.*) with a warning that names them, following the Flux kohya and Wan converters. Then raise on any key that is still left, like the Flux2 converter.
With this, all three failing files above load fully (every LoRA module gets a LoRA layer). The dropped extras are not applied, though. These are the attention-norm deltas and, for the terminusresearch file, the replacement ref_time_in (flow-map target-timestep embedder) weights. So the distillation-specific parts of the WAS and terminusresearch extracts don't take effect in diffusers. Base Klein has no target-timestep embedder anyway.
I have a fix with a test ready and can open a PR.
System Info
diffusers main (08d5de3), torch CPU, peft installed.
- Vorherrschende Sprache
- Python
- Sterne
- 35k
- Forks
- 7.5k
- Ø Merge
- 2 T. 22 Std.
- Gemergte PRs (30 T.)
- 58
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus huggingface/diffusers
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
huggingface/diffusers#15436 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
InpaintProcessor crashes when padding_mask_crop is set and a dimension is omittedEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
huggingface/diffusers#15433 ·
Maintainer antworten meist innerhalb von 1 Tag
-
LTXEulerAncestralRFScheduler skips signal scaling with s_noise=0Evtl. vergeben @hparik11 hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
huggingface/diffusers#15423 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Docs: 13 docstrings document parameters their functions don't haveEvtl. vergeben @M-Colley hat das vor 3 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
huggingface/diffusers#15363 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeErrorEvtl. vergeben @chessing234 hat das vor 11 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
huggingface/diffusers#15337 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in huggingface/diffusers
Ähnliche Issues
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount dueEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 79/100
developmentseed/titiler-covjson#164 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
awslabs/visual-asset-management-system#2164 ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
MakazhanAlpamys/Soup#3589 ·
Maintainer antworten meist innerhalb von 1 Tag
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
Maintainer antworten meist innerhalb von 1 Tag