Commit Graph

14009 Commits

Author SHA1 Message Date
Vladimir Mandic 03473c1316 add loaded-loras api endpoint
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-12 13:10:35 +02:00
Vladimir Mandic d31a99edb0 ui format gallery
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-12 10:38:46 +02:00
Vladimir Mandic 22e132e6f0 rebuild ts
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-12 09:06:15 +02:00
Vladimir Mandic 99a963271e Merge pull request #4993 from vladmandic/feat/secondary-unet-networks
feat(ui): load unet into secondary slot from networks panel
2026-07-12 09:02:12 +02:00
CalamitousFelicitousness 00d1b7cff6 feat(ui): load unet into secondary slot from networks panel
The refine toggle doubles as the slot selector on the UNet/DiT page:
with it active a card click sets sd_unet_secondary instead of sd_unet,
mirroring base/refiner selection on the model page.
2026-07-12 03:50:48 +01:00
CalamitousFelicitousness cf031b869c feat(sdnq): add weight dequant and combined block sections to the benchmark tool
Benchmark weight dequantization alongside attention: eager vs compiled
dequantization, measured standalone and through the full linear forward,
plus the quantized matmul forward, across int/uint 8-6-4-2 and the
pre-quantized float formats (float8_e4m3fn, float8_e4m3fn_sdnq,
float4_e2m1fn group 16) at krea 2 layer geometry, against a bf16 nn.Linear
baseline and a true-fp32 output reference. Each row carries measured
storage size and one-shot quantize time; an svd/hadamard variants table
measures rotation and low-rank costs on top of the base dtypes.

A combined block section measures complete configurations (weights dtype x
matmul path x attention) end to end through a dit-style transformer block,
with output error at depth one and four against an fp32 reference block,
because component speedups and errors do not compose multiplicatively.

- recommendations weigh error against speed: a faster option is rejected
  when it multiplies measured output error beyond 2x, and reason strings
  cite both numbers; notes include measured size/error and speed/error
  frontiers
- robustness: extreme-activation stress rows in the correctness matrix
  (pass on finite output), max-token-error columns beside norm error, and
  non-finite outputs labeled as verdicts; norm metrics alone hide
  token-level corruption on outlier-heavy inputs
- probe compiled weight dequant for e4m3 and e5m2 storage and report the
  fp8 compile gate status; on ampere e5m2 compiles while e4m3 does not
- new attention presets: sdxl-cross (cross-attention), qwen3-te (causal
  gqa text encoder), wan22-cfg (batched cfg video); cross-attention
  correctness check
- --sections, --dequant-dtypes, --dequant-variants and --block-configs
  selectors, --json structured results output
2026-07-12 03:44:54 +01:00
CalamitousFelicitousness ce84b2d183 perf(model): adopt fp8 weights through the uint8 codec when fp8 cannot compile
Triton cannot compile e4m3 loads before sm_89, so fp8 weights fall back
to eager dequant there. The uint8-backed float8_e4m3fn_sdnq codec decodes
identically now that subnormals are handled (the two NaN codes become
+/-480), and its compiled dequant runs about 6x faster than eager native
fp8. Pre-quantized fp8 layers are viewed as uint8 at adoption when
compiled dequant is enabled on such hardware; the eager gate remains the
safety net for every other fp8 path.
2026-07-12 03:44:54 +01:00
CalamitousFelicitousness 5e1a0719ab feat(model): detect header metadata and nvfp4 in the model probe
detect_quant now reads _quantization_metadata as the authoritative quant
source when present, and resolves marker-file formats from the marked
layers' stored weight dtypes instead of file-wide dtype voting, which
mislabeled fp8 files carrying extra uint8 tensors and had no nvfp4
mapping at all. Schema bump so cached probe entries refresh.
2026-07-12 03:44:54 +01:00
CalamitousFelicitousness 0997526394 feat(model): load nvfp4 comfy_quant checkpoints via sdnq
nvfp4 layers keep their packed 4-bit codes and land on SDNQ grouped
quantization as float4_e2m1fn: the nibble order is swapped once at load,
the e4m3 block scales are unswizzled from the cuBLAS tile layout, and
the fp32 global scale folds into them as per-group scales. Marker
orig_shape acts as a cross-check and alignment padding is sliced
against the model dimensions.

