Commit Graph

14498 Commits

Author SHA1 Message Date
CalamitousFelicitousness e2202bfbdf feat(lora): log exact side-channel applies
The exact factor path was the only apply route with no log line; its
success read as silence. Track layers taking it beside the hosted and
fallback lists and report all three as key=value apply lines
(apply=exact/hosted/requantize); the stack fallback notices use the
same form. The suite pins its stack-mode baseline to sum so a mode
left set in user config cannot reroute tests that assume plain
summation.
2026-08-28 13:09:26 +01:00
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
Vladimir Mandic 03a41e63c6 Merge pull request #5067 from vladmandic/feat/lora-sdnq-cache
perf(lora): factor cache and hosting improvements for sdnq exact apply
2026-08-28 13:32:44 +02:00
Vladimir Mandic d776194ec4 Merge branch 'dev' into feat/lora-sdnq-cache 2026-08-28 13:32:35 +02:00
Vladimir Mandic 68d892e6b2 modular pipelines intercepts and profiling
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-28 13:32:14 +02:00
Vladimir Mandic a8f15e7b5f Merge branch 'dev' into feat/lora-sdnq-cache 2026-08-27 08:49:44 +02:00
Dity0 37ac1b64c9 point sdnq logger to sdnext logger 2026-08-27 03:15:18 +03:00
Dity0 e1767aa72d remove sdnq.sdnext hijacks 2026-08-27 02:47:03 +03:00
CalamitousFelicitousness 2306867b63 perf(lora): store hosted factors at the delta's effective rank
Hosted truncation kept the full rank cap even when the spectrum ends in
numerical zeros, padding exactly low-rank deltas (low-rank LyCORIS,
full-family diffs) up to the cap. Slice the kept factors where
cumulative capture reaches 1 - 1e-6 of the sketch total, and trim
trailing all-zero columns when attaching cache entries written before
the slice, so they collapse the same way without a format bump. The
hosted log line reports the realized rank spread when it sits below
the cap.

- flat spectra keep the cap; a rank-8 delta under cap 256 stores 8 ranks
- select segments follow the effective rank
- suite pins the collapse, the flat-spectrum guard and the padded-entry trim
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness 0c1b087e20 perf(lora): serve hosted layers from the factor cache before delta assembly
A cache hit still paid full calc_updown per layer, the dominant cost of a
replayed apply. The walk now probes the pass's cache entry first through
apply_cached, which evaluates the requantize routing rule from the delta
rms stored in the entry and attaches the cached factors without assembling
the delta; layers the rule declines fall through with the assembled delta
reused for the requantize path instead of recomputing it. The entry format
gains the rms and bumps to fmt 5, so older files recompute once and
rewrite. Hit accounting stays single-count through a plain lookup plus an
explicit hit note.

- replayed krea2 LoKR apply drops calc from 9.1s to 0.2s and activate
  from 39.5s fresh to 4.8s replayed, hosted/routed split identical
- three cache tests pin the calc skip on plain, mixed and dense-pair sets
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness 179978a555 feat(lora): route fat non-factorable deltas back to requantize
Hosting truncates every non-factorable set on sub-8-bit layers, but a
delta large against the grid step whose truncation capture is low is
retained better by the grid than by the rank cap. apply_hosted now
returns such layers to the requantize path when rms(delta)/mean(step)
exceeds 0.30 and the sketch capture falls below 0.90, thresholds sized
on 610 calibrated modules across krea2 and anima. Both terms must
agree: a thin delta rounds away on the grid however low its capture,
and a low-rank delta hosts exactly however fat it is.

- scoped to pure non-factorable sets; factorable members, dense-combined
  deltas and svd-channel checkpoints keep hosting
- factor cache entries memoize the decision through their stored
  capture, so replays route without re-running the sketch
- routed layers log as info apart from the forced-fallback warning
- the fidelity CLI applies the same rule so its reports track the loader
- seven routing tests, constants module-level and test-overridable
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness e33965fc3b fix(lora): bound calibration capture and cover unet denoisers
Persist now fires either when every hooked layer reaches the token quota
or at a fixed denoiser-forward deadline; layers under a small token floor
are omitted and stay on plain truncation. The all-done barrier alone
never fired on models whose modulation or pooled projections see a few
tokens per forward, so hooks stayed registered forever and statistics
recollected every session. eligible_modules walks the transformer or the
unet, so unet checkpoints collect statistics at all.

- lora_sdnq: drop the unused use_previous parameter; the factor cache
  store now always runs inside a begin_pass
