Commit Graph

71 Commits

Author SHA1 Message Date
CalamitousFelicitousness b84b782ba4 fix(lora): apply native networks in place under group offload
Group offload hooks report the onload device at module level while the
weights rest on cpu, so every native apply took the parameter
replacement branch in assign_weight and detached the written layers
from the hook's group bookkeeping. The activation and deactivation
walks now remove a component's group hooks before its first weight
write and reapply offload at the end of the pass: writes land in place
on the resting tensors and fresh groups snapshot the result.

- hooks come off lazily, only for components with a covered layer or a
  pending backup or factor-stash restore; repeat activations with an
  unchanged set leave the hooks untouched
- remove_group_offload_component follows wrapper components to the
  inner model that carries the hooks
2026-08-10 22:10:42 +01:00
CalamitousFelicitousness 76d76be4b7 fix(lora): promote per-network multipliers after the removal pass
Cached networks are shared objects, and network_load overwrote their
multipliers before network_deactivate ran, so fuse-mode removal recomputed
the subtraction delta with the new values: a strength edit froze at its
first applied value and a later removal left residue in the model weights.
network_load now stages the values on the net and network_activate promotes
them, so the removal pass always subtracts the delta that was applied.
Backup mode restores from stored tensors and was unaffected.
2026-08-10 02:43:58 +01:00
CalamitousFelicitousness 28bd5e8d74 fix(lora): materialize balanced-offload modules before touching weights
Under a pressed balanced offload, dispatched modules hold meta tensors
whose data lives in the accelerate offload map. The factor path raised
trying to move a meta svd tensor and aborted activation mid-pass; the
legacy requantize path silently skipped those layers. Both left the
model with a partially applied network.

Rebuild the offload state with apply_balanced_offload(force) at
activate and deactivate entry: modules come back real on cpu with
hooks intact and the execution device unchanged, so both paths see
usable tensors and the next forward re-onloads under the watermark.
2026-08-10 02:42:28 +01:00
Vladimir Mandic cfd31599b4 fix lint
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-08 09:50:26 +02:00
CalamitousFelicitousness 4554b9a277 fix(lora): apply te networks before encode and honor lora_apply_te
Network activation ran after prompt encoding, so text encoder lora
weights never affected embeds on the first generation and the stale
result was then served from the embed cache. The trailing unfiltered
activate in network_load also overrode the te exclude filter, so the
lora_apply_te setting was never honored.

- parse and activate networks in process_base before pipeline args are built
- activate_filtered gates text encoder components on per-request or global
  lora_apply_te; used by base, hires, detailer and faceid call sites
- network_load accepts activate=False for callers that run their own
  deactivate/activate sequence with include/exclude
- network_activate walks excluded components in restore-only mode so a
  filtered text encoder reverts to backup instead of keeping stale deltas
- loaded_loras cache is single-entry since per-filter entries go stale when
  the setting toggles
- prompt embed cache key includes the effective lora_apply_te value
2026-07-08 03:06:04 +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 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 6e3c187b3f Rework to only use contextmanager system 2026-03-19 04:28:11 -07:00
Vladimir Mandic d65a2d1ebc ruff lint 2026-02-19 11:13:44 +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
awsr 09fdda05a4 Move to modules 2026-01-24 02:16:05 -08:00
awsr 82361e6633 Adjust names 2026-01-23 22:29:00 -08:00
awsr 58c3aecc00 Allow multiple identifiers for ErrorLimiter.notify
- Update identifiers.
- Also minor message formatting update.
2026-01-23 16:50:52 -08:00
awsr 3343d2e05f Update and rewrite to use contextlib 2026-01-23 04:56:27 -08:00
awsr 65d8c9e7f2 Implement limiting system for excessive errors 2026-01-22 03:37:52 -08:00
vladmandic 16293375dc lora native stack improvements
Signed-off-by: vladmandic <mandic00@live.com>
2026-01-18 10:06:03 +01: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
Disty0 afbc2d2a72 Fix OpenVINO loras 2025-09-03 21:10:45 +03:00
Vladimir Mandic 84a24fb681 lora restore weights to orig device on apply
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-07 07:49:18 -04:00
Vladimir Mandic d30b1cb1c8 lora improvements
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-06 13:02:58 -04:00
Vladimir Mandic 6430f7006f add monitor cli option and finish lora refactor
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-01 13:39:47 -04:00
Vladimir Mandic b5031a5eba lora modularize code
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-01 13:39:47 -04:00
Vladimir Mandic 032bd46de2 improve mp4 download
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-01 13:39:47 -04:00
Vladimir Mandic 5906eb6792 lora apply on gpu vs cpu settings option
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-04-01 13:39:47 -04:00
Vladimir Mandic 6a5e253ecf add infiniteyou
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-03-26 10:50:09 -04:00
Vladimir Mandic aa15ed1fa7 reapply offload after applying lora
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-03-25 14:09:34 -04:00
Vladimir Mandic d4a67dd946 lora logging
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-03-15 19:04:03 -04:00
Vladimir Mandic 2090a334b0 hunyuanvideo lora support
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-01-07 12:49:09 -05:00
Disty0 9adf777e38 OpenVINO fix Lora 2024-12-31 04:15:37 +03:00
Vladimir Mandic 18f683b283 refactor lora add_weights
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-29 12:42:08 -05:00
Vladimir Mandic 910f5d0a73 lora direct on-demand apply/unapply
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-29 12:38:19 -05:00
Vladimir Mandic 8b910dbf02 cleanup
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-28 17:04:43 -05:00
Vladimir Mandic 53c4c84c40 quantization improvements and lora support
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-28 16:57:06 -05:00
Vladimir Mandic d49d470a89 hide disabled networks and add more previews
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-27 09:45:03 -05:00
Vladimir Mandic e7f0047d52 add granular vae tiling options
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-25 12:38:21 -05:00
Vladimir Mandic a5f94fe0dd remove experimental from consistory
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-24 16:09:25 -05:00
Vladimir Mandic ea6d3107ab update all todo statements
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-22 08:39:31 -05:00
Vladimir Mandic dae181fefb lora-direct with bnb
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-20 18:26:25 -05:00
Vladimir Mandic bd540efb73 lora: absolute path, hf download, flux controlnet loras
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-11 18:10:51 -05:00
Vladimir Mandic 8cea43f7db lora add erorr handler for partial offload
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-11 13:10:05 -05:00
Vladimir Mandic beea969fd3 update lora
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-10 12:34:27 -05:00
Vladimir Mandic 383d7052ac lora split te apply
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-09 15:23:22 -05:00
Vladimir Mandic 1185950c4a yet another lora refactor
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-09 13:40:19 -05:00
AI-Casanova 6c9101dfaf lora low memory mode: switching requires manual model reload 2024-12-06 22:54:08 -06:00
Vladimir Mandic 28eeb00432 remove non-blocking
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-06 09:15:37 -05:00
Vladimir Mandic 16ab1e2ae8 safer lora unapply
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-06 07:23:31 -05:00
Vladimir Mandic 2934948413 lora one more safe cast
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-05 09:04:42 -05:00
Vladimir Mandic ca06002602 lora maintain device
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2024-12-04 09:25:57 -05:00