- reject nvfp4 markers with unknown group sizes or convrot flags
- accept uint8 storage in the krea2 real-file check
2026-07-12 03:44:54 +01:00
CalamitousFelicitousness f05a3ae3e9 fix(sdnq): skip compiled dequant for fp8 weights without hardware support
Triton has no e4m3 conversions before sm_89, so any compiled graph
touching fp8 storage weights fails with an InductorError on Ampere.
Select the eager dequant and re-quantize paths for e4m3 weights when
the hardware cannot compile them; other dtypes keep compiled dequant.
SDNQ_ALLOW_FP8_COMPILE overrides the detection.
2026-07-12 03:44:54 +01:00
CalamitousFelicitousness 6e63f351eb refactor(ui): drop quicksettings companion machinery for secondary unet
The secondary unet loads from the networks panel toggle or the settings
page; companion ordering and dynamic visibility pushes in ui_settings.py
are not worth their footprint for one setting.
2026-07-12 03:44:20 +01:00
CalamitousFelicitousness 3fe54d1045 chore: rename probe cache files to signatures.json and civitai.json 2026-07-12 03:44:19 +01:00
CalamitousFelicitousness 4785dedc32 fix(ui): set refiner option from networks panel refine toggle
The hidden change_refiner button passed key='sd_model_checkpoint', so
loading a card with the refine toggle active reloaded the base model
and never set sd_model_refiner.
2026-07-11 20:26:12 +01:00
CalamitousFelicitousness 8291365955 refactor(model): simplify probe cache handling
json_helpers does its own error handling and file locking, so the
try/except wrappers, threading locks and isfile checks were dead
weight; probe cache file paths are now defined in paths.py.
2026-07-11 20:26:12 +01:00
CalamitousFelicitousness c54c0535c0 fix(civitai): accept civitai.red urls in header peek
The .red mirror rewrites downloadUrl to its own host; normalize to
civitai.com so the ssrf guard, cache hash and fetch host agree.
2026-07-11 20:26:12 +01:00
CalamitousFelicitousness d005ac5aa1 feat(model): support comfy_quant header metadata containers
Newer quantized checkpoints record per-layer formats in the safetensors
header _quantization_metadata instead of marker tensors. The native loader
now reads the header map, re-keys it through the same prefix strip as the
tensors, and transcodes it into marker tensors so both container forms
share one detection path; header entries win over markers.

- drop optional input_scale sidecars for marked layers
- map full_precision_matrix_mult onto the sdnq per-layer matmul exclusion list
- log the detection source (markers, header, both)
2026-07-11 20:26:12 +01:00
Vladimir Mandic 9bb94dcfff update gitignore
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-11 21:08:22 +02:00
Disty0 ad400ba817 SDNQ handle subnormals in FP formats and cleanup Triton MM 2026-07-11 21:52:51 +03:00
CalamitousFelicitousness 8803537df8 chore: ignore model probe cache files 2026-07-11 06:45:30 +01:00
CalamitousFelicitousness 5d5ede5c47 feat(model): load convrot comfy_quant checkpoints via sdnq hadamard
ConvRot is the regular Hadamard rotation SDNQ implements: identical
construction, normalization, axis, and dequant order. Per-layer markers
map onto the dequantizer's use_hadamard and hadamard_group_size; group
sizes must be powers of 4 and divide in_features, else base-repo
fallback. Detection carries per-layer metadata since files mix plain
and rotated layers.
2026-07-11 06:40:08 +01:00
CalamitousFelicitousness 9f91726020 fix(ideogram4): resolve activation dtype for quantized transformers
transformer.dtype reports the storage dtype for fp8-quantized models
(fp8 params are floating, int8 params are not), so activations were
cast to fp8 and the forward crashed. Read the compute dtype from the
SDNQ dequantizer instead.
2026-07-11 06:40:07 +01:00
CalamitousFelicitousness 8c884c1e02 feat(model): secondary unet override slot and ideogram4 native loading
One UNET override cannot serve dual-transformer arches: ideogram4
conditional/unconditional and wan combined-stage experts need separate
files, and previously a single override landed on both experts.