- tests: deadline persist, token-floor omission, unet root walk
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness ff94565da8 perf(lora): pad side-channel factor ranks to fixed buckets
The compiled dequant specializes per factor rank, so each distinct lora
set shape paid a compile stall on switch. Pad appended factors to a
power-of-two rank ladder (multiples of 64 past the hosted cap) with zero
fill: switches inside a bucket reuse the compiled graph, and common
trained ranks land on their bucket exactly so padding is usually a
no-op. Regression tests pin the factor add inside the single compiled
graph and the bucket reuse.
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness 74e68b58ce perf(lora): oversample the hosted-factor sketch to near-exact svd
Sketch hosted deltas at rank+64 with eight power iterations and keep the
top rank columns; this lands within noise of the exact decomposition at
roughly twice a sketch cost the factor cache pays once per configuration.
Bump the cache format so narrower-sketch entries reload as misses.
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness 03dfddaa96 perf(lora): int8 storage for cached hosted factors
Rowwise int8 with fp32 scales halves cache entries; measured in output
space on real hosted deltas the roundtrip is fidelity-free (within
0.0003 of fp32 factors, bf16 storage likewise). Factors are quantized
before first use and the dequantized roundtrip is what the apply
attaches, so a fresh compute and a later cache hit stay bit-identical;
the entry format is versioned and pre-int8 entries reload as misses.

- lora_factor_cache: quantize_rowwise/dequantize_rowwise, store returns
  the applied pair, fmt guard on read
- test/test-sdnq-lora-factors.py: int8 quantization test, entry-size
  assertion in the roundtrip test
2026-08-26 23:48:35 +01:00
CalamitousFelicitousness a2daf9027c feat(lora): disk cache for hosted svd factors
Hosting a non-factorable set costs one truncated svd per layer on every
fresh apply. The factors are deterministic in the checkpoint, the loaded
set, the host rank and the calibration statistics, so they persist under
data/lora-factor-cache keyed by that identity and replay bit-identically
on later applies. lora_sdnq_host_cache sets the disk budget in GB
(0 disables), least-recently-used entries are evicted past it. With the
cost paid once per configuration, svd subspace iterations rise from 2 to
4: about two thirds of the captured-energy gap to an exact decomposition
for +45% one-time compute; an exact svd measures 200-400x slower at
these shapes and is not viable.

- modules/lora/lora_factor_cache.py: signature, store, flush, eviction
- lora_sdnq.apply_hosted: fetch before computing, store after, hits in
  the load summary
- cli/lora-quant-fidelity.py: matching niter for the hosted mirror
- test/test-sdnq-lora-factors.py: factor-cache category, 3 tests
2026-08-26 23:47:44 +01:00
Vladimir Mandic b14ce1032b update changelog
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-26 16:13:12 +02:00
Vladimir Mandic 4be7d3c761 Merge pull request #5052 from vladmandic/feat/attention-core
Feat/attention core
2026-08-26 15:59:39 +02:00
Vladimir Mandic 79a843474d Merge branch 'dev' into feat/attention-core 2026-08-26 15:59:28 +02:00
Vladimir Mandic 7a489d42f5 Merge pull request #5066 from vladmandic/lora-exact
merge lora-exact into dev
2026-08-26 15:59:00 +02:00
Vladimir Mandic 54624debd8 Merge pull request #5044 from vladmandic/feat/lora-sdnq-exact
feat(lora): exact lora application on sdnq-quantized models
2026-08-26 15:58:10 +02:00
Vladimir Mandic 4cdcbd5cdc Merge branch 'lora-exact' into feat/lora-sdnq-exact 2026-08-26 15:58:00 +02:00
Vladimir Mandic 609e9003f1 Merge pull request #5065 from vladmandic/dev
refresh branch
2026-08-26 15:57:16 +02:00
Vladimir Mandic d0cceefd0f Merge pull request #5064 from vladmandic/dev
refresh branch
2026-08-26 15:48:41 +02:00
Vladimir Mandic 213f0b8048 Merge branch 'master' into dev 2026-08-26 11:17:33 +02:00
Vladimir Mandic fca27159ef update changelog/todo
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-26 11:00:10 +02:00
Vladimir Mandic acb4e758d3 add heif/heic support
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-26 10:24:17 +02:00
Vladimir Mandic 0fde1f4dae Merge pull request #5061 from crashingalexsan/dev
Pin stable ROCM 7.14, rework multi arch installation
2026-08-26 10:12:25 +02:00
Alejandro Alberto Aguilar Morales 3edaed8e77 Pin stable ROCM 7.14, rework multi arch installation 2026-08-26 01:17:54 -06:00
Vladimir Mandic 6cdc3bba7e switch to pillow-heif
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-26 07:49:26 +02:00
Vladimir Mandic 144c00efdd Merge pull request #5060 from vladmandic/fix/queue-lock-exception-suppression
fix(queue): stop the queue lock from suppressing exceptions
2026-08-26 07:31:39 +02:00
CalamitousFelicitousness cb06447426 fix(video): report a cancelled generation as 499
process_images swallows the interrupt assertion, so a cancel reaches the shared
video core as an empty result and was raised as 'processing failed' with 500,
leaving clients unable to tell a cancel from a crash. Mirrors the LTX path,
which already returns 499.
2026-08-26 04:28:59 +01:00
CalamitousFelicitousness 78a49eab33 fix(queue): stop the queue lock from suppressing exceptions
Queue.__exit__ returned _queue_lock, and a truthy __exit__ return suppresses the
exception in flight, so every `with queue_lock:` block discarded exceptions and
resumed with locals from the aborted block unassigned. The bare threading.Lock it
replaced returned None.
2026-08-26 03:36:15 +01:00
CalamitousFelicitousness 3f80bb05b0 docs(ltx): correct the refine default comment and stale file references
The refine-default comment claimed Condition variants are excluded from two-stage
refine, but supports_two_stage_refine has no such carve-out and ltx_process builds
a second condition set so conditioning survives the upsample. Two file references
had also drifted: ltx_process.py:179 moved, and the offload hook keying now lives
in sd_offload_balanced. Name the symbols instead of the line numbers.
2026-08-25 23:21:21 +01:00
Dity0 99112c9be1 switch rocm nightlies to rocm 7.14 2026-08-25 12:34:55 +03:00
Vladimir Mandic 1946892b7f improve memory reporting, explicit interpolation and minimax tracking
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-08-25 09:11:46 +02:00
CalamitousFelicitousness 4ae6515163 feat(lora): quantized apply method setting
New lora_sdnq_apply radio (exact, requantize) in the lora settings.
requantize keeps the previous behavior: every quantized layer takes the
dequantize-add-requantize path, with factor attach and svd hosting gated
off. A settings-only flip re-applies loaded networks: the mechanism
rides a per-module apply stamp and the network-changed signature, and
the activate fallthrough strips factors a closed gate leaves attached.
Requantize chosen by the setting logs as info instead of the
reduced-fidelity warning.

