Commit Graph

54 Commits

Author SHA1 Message Date
CalamitousFelicitousness 48fad8524e feat(krea2): add Krea 2 (K2) image model support
Krea 2 is a 12.9B single-stream flow-matching DiT trained from scratch, using a Qwen3-VL-4B text encoder and the Qwen-Image VAE. The transformer is vendored as a diffusers ModelMixin whose module tree mirrors the checkpoint, so weights load with no key conversion; the pipeline ports the reference encode, flow-matching denoise, and VAE decode. The text encoder is shared at runtime via the existing dedup registry, so Base and Turbo reuse one Qwen3-VL-4B copy.

Covers text-to-image, image-to-image, native LoRA, and the single-file UNET override. Also completes SD.Next's partial Qwen-Image VAE support (5D decode input and TAESD preview mapping) that K2 shares.
2026-06-23 04:41:54 +01:00
QualiaRain 023c829179 fix model/vae: wrong quant_config var, getattr guards, remote-vae latent_copy shadowing + response handling
Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-12 13:00:39 -04:00
CalamitousFelicitousness 5b321d2071 refactor(lora): update importers for native_adapter rename
5 pipeline files + 2 test files. Mechanical substitution. 141/141
adapter tests pass.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 9587972831 fix(lora): natural-filename lookup on windows and in subfolders
NetworkOnDisk.fullname stripped only "/" from the post-lora_dir slice,
leaving a leading "\" on Windows. Every prompt typing the file's
natural dot-form name missed both registered aliases. On Linux,
dot-form lookup already missed when the file lived in any subfolder
because only the subfolder-prefixed form was registered.

- network.py: lstrip both separators and normalize backslashes to
  forward slashes so fullname has one canonical shape per OS.
- lora_load.py: register a bare-basename-with-dots alias so typing
  <lora:my.lora:1> resolves regardless of subfolder placement.
  setdefault preserves explicit primary registrations on cross-subfolder
  basename collisions.

Existing prompts using the legacy dots-to-underscores form continue
to resolve via entry.name unchanged.
2026-05-24 02:46:48 +01:00
CalamitousFelicitousness 4c3f4db129 refactor(lora): collapse native dispatcher to a registry
Five if-blocks in lora_load.load_safetensors reduce to one lookup in
_NATIVE_DISPATCH, a string -> module-path map keyed by shared.sd_model_type.

Each entry's module exposes try_load(name, network_on_disk, lora_scale).
flux2 / zimage / chroma / ernie use the umbrella that binds native_loader's
generics via try_load_chain. Anima keeps its own try_load (aliased to
try_load_lora) since its multi-component routing doesn't fit the shared
suffix-table model.

New native archs land by adding one entry to the dict and shipping a
try_load.
2026-05-18 23:38:37 +01:00
Vladimir Mandic c8d6fd5cf8 Revert "much stricter ruff linting"
This reverts commit 310dbf1574.
2026-05-11 08:13:57 +02:00
Vladimir Mandic 310dbf1574 much stricter ruff linting
Co-authored-by: Copilot <copilot@github.com>
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-11 07:15:37 +02:00
CalamitousFelicitousness 0c44b93b25 refactor(flux2): expose single try_load entry point for dispatcher
Move the family-iteration loop into pipelines/flux/flux2_lora.try_load
so the f2 branch in lora_load.load_safetensors becomes a one-line call.

Per-family try_load_* entry points stay public for direct testing.

Addresses review feedback on PR #4841.
2026-05-10 16:33:18 +01:00
CalamitousFelicitousness 69506551a7 feat(lora): surface method-selection reason in load logs
get_method now returns (method, reason). The reason distinguishes
user opt-in (lora_force_diffusers), class-forced, hash-forced, and
arch-unsupported routes from the default native path; surfaced in
the info-level "Network load: type=LoRA load=<method>(<reason>)"
line so users can tell why a given load took a particular path.
2026-05-10 00:05:37 +01:00
CalamitousFelicitousness 4d3699bab6 refactor(flux2): align dispatcher with z-image/chroma native pattern
Adds 'f2' to allow_native and dispatches all eight native loaders
through load_safetensors. lora_force_diffusers continues to route
through lora_diffusers.load_diffusers as the explicit PEFT escape
hatch.
2026-05-09 23:16:09 +01:00
CalamitousFelicitousness 92df94a227 feat(chroma): native loader for chroma lora
Add a per-model native LoRA path for Chroma that handles both PEFT-style
(diffusion_model.<dotted>.lora_A.weight, no alpha) and kohya-flat
(lora_unet_<flat> with .alpha) layouts, plus LoKR/LoHA/OFT/DoRA.

Resolves issue #4169 (ostris ai-toolkit Chroma LoRAs failed to load).

- new pipelines/chroma/chroma_lora.py with try_load_lora/lokr/loha/oft
- fused-QKV expansion: 3-way equal for img/txt qkv, 4-way unequal
  [3072, 3072, 3072, 12288] for single linear1 (Q+K+V+proj_mlp)