- sd_unet_secondary option with per-slot tracking, consumed-state sync,
  arch-change reset, and incompatible-override fallback
- dropdown renders beside the primary, follows it into quicksettings,
  and is visible only for dual-transformer model types
- ideogram4 native single-file spec with a quant-aware fused-qkv
  converter; such converters run before comfy_quant detection via
  TransformerSpec.converter_handles_quant
- quicksettings render in configured order (sort keyed on the option
  object and always fell back to alphabetical)
- post-load dtype warning skips quantized transformers
2026-07-11 06:40:07 +01:00
CalamitousFelicitousness 3831e4563f feat(model): variant-specific fp8 precision tokens
fp8_e4m3fn and fp8_e5m2 differ in kernel support, so a bare fp8 token
is not enough to know whether a file runs on a given architecture;
scaled_fp8 derives its token from the detected format.
2026-07-11 06:40:07 +01:00
CalamitousFelicitousness c72e68e888 feat(model): read exact comfy_quant format from local marker tensors
Local probes read the marker tensor bytes for the true format string
(nvfp4, mxfp8, int8_tensorwise) instead of inferring from weight
dtypes; remote ranged peeks stay dtype-inferred. precision_token maps
quant format or dominant dtype to the short filename token.
2026-07-11 06:40:07 +01:00
CalamitousFelicitousness 055388aa70 feat(civitai): attach model probe analysis to header peeks
peek-header now returns the full probe (architecture fingerprint,
dtypes, quant scheme) alongside the metadata block, and caches the
response persistently by civitai file id; file content per id is
immutable, so cached probes skip the ranged fetch entirely.
2026-07-11 06:40:07 +01:00
CalamitousFelicitousness e5800b005e feat(model): add header-only model probe with arch fingerprints
Analyzes safetensors/gguf headers without reading weights: curated
tensor-name fingerprints for common families, container kind detection
(model/lora/vae/text-encoder), element-weighted precision over core
tensors, comfy_quant/scaled-fp8/gguf quant detection, lora base
resolution via trainer metadata with shape arbitration, and full
__metadata__ passthrough. Results cached by mtime in
data/model_probe.json.

- analyze_header is pure and shared by remote ranged peeks and local
  file reads
- fingerprints verified against the local library and live civitai
  headers; unmatched families report unknown rather than guessing