- locale hint covers fidelity and memory tradeoffs of both methods
- suite: gate, legacy routing and flip-transition tests
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 8c377aeeee refactor(settings): dedicated lora settings tab
The lora block moves out of Networks into its own settings tab, with
header groups by what each option acts on: loading, prompt, application,
quantized models and metadata. Locale hints follow to the new section.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 82a7e94450 feat(lora): activation-weighted hosting via per-checkpoint calibration
Plain svd truncation of hosted deltas is optimal in weight space but not
in output space: activations concentrate energy in a few input channels,
so scaling the delta by per-channel input RMS before the svd spends the
rank budget on output error instead. Statistics stream from the model's
own forwards on sub-8-bit SDNQ checkpoints and cache per checkpoint;
measured on real LoKR files this raises output-delta retention by ~0.05
at rank 256 and ~0.09 at rank 64, most on MLP down projections.

- modules/lora/lora_calib.py: capture hooks, per-checkpoint cache under
  data/sdnq-calib, statistics land on layers as sdnq_calib_rms; gated by
  lora_sdnq_host_calib, skipped when the model is compiled
- lora_sdnq.apply_hosted: weighted truncation when statistics exist,
  calib count in the load summary
- cli/sdnq-calibrate.py: complete calibration now against a live server
- cli/lora-quant-fidelity.py --calib: hosted rho scored in the
  activation-weighted norm
- test/test-sdnq-lora-factors.py: calibration category, 5 tests
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 37e33e4677 feat(cli): score hosted retention in the fidelity analyzer
Non-factorable modules on sub-8-bit formats report the hosted figure:
the seeded svd truncation at --host-rank realized through the bf16
materialize, mirroring the loader. The requantize figure stays in
requant_rho; --host-rank 0 restores the old scoring.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 6c0dd0b15f feat(lora): host non-factorable adapters on the sdnq side-channel
Non-additive families (lokr, loha, oft, dora, full) merged into the
quantized weight and lost most of their delta on low-bit formats. On
sub-8-bit layers the set's calc_updown delta now rides the svd
side-channel as its top singular directions instead: factorable members
are subtracted out and appended exactly, so only the non-factorable
remainder is truncated. Truncation keeps the dominant part of the
effect and drops an orthogonal residual, where requantize keeps the
grid extrema and adds grid-shift noise of the delta's own magnitude;
on real lokr files retention rises from 0.04 to about 0.5 at the
default rank.

