65 Commits

Author SHA1 Message Date
CalamitousFelicitousness 259e15fafe feat(lora): per-layer select stack modes klora and estlora
Two-network subject+style sets select a winner per layer instead of
summing: scores are top-K magnitude sums (klora) or Frobenius energies
(estlora), and a timestep ramp shifts layers from the subject network
toward the style network across sampling, reduced to at most one
precomputed flip per layer per pass. On sub-8-bit SDNQ the pair rides
the side-channel as separate segments flipped in place; other layers
recompute the winner from the pristine backup, so select modes force
backup mode. Selection resets per pass from the callback setup and is
gated off under model compile. estlora's measured style-discrepancy
term is exposed as an option. Adds XYZ axes for the stack settings.
2026-08-28 13:09:25 +01:00
CalamitousFelicitousness 2396185393 feat(lora): dense stack modes for multi-network sets
Add lora_stack_mode with ties, dare_ties, dare_linear and
magnitude_prune combination of per-network deltas when several loaded
networks target one layer; sum stays the default and the exact factor
path. Combined deltas ride the existing tail: hosted svd on sub-8-bit
SDNQ, requantize at int8 and above, direct add elsewhere. Text-encoder
layers and single-network sets keep plain summation. DARE masks draw
from per-layer sha256 seeds so re-applies and cache entries stay
deterministic; the stack settings join the activation and factor-cache
signatures so settings changes re-apply without a reload.
2026-08-28 13:09:00 +01:00
CalamitousFelicitousness 9b37a1535c fix(lora): exact lora application on sdnq-quantized layers
Baking a lora into a quantized weight requantizes it, and on low-bit
formats round-to-nearest erases sub-step deltas (uint4 retains roughly
2/group_size of the signal). Plain lora deltas now ride the sdnq svd
side-channel: factors append to svd_up/svd_down with the down factor
hadamard-rotated, applied by the dequantizer at full precision in every
forward mode. Apply and remove are exact and take no weight backup.

- non-factorable families (dora, lokr, loha, oft, cp mid, dense bias)
  fall back to requantize with a per-pass summary warning
- native fuse now honors the quantized-model guard; fuse requantized in
  place on every network swap and accumulated drift
- layers that fell back on a mixed set restore from backup before
  re-entering the factor path; untargeted quantized layers are no
  longer flagged
- test/test-sdnq-lora-factors.py pins the erasure law, factor-path
  exactness, memory accounting and set transitions
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 6a354cdbc6 fix(lora): apply bias deltas onto the bias, not the weight
network_add_weights defaulted its base tensor to self.weight for the bias
delta as well, so in fuse mode a diff_b was added to the weight matrix and
the result written into the bias. Layers where in and out differ threw a
shape error and had the weight matrix installed as their bias, square layers
broadcast silently, and either way the summary still counted the delta as
applied.

- pick the base tensor from the bias flag
- name the layer, target and both shapes in the mismatch error
- return which of (weight, bias) took a write, count the rest as refused
- report refused= on partially applied and partially removed networks
- cover both apply paths in test/test-lora-apply.py
2026-08-21 01:42:25 +01:00
Dity0 251945939b Add Lloyd-Max quantization with use_codebook 2026-08-10 22:51:32 +03:00
Dity0 712a13f1a0 Move SDNQ to upstream SDNQ repo 2026-08-10 12:13:10 +03:00
CalamitousFelicitousness bf0be3da69 fix(lora): keep applied and restored weights on their original storage
Backup-mode apply and restore installed fresh Parameters. Matmul kernel
selection is sensitive to operand placement, so the first load/remove cycle
shifted otherwise deterministic renders once per process even though every
weight restored byte-exact: bit-identical inputs entered the first post-cycle
unet forward and a different output left it. Copying into the existing
parameter keeps each touched module on its load-time allocation and drops the
per-layer transient of holding old and new weights side by side.

- assign_weight writes weight and bias installs in place when shape, dtype
  and device match; quantized fallback layers keep their rebuild path