2026-07-11 06:40:07 +01:00
CalamitousFelicitousness e0ed573d66 feat(civitai): add ranged safetensors header peek endpoint
The API carries no field distinguishing dual-transformer expert files;
conversion tools embed it in the header __metadata__. peek-header
range-fetches the JSON header and returns the metadata block without
downloading the file. Restricted to civitai.com urls.
2026-07-11 06:40:07 +01:00
Vladimir Mandic a8cc6b1c7e update submodules
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-10 19:21:56 +02:00
Disty0 736012d5af SDNQ Atten use FMA on PV 2026-07-10 14:27:53 +03:00
Vladimir Mandic 8ce3313f9a improve log viewer
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-10 13:14:27 +02:00
Vladimir Mandic 73ee1945a3 update todo/changelog
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-07-10 10:15:30 +02:00
CalamitousFelicitousness cbe3c148e0 fix(model): skip redundant model reload after unet override load
load_transformer consumes the sd_unet dropdown selection during a full
model load but never marked it as loaded, so the queued sd_unet
onchange callback always forced a second full reload. Sync
sd_unet.loaded_unet once the override is successfully consumed; the
incompatible-override fallback keeps its reset to Default.
2026-07-10 02:39:24 +01:00
CalamitousFelicitousness 2a7d4b4037 feat(model): extend comfy_quant loading to float8_e4m3fn
Parameterize the pre-quantized comfy_quant path by format so fp8
tensorwise checkpoints load alongside int8; both map onto SDNQ's
symmetric dequant for the matching weights dtype. Containers are
mislabeled in the wild, so the stored weight dtype is validated
against the marker, mixed-format files are rejected, and markers
carrying a convrot rotation flag fall back to the base repo since
they may require runtime inverse rotation.
2026-07-10 02:27:24 +01:00
CalamitousFelicitousness d087c3e687 feat(civitai): route text encoder files to te_dir
Versions bundle companion files typed by the file, not the model;
'Text Encoder' had no TYPE_MAP entry so companions landed in the
checkpoint folder where the loader never scans.
2026-07-10 02:17:33 +01:00
CalamitousFelicitousness 24683dc608 feat(civitai): parse gguf quantType in file metadata
GGUF variants are distinguished by quantType, not fp; the model
endpoint carries it in file metadata.
2026-07-10 02:09:14 +01:00
CalamitousFelicitousness 68c1ea8e78 feat(model): load comfyui comfy_quant int8 checkpoints via sdnq
Detect comfy_quant markers in native single-file transformer loads and
adopt the pre-quantized tensors as SDNQ int8 layers instead of rejecting
them. ComfyUI int8_tensorwise is a strict subset of SDNQ symmetric int8,
so weights and scales are taken bit-exact with no dequantize-requantize
round trip; quantized matmul and scale-dtype settings apply as usual.

- detect_comfy_quant/remap_comfy_quant helpers plus a prequantized
  builder in native_transformer; file markers dictate the layer set
- unsupported formats and wrong-arch markers fall back to the base repo
- offline unit tests and an opt-in real-file krea2 test
2026-07-10 01:54:27 +01:00
CalamitousFelicitousness e615b6e22b feat(civitai): sweep abandoned download partials at startup
Interrupted downloads leave url-hash .tmp resume files that nothing
cleans up; the queue that knows about them is in-memory only.

- iter_type_roots lists every folder downloads resolve into
- partials older than 7 days by mtime are deleted when the download
  manager starts; active partials always have a fresh mtime
2026-07-10 01:54:27 +01:00
CalamitousFelicitousness ef6030b871 feat(civitai): expose file variant metadata and scan results
Multi-variant versions serve one canonical filename per file; the
precision, size class, format, and scan status that distinguish them
were dropped at the model layer.

- CivitFile gains metadata (format, size, fp), pickle and virus scan
  results, and scannedAt
2026-07-10 01:54:27 +01:00
Disty0 7578d9b6bc remove dynamic from sdnq atten 2026-07-10 03:22:14 +03:00
CalamitousFelicitousness 9b18aad1c1 feat(civitai): record search filters in history entries
History entries stored only the query or tag term, so restoring a
search dropped every filter, and filter-only browsing was never
recorded at all.

- SearchHistory.add takes an optional params dict stored on the entry
- get_search records non-default filters: type, sort, period, base
  models, nsfw, username, favorites
- filter-only searches are recorded as 'filter' entries labeled with
  the filter values
2026-07-10 00:50:01 +01:00
CalamitousFelicitousness 9f9a350e53 fix(civitai): restart download when server ignores range request
A 200 reply to a resumed download carries the full file, not the
remainder; appending it to the partial produced a corrupt file that
passed the size check and only failed at hash verification. Truncate
the temp file and restart from byte 0 when a Range request comes back
as 200 instead of 206.
2026-07-10 00:05:37 +01:00
CalamitousFelicitousness a274f57aab fix(civitai): tolerate null availability, expose early access fields
The /model-versions endpoint now serializes availability as null, which
failed str validation and turned every version lookup into a 404. Coerce
null to the default like the creator username validator already does.

