diff --git a/modules/lora/lora_load.py b/modules/lora/lora_load.py index 773c01775..b3c4b0908 100644 --- a/modules/lora/lora_load.py +++ b/modules/lora/lora_load.py @@ -103,25 +103,7 @@ def load_safetensors(name, network_on_disk: network.NetworkOnDisk) -> network.Ne return chroma_net if shared.sd_model_type == 'f2': from pipelines.flux import flux2_lora - lora_scale = shared.opts.extra_networks_default_multiplier - f2_net = None - for try_fn in ( - flux2_lora.try_load_lora, - flux2_lora.try_load_lokr, - flux2_lora.try_load_loha, - flux2_lora.try_load_oft, - flux2_lora.try_load_ia3, - flux2_lora.try_load_glora, - flux2_lora.try_load_norm, - flux2_lora.try_load_full, - ): - sub = try_fn(name, network_on_disk, lora_scale) - if sub is None: - continue - if f2_net is None: - f2_net = sub - else: - f2_net.modules.update(sub.modules) + f2_net = flux2_lora.try_load(name, network_on_disk, shared.opts.extra_networks_default_multiplier) if f2_net is not None: lora_cache[name] = f2_net return f2_net diff --git a/pipelines/flux/flux2_lora.py b/pipelines/flux/flux2_lora.py index 5148a8cfe..fcea16474 100644 --- a/pipelines/flux/flux2_lora.py +++ b/pipelines/flux/flux2_lora.py @@ -423,6 +423,32 @@ def _bfl_to_diffusers_targets(base): # === Native loaders === +def try_load(name, network_on_disk, lora_scale): + """Run every Flux2 family loader in dispatch order, merge any that match. + + Per-family ``try_load_*`` entry points stay public; this is the single + umbrella the dispatcher in ``modules.lora.lora_load.load_safetensors`` + calls. Order matters only for marker-cost: LoRA / LoKR are most common + so their fast bail-out runs first; the rare families come last. + + Returns a ``Network`` with the union of modules from every matching + family loader, or ``None`` if no loader recognized the file. + """ + net = None + for try_fn in ( + try_load_lora, try_load_lokr, try_load_loha, try_load_oft, + try_load_ia3, try_load_glora, try_load_norm, try_load_full, + ): + sub = try_fn(name, network_on_disk, lora_scale) + if sub is None: + continue + if net is None: + net = sub + else: + net.modules.update(sub.modules) + return net + + def try_load_lora(name, network_on_disk, lora_scale): """Load a Flux2/Klein LoRA (plus DoRA via the universal ``finalize_updown`` hook) as native modules.