7 Commits

Author SHA1 Message Date
CalamitousFelicitousness 783b66c3be refactor(lora): offer unknown bare keys to the resolver
A bare key that matches no known prefix is parsed with the
bare-diffusers sentinel and handed to the resolver instead of being
dropped at parse time. The per-arch lists of bare diffusers prefixes are
gone, and a path that names no live module counts as unmapped.
2026-09-06 04:25:44 +01:00
CalamitousFelicitousness 18bbe288b0 fix(lora): apply full-diff norm targets and map z-image's renamed modules
A full-weight extraction on Z-Image bound 308 modules and applied 172 of
them, silently dropping the rest, and left 71 more unmapped.

assign_network_names_to_compvis_modules puts every transformer module in
network_layer_mapping but skips stamping network_layer_name on norms,
which is the attribute the apply pass keys off. try_load_full bound those
modules through the mapping and they then never applied; stamp them
loader-locally, as try_load_norm already does.

Z-Image also names three module groups differently from the diffusers
tree: the qk-norms (q_norm/k_norm vs norm_q/norm_k), and the patch
embedder and final layer, which live in ModuleDicts keyed by
"{patch_size}-{f_patch_size}" and so carry a key the checkpoint has no
notion of. Read that key from the live model rather than hardcoding it.
The counts close exactly: 68 qk-norms plus 3 non-block targets are the 71
that went unmapped.
2026-07-14 08:06:45 +01:00
CalamitousFelicitousness b8cf912e4e feat(lora): run the full adapter family chain on every native arch
zimage, chroma, ernie and krea2 chained only lora/lokr/loha/oft while
flux2 and anima ran all eight families, so ia3/glora/norm/full files
(e.g. full-diff extractions with diff/diff_b keys) reported not loaded
on the short-chain arches. The generic family loaders are arch-agnostic;
wire the missing four into each chain.

- add ia3/glora/norm/full wrappers and chain entries to the four arch
  modules, with matching suffix/marker re-exports
- add a chain-level full-diff test per suite: zimage covers the legacy
  attention.out alias and the fused-qkv skip, chroma the proj rename,
  ernie the passthrough
2026-07-14 08:06:45 +01:00
CalamitousFelicitousness 1587b9682d feat(lora): support the lycoris_ prefix in every native adapter arch
The lycoris_ save format is arch-independent: LyCORIS standalone wraps
the loaded diffusers model and emits the wrapped module path with dots
as underscores, so verbatim passthrough is correct for any arch. Only
flux2 handled it; zimage, chroma, ernie and krea2 reported such files
as not loaded.

- add lycoris_ to KNOWN_PREFIXES_DEFAULT and PASSTHROUGH_PREFIXES_DEFAULT
- drop flux2's per-arch prefix append and resolve_targets branch
- add lycoris_ to ANIMA_PREFIXES (anima replaces the default tuple);
  network_prefix_for already routes it to the transformer namespace
- cover the passthrough with a zimage loader test
2026-07-14 08:06:45 +01:00
CalamitousFelicitousness 2d47b1f761 test(lora): cover OneTrainer lora_transformer_ format for native loaders
Add an end-to-end regression per diffusers arch (chroma, flux2, zimage, ernie)
that loads a lora_transformer_ diffusers-flat state dict and checks the
expected modules bind. The chroma suite also asserts the shared
resolve_group_targets passthrough runs above each arch's own resolve_targets,
which returns nothing for this prefix.
2026-06-14 18:22:41 +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 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