Commit Graph

13456 Commits

Author SHA1 Message Date
Vladimir Mandic e50fc62ee7 fix networks click-select
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-23 07:36:55 +02:00
Vladimir Mandic 60e6c37e24 fix script params
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-22 18:28:22 +02:00
Disty0 1377495998 lint 2026-05-22 18:21:22 +03:00
Vladimir Mandic 082498e6bd prompt-enhance-v2 with steering
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-22 16:58:23 +02:00
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 9457a8282e fix(ui): expose cardClicked on window for inline onclick handlers
modules/ui_extra_networks.py emits onclick="cardClicked(...)" on
every network card, but cardClicked was module-private in
ui/extraNetworks.ts and got tree-shaken out of the bundle. Attach
it to window like showCardDetails so card clicks resolve and the
<lora:...> insertion path works.
2026-05-22 01:53:41 +01:00
CalamitousFelicitousness 5a837224b9 Merge pull request #4863 from vladmandic/refactor/anima-native-loader
refactor(anima): migrate to generic native_loader
2026-05-22 01:24:04 +01: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
Vladimir Mandic 32d245898c update readme and wiki
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-20 20:28:28 +02:00
Vladimir Mandic 68d73a2aca update contributing
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-20 20:15:48 +02:00
Vladimir Mandic e03557462a update ai instructions
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-20 20:09:06 +02: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 6937ea803f refactor(ernie): migrate to generic native_loader
Replaces ernie's four family loaders with thin wrappers binding
native_loader's generics to ernie's prefix tuples and resolve_targets.

ErnieImageAttention has fully split to_q / to_k / to_v with no fused QKV
and ErnieImageFeedForward has three separate Linear modules, so
resolve_targets is a straight passthrough across every recognized prefix.

BARE_DIFFUSERS_PREFIXES covers layers., adaLN_modulation., final_norm.,
final_linear. for bare-diffusers exports (e.g. via save_lora_adapter).

parse_key returns (prefix_used, base, suffix) instead of the old
(network_key, suffix); parse test updated.
2026-05-18 23:34:41 +01:00
CalamitousFelicitousness e45c23c031 refactor(chroma): migrate to generic native_loader
Replaces chroma's four family loaders with thin wrappers binding
native_loader's generics to chroma's prefix tuples and resolve_targets.

resolve_targets folds the Flux-to-diffusers rename table and the two
fused-weight splits into one path-resolution step:

- img_attn.qkv / txt_attn.qkv: ChunkSpec(idx, total=3) for equal Q/K/V
- single_blocks.linear1: ChunkSpec(start, end) for the unequal
  Q/K/V/proj_mlp partition

QKV_DIMS and LINEAR1_DIMS stay as module-level constants (tests patch
them for the scaled-down mock).

Behavior changes:

- LoKR on equal-chunk QKV now dispatches to NetworkModuleLokrChunk
  instead of NetworkModuleLokrSliceChunk (the slice variant was used
  pre-migration for both forms since chroma had no equal-chunk path).
- LoHA on fused img_attn.qkv now binds via NetworkModuleHadaChunk
  instead of being skipped; the shared HadaChunk added in the flux2 PR
  is general for equal-chunks dispatch.

parse_key returns (prefix_used, base, suffix) instead of the old
(flat_key, suffix); rename happens in resolve_targets. test_static_rename_table
replaced with test_resolve_targets_static_renames driving the same
remappings through the new interface.
2026-05-18 23:31:17 +01:00
CalamitousFelicitousness c3b7379fd3 refactor(zimage): migrate to generic native_loader
Replaces zimage's four family loaders with thin wrappers binding
native_loader's generics to z-image's prefix tuples and resolve_targets.

resolve_targets folds the legacy attention.qkv split and attention.out
alias rename into the path-resolution step. Fused qkv now emits three
ChunkSpec(idx, total=3) entries; attention.out / attention.out.0 /
attention.wo aliases collapse to attention.to_out.0.

BARE_DIFFUSERS_PREFIXES allows bare paths starting with layers. /
noise_refiner. / context_refiner. to pass through to the loader. This
matches real Z-Image LoRAs exported via
ZImageTransformer2DModel.save_lora_adapter().