Hosted layers take no weight backup and unload bit-exactly. The svd
runs under a forked rng so generation seeds are unaffected. At 8 bits
and above requantize retains most of the delta and remains the path.
lora_sdnq_host_rank caps the hosted rank; 0 disables hosting.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 9fa23b914e fix(cli): measure realized factor-path fidelity instead of asserting it
The analyzer scored factor-eligible modules applied_rho=1.0 by
construction. The side-channel stores the delta losslessly, but the
dequantizer materializes base + factors in the result dtype, so small
deltas round at the bf16 ulp of the base weight. Score the realized
delta through that rounding; sub-ulp loras now report the same floor an
unquantized bf16 model gives them instead of a false 1.0.

Also survive a broken file and keep completed work: per-lora failures
are recorded and skipped, the report json rewrites after every file,
and a complete flag marks a finished run.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness b5c58151be fix(lora): harden the sdnq factor path
- restore stashed svd factors onto the layer's current device; the
  stash tuple does not follow module device moves, so an offload
  between apply and remove left restored factors on a stale device
- recheck factor shapes for layers already in factor mode, so a
  malformed stacked network downgrades to the legacy path instead of
  raising in the concat
- clear the fallback log at activate entry so a raise mid-pass cannot
  leak stale entries into the next report
- pin both behaviors in the suite and state the compute-dtype fidelity
  floor in the module docstring
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 0b606b8b2a fix(cli): replicate the loader's requantize and survive non-matrix targets
Three defects surfaced by running the analyzer over a full local
collection against shipped checkpoints.

The requantize path hardcoded use_svd=False, but network_add_weights
requantizes with the layer's own svd setting and rank. On an svd
checkpoint the dequantized weight is not on the plain integer grid, so
requantizing without svd produced an error dominated by the discarded
correction and roughly orthogonal to the delta, which read back as a
retention near 1.0 on a grid where the delta is 0.005 of a step. Thread
use_svd, svd_rank and svd_steps through and reuse the returned factors.

Targets whose weight is not a matrix (norm and scale parameters, 205 of
them in one z-image extraction) reached the quantizer and the module stub,
both of which unpack two dimensions and raised. Skip and count them before
either. An all-zero delta (some full-rank extractions ship empty .diff)
divided by its own norm and reported nan; its retention is undefined
rather than erased, so it is excluded from the medians and counted.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 329d69f5df fix(cli): match module paths the way the loader does
Kohya-style files carry an already-underscored base (lora_unet_layers_0_
mlp_gate_proj), which the loader resolves by comparing network_prefix +
path.replace('.', '_') against each module's stamped name, so both sides
are underscored and the file loads. The analyzer instead looked the base
up as a literal dotted module path, so every module of such a file was
reported unmatched: 76 files in a local collection, including 36 of 57
anima and 5 of 10 chroma.

Fall back to a stamped-name index when the direct lookup misses. Dotted
bases are unaffected.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 6ea2c50d5d fix(cli): measure every adapter family in the fidelity analyzer
The analyzer only mapped plain-lora groups, so a file carrying no plain
lora (a pure lokr, for example) analyzed zero modules and fell through to
a 1.0 default: it reported perfect fidelity for exactly the files that
degrade most. Measured on the shipped krea 2 uint4 checkpoint, those
files land between 0.04 and 0.34.

Every targeted module is now rebuilt with the loader's own module class
and its delta read from the production calc_updown, so lokr, loha, oft,
full, ia3, glora, norm and the dora / dense-bias / diff_b variants are
measured as they apply; factor-path eligibility is decided by calling the
loader's own predicate. Modules carrying several families sum their
deltas the way the loader stacks them, and a family the tool cannot
rebuild is reported instead of counting as clean.

- report per-module applied fidelity (1.0 on the factor path, measured
  rho on the requantize path) as a median and an energy-weighted mean
- add --dtype bf16 to measure the unquantized reference rather than
  assert it
- drop the per-module empty_cache: it cost 16ms per module against 1ms
  of reuse, and the caching allocator already reuses the buffers
- keep shard handles open across modules
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 2fcd99a409 test(lora): cover sdnq config matrix in factor path suite
Checkpoints quantized without hadamard must attach factors unrotated;
checkpoints carrying their own svd correction must keep it under apply
and get the original factors back on remove. Both pinned in both svd
layouts.
2026-08-25 00:25:22 +01:00
CalamitousFelicitousness 9906afae08 feat(cli): lora quantization fidelity analyzer
Offline analyzer for a (model, lora) pair: maps lora modules onto the
transformer, measures per-module delta-to-step ratio and requantize
retention, and reports factor-path eligibility. Loads pre-quantized
sdnq repos or simulates quantization on bf16 repos; supports --json
and --fail-under for scripted checks.
2026-08-25 00:25:22 +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