Commit Graph

8874 Commits

Author SHA1 Message Date
Disty0 e484850e9e Cleanup SDNQ 2026-05-22 17:32:41 +03:00
Vladimir Mandic ad9c937e68 Merge pull request #4862 from vladmandic/fix/editable-dropdown-blur
fix(ui): debounce editable dropdowns in quicksettings
2026-05-22 06:12:38 +02:00
CalamitousFelicitousness 84683a1d84 refactor(anima): migrate to generic native_loader
Replaces anima_lora.py's bespoke try_load_lora / group_keys /
resolve_network_key with thin wrappers binding native_loader's generics
to anima's prefix tuples and resolve_targets, mirroring flux2 / zimage /
chroma / ernie. The hand-rolled apply_lora_alphas bake-with-balance
pass goes away; alpha / scale / dora_scale flow through NetworkWeights.w
to NetworkModule.calc_scale at apply time.

native_loader gains an optional network_prefix kwarg (str or
Callable[[prefix_used], str], default "lora_transformer_") used when
constructing network_key. Anima passes a callable picking
lora_transformer_ / lora_llm_adapter_ / lora_te_ per matched prefix.
Single-component siblings keep the default and are unchanged.

network.NetworkModule.apply_weight_decompose grows a dual-path DoRA
convention detector. The pre-fix implementation only handled per-input
dora_scale (DoRA paper / kohya, shape (1, in)), silently broadcasting
per-output LyCORIS / PEFT dora_scale (shape (out, 1)) into an incoherent
element-wise rescaling. Detection is structural: (out, 1, ...) routes
to per-output; everything else (including the square-weight 1D ambiguity)
defaults to per-input for legacy compat. Pre-existing bug surfaced by
the LoKR+DoRA LyCORIS files Anima now loads.

Behavior changes:

- LoHA via the generic try_load_loha (NetworkModuleHada); covers
  scenery-anima-base and any other LyCORIS .hada_w* export.