LoHA on fused qkv now binds via NetworkModuleHadaChunk (added to shared
infra by the flux2 PR) instead of being skipped. Test renamed to
test_loha_legacy_fused_qkv_chunked.

parse_key returns (prefix_used, base, suffix) instead of the old
(network_key, suffix); parse test updated.
2026-05-18 23:20:03 +01:00
CalamitousFelicitousness c7e8e7a029 test(ernie): offline tests for native adapter loaders
Covers ernie's four-family surface (LoRA, LoKR, LoHA, OFT).

ErnieImageAttention has fully split to_q / to_k / to_v with no fused QKV,
and ErnieImageFeedForward has three separate Linear modules. The loader
has no chunking, renames, or fused-target dispatch.

Mock matches diffusers.ErnieImageTransformer2DModel
(ErnieImageSharedAdaLNBlock with self_attention + mlp + RMSNorms, plus
module-level adaLN_modulation Sequential and final_linear).

Formats exercised:

- BFL / AI-toolkit
- kohya
- BFL LoKR
2026-05-18 23:19:46 +01:00
CalamitousFelicitousness 1f309fe836 test(chroma): offline tests for native adapter loaders
Covers chroma's four-family surface plus the Flux-to-diffusers rename
and the unique single-block linear1 unequal-chunk slicing.

Mock transformer matches diffusers.ChromaTransformer2DModel
(transformer_blocks with FluxAttention(added_kv_proj_dim), single
transformer_blocks with pre-only attn + proj_mlp + proj_out, plus
distilled_guidance_layer).

Formats exercised:

- BFL / AI-toolkit
- kohya
- PEFT
- LyCORIS oft_diag

install_mock_pipe patches chroma_lora.QKV_DIMS and LINEAR1_DIMS to the
test scale (HIDDEN=96, MLP_HIDDEN=384); the module otherwise hardcodes
Chroma1-HD's 3072 / 12288.
2026-05-18 23:19:35 +01:00
CalamitousFelicitousness be46362e3e fix(chroma): prepend lora_transformer_ to LoKR slice_info keys
try_load_lokr renamed slice_info keys via static_rename but didn't add
the lora_transformer_ prefix that apply_static_rename adds to the groups
dict. slice_info.get(network_key) always returned None for fused targets,
so the loader fell back to NetworkModuleLokr instead of
NetworkModuleLokrSliceChunk on every fused-QKV / fused-linear1 adapter.

The full kron(w1, w2) was applied against split target modules, either
shape-mismatching at apply time or broadcasting wrong.

Caught by test_lokr_bfl_img_attn_qkv_slice_chunked. No real-world chroma
LoKR adapters on fused targets are known in the wild.
2026-05-18 23:19:24 +01:00
CalamitousFelicitousness 409a30f9e0 test(zimage): offline tests for native adapter loaders
Covers z-image's four-family surface (LoRA, LoKR, LoHA, OFT). Mock
transformer matches diffusers.ZImageTransformer2DModel (layers,
noise_refiner, context_refiner).

Formats exercised:

- BFL / AI-toolkit
- PEFT
- kohya
- Legacy fused attention.qkv (split by expand_legacy_attention_*)

Covers parse primitives, all four loader entry points, DoRA threading,
calc_updown shape sanity per family.
2026-05-18 23:19:13 +01:00
CalamitousFelicitousness 5ff32038f1 refactor(flux2): migrate to generic native_loader
Replaces flux2's eight family loaders with thin wrappers binding
native_loader's generics to flux2's prefix tuples and resolve_targets.

Constants and helpers (has_marker, parse_key, group_by_suffixes) are
re-exported from native_loader so the offline tests address them through
flux2_lora's surface unchanged.

resolve_targets now returns (diffusers_path, ChunkSpec | None) tuples
instead of (path, idx, num_chunks). Three parse-level tests updated.

PEFT-fallback path (apply_lora_alphas, preprocess_f2_keys, apply_patch)
stays in flux2_lora.
2026-05-18 23:19:03 +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 9fd27197b7 update changelog/todo
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-18 19:33:16 +02:00
Vladimir Mandic fdda09c7e5 fix ui server log monitor
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-18 19:33:16 +02: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