- regression test pins storage stability across the activate walk
2026-08-10 02:43:23 +01:00
Vladimir Mandic 4cf2854c93 update ruff and lint
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-24 18:20:41 +02:00
Vladimir Mandic 7eacfafa4a lora guard against param change on-the-fly
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-01 15:53:38 +02:00
Disty0 c227d5fa10 SDNQ add Hadamard Rotation support 2026-05-18 17:06:11 +03:00
Disty0 297ab4bb60 SDNQ Lora fix dtype 2026-05-16 13:13:41 +03:00
Disty0 8e11971572 Fix SDNQ Lora 2026-05-15 21:25:08 +03:00
CalamitousFelicitousness 1750a2881e fix(lora): use is-not-none check for ex_bias accumulation
Truthiness on a tensor raises when stacking multiple Norm/Full
adapters. Match the updown accumulation pattern five lines above.
2026-05-09 22:04:42 +01:00
vladmandic ab7fd5b5e6 cleanup
Signed-off-by: vladmandic <mandic00@live.com>
2026-04-21 19:45:51 +02:00
vladmandic db670b8bca fix sdnq-lora
Signed-off-by: vladmandic <mandic00@live.com>
2026-04-21 19:44:18 +02:00
vladmandic 456d17fcd3 cleanup bnb references
Signed-off-by: vladmandic <mandic00@live.com>
2026-04-12 19:06:08 +02:00
vladmandic 91bba59c0d fix lint
Signed-off-by: vladmandic <mandic00@live.com>
2026-04-12 19:06:08 +02:00
vladmandic afe3786f5f add unet/dir to networks
Signed-off-by: vladmandic <mandic00@live.com>
2026-03-22 11:09:45 +01:00
awsr d34896028d Make elimit kwarg optional 2026-03-19 04:41:37 -07:00
awsr 6e3c187b3f Rework to only use contextmanager system 2026-03-19 04:28:11 -07: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
Disty0 259a38a2ed fix sdnq lora 2025-12-27 23:07:53 +03:00
Disty0 b6e9332cfe SDNQ de-couple matmul dtype and add fp16 matmul 2025-11-22 02:16:20 +03:00
Disty0 3fbfae5963 cleanup 2025-11-18 02:37:10 +03:00
Disty0 524e92eee2 SDNQ fix Loras 2025-11-18 01:47:35 +03:00
Disty0 6f33ec3357 SDNQ use the model quant params instead of user settings on Lora 2025-11-10 00:12:38 +03: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 b601f0d402 SDNQ expose svd_steps and update module skip keys 2025-10-14 00:15:09 +03:00
Disty0 5c042c5fb8 cleanup 2025-10-06 11:30:26 +03:00
Vladimir Mandic a315a004e9 linting
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2025-10-05 20:25:33 -04:00
Disty0 9e52d0c1fb SDNQ add SVDQuant quantization method 2025-10-05 22:50:30 +03:00
Disty0 54acf1760b Make SDNQ scales compatible with balanced offload 2025-10-03 18:13:55 +03:00
Disty0 afb3a5a06d SDNQ move non_blocking to quant config 2025-08-11 15:07:02 +03:00
Disty0 86cd272b96 SDNQ fix Dora 2025-06-18 16:24:42 +03:00
Disty0 25fc0094a9 SDNQ use quantize_device and return_device args and fix decompress_fp32 always being on 2025-06-14 21:29:08 +03:00
Disty0 2ba64abcde Cleanup 2025-06-14 00:54:18 +03:00
Disty0 5e013fb154 SDNQ optimize input quantization and use the word quantize instead of compress 2025-06-12 12:06:57 +03:00
Disty0 5eed9135e3 Split SDNQ into multiple files and linting 2025-06-10 03:18:25 +03:00
Disty0 976f0ba61f Cleanup 2025-06-05 20:59:58 +03:00
Disty0 90324f9c8c SDNQ fix lora with quant matmul 2025-05-29 18:25:12 +03:00
Disty0 dece497f10 Refactor SDNQ to use weights_dtype and rename decompress_int8_matmul to use_quantized_matmul 2025-05-27 15:49:21 +03:00
Disty0 280be31883 SDNQ fix Lora change 2025-05-27 00:08:32 +03:00
Disty0 84ddfb2868 SDNQ fix lora apply 2025-05-26 22:39:20 +03:00