- NetworkModuleLokrSliceChunk for unequal-row LoKR slicing
- path rewrite from Flux-source to ChromaTransformer2DModel naming
- lora_load.py: dispatch chroma to the native loader and narrow the
  kohya-Flux convert gate to f1 only
2026-05-04 21:17:14 +01:00
CalamitousFelicitousness b37e275212 feat(lora): native loader for ernie-image
Adds pipelines/ernie/ernie_lora.py with try_load_lora/lokr/loha/oft
entry points modeled on the z-image native loader, wires it into
lora_load.load_safetensors, and adds 'ernieimage' to allow_native.

ERNIE attention is not fused (separate to_q/to_k/to_v/to_out.0), so
the loader skips the qkv-split machinery the z-image loader needs and
supports all four families uniformly. Recognized prefixes are
diffusion_model., transformer., and lora_unet_; PEFT lora_A/lora_B
keys are normalized to lora_down/lora_up. Verified against PEFT, LoKR,
and Kohya/AIT files in the wild with zero unmapped or shape-mismatched
modules.
2026-05-04 16:43:36 +01:00
CalamitousFelicitousness 450bf977e8 fix(lora): use native_active flag instead of applied_layers for restore trigger
applied_layers is cleared and re-populated on every network_activate call.
With lora_apply_te=True the second activate (TE-only pass) finds all
modules already at the target state and skips them all, leaving
applied_layers empty and breaking the restore trigger on the next gen.

native_active is set from loaded_networks at the end of activate, so it
survives idempotent re-runs and only flips false after the restore call
clears loaded_networks.
2026-05-01 01:38:56 +01:00
CalamitousFelicitousness a028b56687 fix(lora): restore native weights when LoRA removed on diffusers-path models
Flux2/Klein loads LoRAs as native modules through the diffusers method
path. network_activate() was only called when new native modules existed,
so removing a LoRA from the prompt left backed-up weights unrestored.

Check applied_layers to detect previously active native modules and
trigger network_activate() for the restore path.
2026-04-29 02:00:33 +01:00
CalamitousFelicitousness 4af3a57741 feat(anima): native lora across transformer, llm_adapter, text encoder
Dispatch anima loras through a dedicated native loader covering kohya,
bfl/ai-toolkit, and hybrid (bfl with alpha plus qwen3 text encoder)
formats. Cosmos 2.0 path rename is mirrored from diffusers in flat
(underscore) form so rewritten paths match network_layer_mapping keys
without further conversion.

Split model_type from cosmos to anima so a future base-cosmos2 lora
path stays separable. Update flow_models, taesd supported list, and the
taesd wanvideo bucket so samplers and preview decoding keep working
after the split.

Extend assign_network_names_to_compvis_modules to walk pipe.llm_adapter
under the lora_llm_adapter_ prefix, and add llm_adapter to
default_components so activate and deactivate include it for anima
models while staying inert elsewhere via the existing getattr guards.
2026-04-25 03:16:03 +01:00
awsr 09f5fc6e03 Update concurrent.futures imports
Python 3.14 adds `concurrent.interpreters` and we don't need to import that here.
2026-04-23 16:49:31 -07:00
CalamitousFelicitousness 65e59e7224 feat(lora): z-image native lokr, loha and oft loaders
Add three adapter families to the z-image native loader and chain them
with the existing lora path through load_safetensors. Mixed-family
files (for example gta6_amateur_photography_zimagebase_v2.safetensors,
which carries lora and lokr groups in the same file) now load
completely instead of having one family silently dropped.

Shared helpers in pipelines/z_image/zimage_lora.py parse keys by
suffix list, rename legacy attention.out and attention.wo to
attention.to_out.0, and split fused attention.qkv into to_q/k/v. For
lora the split chunks the up weight along dim 0. For lokr the split
emits three NetworkModuleLokrChunk entries that share the tensors and
slice the kronecker product at apply time.

Fused attention.qkv for loha and oft is skipped with a warning. No
NetworkModuleHadaChunk exists, oft rotations are tied to out_features
and cannot be cleanly split across q/k/v, and no real z-image adapter
in that layout exists today.

load_safetensors for zimage chains try_load_lora, try_load_lokr,
try_load_loha and try_load_oft and merges their module dicts into a
single Network so mixed files load every module.
2026-04-14 21:48:19 +01:00
CalamitousFelicitousness c35adc4d0d feat(lora): native z-image lora loader
Add zimage to allow_native so lora_force_diffusers picks between
native and diffusers. Before this, zimage always took the diffusers
path regardless of the setting.

pipelines/z_image/zimage_lora.py reads the safetensors and writes
directly into network_layer_mapping, so Z-Image LoRAs no longer go
through the diffusers PEFT converter that raised KeyError on
state dicts with partial alpha keys.