Pass through earlyAccessEndsAt and earlyAccessConfig so clients can see
that a download requires a Buzz purchase before requesting the file.
2026-07-09 23:49:37 +01:00
CalamitousFelicitousness d2937166d3 fix(sdnq): sync benchmark prep mirror with kernel helpers
upstream replaced math.log2/triton.next_power_of_2 with sdnq utils in
the attention prep; mirror the same hadamard sizing in make_prep_fn.
2026-07-09 17:42:49 +01:00
CalamitousFelicitousness 75a245cbeb fix(sdnq): disable tf32 for the benchmark fp32 reference
sdnext enables tf32 globally; a math-backend dispatch fallback (gqa,
some mask shapes) degrades the fp32 reference to tf32 precision,
measured 4.2e-4 vs 5.0e-7 relative to fp64. the default mem-efficient
backend is unaffected.
2026-07-09 17:39:59 +01:00
CalamitousFelicitousness ad25416cf2 feat(sdnq): derive benchmark recommendations from measured webui state
Recommendations must hold on any gpu, so every verdict now comes from
measuring the configuration the advice points to.

- run benchmarks in the webui's configured dtype, --dtype overrides
- bench the prep mode matching the environment: compiled, verified
  dynamic=false workaround, or eager; label each with the webui change
  the numbers correspond to
- add a prep column for the q/k/v quantization cost outside the
  kernel; eager prep measured 1.9 ms vs 0.2 ms fused at sdxl,
  inverting the quantized matmul verdict
- compare Use Quantized MatMul against the unquantized sdnq row so
  quantization pays for its own prep
- star the lowest-error config within 5% of the fastest sdnq time;
  the same rule drives the worth-enabling verdict vs torch sdpa
- drop the (auto, default) suffix; document the settings mapping and
  star rule in the notes
- wrap correctness and shape tables in panels to separate sections
2026-07-09 17:39:59 +01:00
CalamitousFelicitousness 95234dd3c3 feat(sdnq): measure fp8 attention configs in the benchmark
The pv matmul recommendation trusted the float8 hardware probe alone,
so gpus where fp8 pv compiles but runs slower than unquantized pv got
a recommendation that degrades generation speed and error. Measured on
an rtx 2000 ada, fp8 pv lands at x0.93 of the sdpa baseline while int8
qk alone reaches x1.26.

- add fp8 pv and fp8 qk bench configs, gated on the eager float8
  probe so unsupported gpus keep clean tables
- include fp8 pv in the video presets since the pv stage matters most
  at long sequence lengths
- recommend a quantized pv type only when the fastest measured pv
  variant beats plain int8 qk by at least 5%, otherwise recommend auto
  and name the variants that measured no gain
- cite the measured fp8 qk ratio in the matmul type reason instead of
  the static compile claim
2026-07-09 17:39:59 +01:00
CalamitousFelicitousness af0b76f550 fix(sdnq): correct triton and fp8 detection in attention benchmark
The environment panel reported triton as missing and float8 as
unsupported on ada gpus. The triton lookup used the distribution name,
which varies by platform (triton-windows on windows), and the fp8 probe
ran through the torch.compile input prep, so a broken compile toolchain
read as a hardware limitation with the actual error discarded.

- read the module version for the triton line instead of the
  distribution name
- probe float8 with eager input prep so the result reflects gpu
  capability; show the failure reason when genuinely unsupported
- probe the compiled input prep separately and cold, before any eager
  kernel run: inductor lowers part of the dynamic-shape prep to a cpu
  helper kernel, so a missing host c++ compiler fails every sdnq
  attention call at generation, and a prior eager run in the same
  process masks the cold-start failure the webui hits
- on failure, verify the SDNQ_COMPILE_KWARGS dynamic:false workaround
  live and report it in the environment panel and recommendation notes
- benchmark with eager input prep when the compiled path is broken so
  kernel numbers still fill in
- replace the unicode star marker with ascii: rich's legacy windows
  renderer crashes with a cp1252 UnicodeEncodeError on piped output
2026-07-09 17:39:59 +01:00
Disty0 c35201de30 cleanup triton mm 2026-07-09 16:21:47 +03:00
Disty0 8cc5faa877 remove math import 2026-07-09 14:14:50 +03:00
Disty0 3641d12274 Inductor breaks down with math.log 2026-07-09 14:06:02 +03:00