Commit Graph

13441 Commits

Author SHA1 Message Date
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 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
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
Vladimir Mandic 88583fe745 Merge pull request #4858 from awsr/typing-merge-1
Additional typing updates
2026-05-18 08:29:54 +02:00
CalamitousFelicitousness 10b652cc6c revert stable cuda 13.2 to 13.0 (ampere segfault) 2026-05-18 03:25:06 +01:00
awsr 2a0f55e0b5 Additional minor typing 2026-05-17 11:14:55 -07:00
Vladimir Mandic 7ab3007e92 update torch==2.12 with cuda==13.2
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-17 20:14:35 +02: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