- Kohya lora_te_ prefix recognized. The legacy resolver only matched
  BFL text_encoders.qwen3_06b.transformer.model. and silently dropped
  lora_te_layers_N_* keys (41% of BlueArcStyle's bases were unloaded).
- LoKR+DoRA LyCORIS files now apply correctly; the per-output dora_scale
  is honored instead of silently scrambled.

Adds test/test-anima-native-adapters.py: 37 offline tests across all
five prefixes (LoRA + LoHA), every COSMOS_2_FLAT_RENAME entry, DoRA
threading, marker disambiguation, try_load_chain dispatch, calc_updown
sanity, and both DoRA conventions (per-input / per-output / 1D ambiguous).
Adapter mock mirrors AnimaLLMAdapter's real module tree.
2026-05-22 00:22:32 +01:00
Disty0 f91893d0df Fix bias dtype mismatch with pre-quants 2026-05-22 00:08:42 +03:00
Disty0 3e879ccb69 cleanup 2026-05-21 23:44:44 +03:00
Disty0 cfafbed868 don't duplicate modules_to_not_convert 2026-05-21 20:44:28 +03:00
Disty0 9adf20a47c fix asym quant with hadamard 2026-05-21 17:22:45 +03:00
Vladimir Mandic 7d91ee9611 enhance globals
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-21 12:02:01 +02:00
Vladimir Mandic b35f8fa831 ui fixes
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-21 09:23:10 +02:00
Vladimir Mandic 1e47ade7ee Merge pull request #4861 from vladmandic/refactor/native-loader
Refactor/native loader
2026-05-21 08:57:33 +02:00
CalamitousFelicitousness 9de161e65a fix(ui): debounce editable dropdowns in quicksettings
Editable dropdowns (sd_model_checkpoint, sd_text_encoder) fired a
.change event on every keystroke because Gradio's allow_custom_value
keyup handler sets the value to the typed text.

- Use .blur instead of .change for DropdownEditable in quicksettings
- Validate model keys in run_settings_single before committing
2026-05-21 03:58:41 +01:00
CalamitousFelicitousness 98ea64943f fix(modelloader): convert ModelCardData to dict before saving model_info.json 2026-05-21 03:11:05 +01:00
CalamitousFelicitousness 394d4e5b84 fix(ltx): patch connectors regression and group model dropdown
- monkey-patch LTX2ConnectorTransformer1d.forward to restore pre-#13564
  padding logic when the upstream torch.flip pattern is detected; fixes
  word-order scrambling in audio dialogue tracks
- reorganize LTX model entries into version-group separators (2.3 v1.1,
  2.3 v1.0, 2.0, 0.9.x) with base/distilled subgroups; separators are
  selectable no-ops handled in run_ltx
2026-05-21 03:01:51 +01:00
Disty0 40bd5ca00d Make Triton MM block sizes configurable 2026-05-20 19:16:21 +03:00
Vladimir Mandic 4b2f38ab7f complete refactor javascript to typescript and reorg frontend files and folders
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-20 18:08:10 +02:00
Disty0 4341193b35 SDNQ trigger triton_mm autotune for every multiple of 64 instead of 1 2026-05-20 15:36:12 +03:00
Disty0 cad5ab19c8 SDNQ use torch.compile friendly hadamard cache 2026-05-19 22:18:58 +03:00
Vladimir Mandic 01a68baa47 update masking
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-19 11:56:20 +02:00
Vladimir Mandic a56d1d299e add wildcards to image metadata and note separate template from prompt field
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-19 09:45:20 +02: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
CalamitousFelicitousness 6ad67319de refactor(lora): add generic loaders for IA3/GLoRA/Norm/Full
Same parameterized shape as the core 4.

- IA3: .on_input is the marker disambiguator (.weight is too generic).
  Fused targets skipped.
- GLoRA: requires a1/a2/b1/b2 per group. Fused skipped (target-dependent
  term doesn't slice cleanly).
- Norm: never fused. Loader-local network_layer_name stamping bypasses
  lora_convert's transformer-norm guard without changing the carve-out.
- Full: fused skipped (no chunk class for diff tensors).
2026-05-18 23:18:51 +01:00
CalamitousFelicitousness d2fd08fe3c refactor(lora): add generic loaders for LoRA/LoKR/LoHA/OFT
Family loaders parameterized on per-arch resolve_targets callable and
prefix tuples. Build network keys as
"lora_transformer_" + path.replace(".", "_").

Fused-target handling:

- LoRA: chunk at load time, supports both equal and unequal ChunkSpec
- LoKR: dispatch to NetworkModuleLokrChunk (equal) or LokrSliceChunk
  (unequal), materialize kron(w1, w2) lazily
- LoHA: NetworkModuleHadaChunk for equal only; Tucker-on-fused and
  unequal skipped with warning
- OFT/BOFT: fused skipped with warning. Algorithm discriminated by
  oft_blocks.ndim (3-D OFT, 4-D BOFT)

Plus try_load_chain umbrella for per-arch family-iteration wrappers.
2026-05-18 23:18:41 +01:00
CalamitousFelicitousness cbaaf1c88c refactor(lora): move NetworkModuleLokrSliceChunk to network_lokr
Lifts the slice variant from chroma_lora into network_lokr so the generic
LoKR loader can dispatch to either NetworkModuleLokrChunk (equal chunks)
or NetworkModuleLokrSliceChunk (unequal ranges) based on ChunkSpec shape.

chroma_lora keeps the same slice path through an updated import.
2026-05-18 23:18:31 +01:00
CalamitousFelicitousness 7c32d97121 refactor(lora): extract native adapter scaffolding to native_loader
Lifts the parts of the per-arch native loaders that are byte-identical
across z-image, chroma, ernie, and flux2 into a new shared module.

- Suffix and marker tables for all nine families
- SUFFIX_NORMALIZE (lora_A/lora_B to lora_down/lora_up)
- KNOWN_PREFIXES_DEFAULT and BARE_DIFFUSERS_PREFIX_USED sentinel
- ChunkSpec dataclass for fused-weight slicing (equal idx+total or
  unequal start+end)
- unwrap_peft_wrapper and strip_peft_adapter_name
- has_marker, resolve_mapping, new_network, finalize_network, shapes_match
- Parameterized parse_key and group_by_suffixes
2026-05-18 23:18:22 +01:00
Disty0 46f37232b3 Fix hadamard not registering 2026-05-18 23:54:23 +03:00
Disty0 a896719713 Fix dynamic quant with svd + hadamard combination 2026-05-18 23:31:18 +03:00
Disty0 069a1c927d Fix dynamic quant 2026-05-18 22:44:50 +03:00
Disty0 051c66aa6f ipex fix torch.compile 2026-05-18 21:38:09 +03:00
Vladimir Mandic b2223c7f8c nunchaku improvements
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-18 19:33:16 +02:00
Disty0 927994d47d gate recompile_limit behind torch version 2026-05-18 19:28:05 +03:00
Disty0 65b9c8803f SDNQ use cache for hadamard matrix 2026-05-18 18:20:32 +03:00
Disty0 ac31b897b9 PyTorch ignores the global re_compile limit now 2026-05-18 17:53:27 +03:00
Disty0 e3b1eb71a1 cleanup 2026-05-18 17:10:31 +03:00
Disty0 c227d5fa10 SDNQ add Hadamard Rotation support 2026-05-18 17:06:11 +03:00
awsr 2a0f55e0b5 Additional minor typing 2026-05-17 11:14:55 -07:00
awsr 027133b3bd Typing cleanup 2026-05-17 10:41:09 -07:00
awsr 5520e9555d Typing and type narrowing 2026-05-17 10:40:28 -07:00
awsr 39db2cf706 processing_class typing and defaultdict
Use defaultdict for network_data to match usage elsewhere
2026-05-17 10:22:34 -07:00
awsr ad0afa6fb9 processing_prompt typing 2026-05-17 10:21:39 -07:00
awsr 45f6027a92 sd_checkpoint typing 2026-05-17 10:21:01 -07:00
awsr 6e153e1980 Cast correct type for opts.lora_force_reload 2026-05-17 10:06:43 -07:00
awsr 8fed5afe62 Fix method signature 2026-05-17 10:06:31 -07:00
awsr 3ff0c6d8be Add typing 2026-05-17 10:05:43 -07:00
awsr 4e5291b1f8 Document reason for type ignore 2026-05-17 09:55:38 -07:00
awsr 4944a296c2 Move extra_data type hint 2026-05-17 09:55:00 -07:00
awsr 25428ad176 Fix argument type inference and organize imports 2026-05-17 09:52:11 -07:00
Disty0 39b768564a update ipex and rocm to torch 2.12 2026-05-17 18:26:19 +03:00
Oleksandr Liutyi 72e23ebdf6 fix compatibility to sdnext-scheduler 2026-05-17 12:30:11 +00:00
Vladimir Mandic 2270580a40 improve settings search
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-17 09:59:38 +02:00
Vladimir Mandic dd796552db use snapshot path for downloaded model
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-17 09:14:50 +02:00