Key formats handled: ai-toolkit, kohya lora_unet_, bare transformer.
and no-prefix. Pre-refactor fused attention.qkv is split into
to_q/k/v; attention.out and attention.wo are renamed to
attention.to_out.0. Alpha and dora_scale are preserved.
2026-04-14 21:13:23 +01:00
CalamitousFelicitousness 18568db41c Add native LoRA loading for Flux2/Klein models
Load Flux2/Klein LoRAs as native NetworkModuleLora objects, bypassing
diffusers PEFT. Handles kohya (lora_unet_), AI toolkit (diffusion_model.),
diffusers PEFT (transformer.), and bare BFL key formats with automatic
QKV splitting for double block fused attention weights.

Includes shape validation to reject architecture-mismatched LoRAs early.
Respects lora_force_diffusers setting to fall back to PEFT when needed.
2026-03-25 04:24:49 +00:00
vladmandic 57990fd8c0 add FireRed-Image-Edit-1.1
Signed-off-by: vladmandic <mandic00@live.com>
2026-03-23 06:41:46 +01:00
CalamitousFelicitousness 091f31d4bf add Flux2/Klein LoRA support
- detect f2 model type for LoRAs via metadata, architecture, and filename/folder
- preprocess bare BFL-format keys with diffusion_model prefix for Flux2LoraLoaderMixin
- handle LoKR format via native NetworkModuleLokr with on-the-fly kron(w1, w2)
- add NetworkModuleLokrChunk for fused QKV split into separate Q/K/V modules
- activate native modules loaded via diffusers path
- improve error message for Flux1/Flux2 architecture mismatch
2026-03-23 02:14:07 +00:00
vladmandic f83e9e7943 deregister rembg submodule
Signed-off-by: vladmandic <mandic00@live.com>
2026-03-20 08:14:01 +01:00
vladmandic 121c51289b patch lora
Signed-off-by: vladmandic <mandic00@live.com>
2026-03-13 12:02:27 +01:00
Vladimir Mandic e5c494f999 cleanup logger 2026-02-19 11:09:13 +01:00
Vladimir Mandic a3074baf8b unified logger 2026-02-19 09:46:42 +01:00
Vladimir Mandic bfe014f5da modernize typing 2026-02-19 09:15:37 +01:00
vladmandic 947dd7b2b3 support lora inside prompt selector
Signed-off-by: vladmandic <mandic00@live.com>
2026-01-25 09:49:36 +01:00
vladmandic bfbe4af598 fix lora load
Signed-off-by: vladmandic <mandic00@live.com>
2026-01-21 08:45:45 +01:00
Vladimir Mandic e7809b11cd reapply offload hooks on diffusers lora load
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-01-13 10:07:30 +00:00
Vladimir Mandic ff772003e3 lora: restore pipeline type if reload/recompile needed
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-11-13 09:56:36 -05:00
Vladimir Mandic ba270db6ad separate settings for lora fuse
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-11-08 11:08:06 -05:00
Vladimir Mandic 526472a921 add chronoedit prequants and lora loading
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-10-31 11:08:27 -04:00
Vladimir Mandic d71d540a62 allow lora specifier to select model component. see changelog/wiki for docs on how to.
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-09-23 15:25:13 -04:00
Vladimir Mandic 16670636d7 fix lora with nested pipeline
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-09-11 09:03:02 -04:00
Disty0 afbc2d2a72 Fix OpenVINO loras 2025-09-03 21:10:45 +03:00
Vladimir Mandic fc547a3ccd sdnq with diffusers lora loader
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-08-18 10:29:01 -04:00
Vladimir Mandic e8b5ea3847 major refactor: remove backend original
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-07-05 13:16:46 -04:00
Enes Sadık Özbek e91208bea9 Merge branch 'dev' into feature/chroma-support 2025-06-26 17:02:00 +03:00
Vladimir Mandic 7380c08f8e lint fix
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-06-26 06:51:59 -04:00
Enes Sadık Özbek 21bdde12d3 Merge branch 'dev' into feature/chroma-support 2025-06-26 01:56:34 +03:00
Enes Sadık Özbek 4b3ce06916 Initial support for Chroma 2025-06-18 00:38:17 +00:00
Enes Sadık Özbek 3868a9184b Fix incorrectly reported lycoris load error 2025-06-07 00:36:08 +03:00
Vladimir Mandic ff649291b5 lint fixes
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-28 10:55:21 -04:00
AI-Casanova d14b54efa3 Preliminary support for sd1.5/sdxl OMI lora 2025-04-27 16:53:22 -05:00
Vladimir Mandic f00824e7b5 add SD_LORA_DUMP
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-25 09:54:43 -04:00
Vladimir Mandic bcb7b24bf2 cleanup video tab
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-23 13:46:50 -04:00
Vladimir Mandic a9969491ff fix hidream loader
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-22 11:04:35 -04:00
Vladimir Mandic 8d6c7510c2 fix lora
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-18 07:34:12 -04:00
Vladimir Mandic eaf37055ba nunchaku lora support
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-17 11:45:37 -04:00
Vladimir Mandic 984aa8ec55 lint fixes
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-08 16:31:51 -04:00