Commit Graph
52 Commits
Author SHA1 Message Date
rdp c0cc2805e9 Fix "addmm_cuda" not implemented for 'Char' crash when using INT8GroupedLora 2026-06-10 15:28:17 +03:00
BobJohnson24 041148b096 Handle disabling of offloading after dynamic model load 2026-06-08 15:40:17 +07:00
BobJohnson24 8202d5aeb5 actually do the thing instead of comitting the wrong version 2026-06-08 00:39:19 +07:00
BobJohnson24 cdc0989b0c Determine device for dtype 2026-06-08 00:23:14 +07:00
BobJohnson24 319deac131 Make the dtype setting functional 2026-06-03 02:56:11 +07:00
Your Name 0873d36736 Fix line endings error hopefully 2026-05-31 14:56:41 -05:00
BobJohnson24 fa9e6aa94f Additional fixes for lora 2026-05-25 17:11:39 +07:00
BobJohnson24 2ed1a51610 Merge pull request #55 from L33chKing/main
Several bug fixes
2026-05-25 17:10:45 +07:00
BobJohnson24 0785f63ccd Fallback for comfy <0.22.0 2026-05-24 02:03:03 +07:00
BobJohnson24 0d3c0dfbe8 forgor to add pin state needed for big models 2026-05-24 01:35:34 +07:00
BobJohnson24 b4f4200e1b Fix for loras on models with .bias weights (WAN) 2026-05-23 23:49:49 +07:00
BobJohnson24 bc2e049725 Get rid of b16 weights during on the fly quant 2026-05-23 18:26:22 +07:00
BobJohnson24 c1f8cae2f4 Add files via upload 2026-05-23 17:09:17 +07:00
l33chKing 8e772b2283 Summary of Changes
Bug 1 — Save after INT8 Grouped LoRA produces corrupted/unloadable checkpoint
Root cause: ModelPatcher.clone() constructs a fresh patcher and does not carry over arbitrary attributes that the loader had attached to the source patcher (_safetensors_metadata). After INT8GroupedLora.apply_loras() calls model.clone(), the metadata stash is gone, so INT8ModelSave writes a checkpoint with empty safetensors metadata.
Some model types (notably LTX2 — which keeps its transformer config in metadata) then fail to redetect on reload, and the file appears smaller because the metadata header is empty.

Fixes:

int8_unet_loader.py:225-235 — Stash metadata in two places: on the patcher (legacy) and on the inner model.model object (_int8_source_metadata). Inner-model attributes survive clone() because it shares the inner model by reference.
int8_lora.py:31-45 — Best-effort copy of _safetensors_metadata / _int8_source_metadata from the source patcher onto the cloned one in INT8GroupedLora.apply_loras.
int8_save.py:12-40 — New _resolve_source_metadata() that walks the patcher → parent chain and the inner-model fallback, plus a warning when nothing is found.
Bug 2 — Save node was collecting extra_keys BEFORE LoRA bake
comfy.sd.save_checkpoint internally triggers load_models_gpu, which is when the INT8ModelPatcher actually bakes LoRA patches into the int8 weights. The previous save node iterated modules before that, so on the LoRA-stacked path:

mark_module_for_direct_save was being called against the pre-bake module identity.
comfy_quant extra_keys were emitted against pre-bake state.
After save_checkpoint baked patches via set_attr(module, "weight", new_int8_param), the saved bytes were the patched int8 weights but with metadata that may or may not have observed the post-bake state cleanly.
Fix (int8_save.py:120-154): Pre-call comfy.model_management.load_models_gpu([model], force_full_load=True) so all LoRA patches are baked and comfy_patched_weights = True is set on every module before we walk it. Then re-finalize any aimdo-deferred layers, then collect extra_keys.

Bug 3 — OTF quantization round-trip was fragile
OTF-quantized layers were never stamping _convrot_groupsize on the module, so the save side fell back to the loader-time default (currently CONVROT_GROUP_SIZE = 256). It happened to match on reload, but any future change to the default would silently corrupt round-trips, and the saved comfy_quant JSON had no convrot_groupsize field at all.

Fixes:

int8_quant.py:254-257 and int8_quant.py:443-454 — Set self._convrot_groupsize = CONVROT_GROUP_SIZE whenever OTF (or the deferred aimdo finalize) actually applies a Hadamard rotation.
int8_save.py:166-187 — Always emit convrot_groupsize in comfy_quant whenever convrot=True, falling back to the module-level constant if _convrot_groupsize is somehow missing. Also emit per_row so the loader can pick the matching forward kernel without re-inspecting tensor shapes.
int8_quant.py:340-396 — Parse the new per_row hint in comfy_quant and use it to override the shape-based heuristic in _load_from_state_dict. Existing files (without per_row) continue to work via the original shape heuristic.
Files changed
int8_save.py — Restructured save flow, added metadata resolver, save convrot_groupsize and per_row deterministically, pre-load patches before extra_keys collection, robust fallback path.
int8_unet_loader.py:225-235 — Stash _int8_source_metadata on the inner model so it survives clone().
int8_lora.py:31-45 — Copy metadata attributes onto the cloned patcher in INT8GroupedLora.apply_loras.
int8_quant.py:240-256, 340-352, 371-401, 443-454 — Stamp _convrot_groupsize during OTF and aimdo-deferred finalize, parse per_row hint from comfy_quant.
Notes on the OTF "worse quality than pre-quantized" report
After re-tracing the OTF → save → reload path carefully (Hadamard rotation, per-row scale, bias preservation, dtype tracking) I was not able to find a save-side bug that would degrade quality.
The OTF and pre-quantized paths use the same quantize_int8_axiswise(weight, dim=1) code, the same forward kernels, and now write the same comfy_quant payload.
The most plausible source of the perceived quality gap is that pre-quantized HF checkpoints were calibrated with a different excluded_names list per model than what Int8TensorwiseOps.excluded_names uses for the same model in this loader; that is a calibration choice, not a bug in the save/reload path.
If a concrete reproduction (same workflow, same seed, OTF-then-save vs HF-prequant) shows a measurable delta, the fix would belong in the per-model excluded_names table in int8_unet_loader.py, not in the save node.
2026-05-20 17:27:21 +03:00
BobJohnson24 dde5b38b9d Fix pre-lora on windows
also fixing pre lora widgets not loading properly
2026-05-15 01:46:32 +07:00
BobJohnson24 7a9cfdc278 Comment out logging 2026-05-14 21:58:02 +07:00
BobJohnson24 7f2e80ac86 The return of stochastic lora
Because I deeply don't care to figure out which is better. I am leaving it up to you, as I enjoy my life with pre-lora.
2026-05-14 21:19:18 +07:00
BobJohnson24 5a9e7626e5 Better RAM Management 2026-05-14 15:45:10 +07:00
BobJohnson24 545ff437ed Fix sticky lora, model saving 2026-05-11 22:31:07 +07:00
BobJohnson24 d33f54a8c3 Fix for compile caused by vram fix 2026-05-11 03:26:25 +07:00
BobJohnson24 e9bef7e935 Fix for dynamic vram 2026-05-11 02:43:00 +07:00
BobJohnson24 ee8c8c14de Fix Pre-Lora states, properly rename to ConvRot 2026-05-10 02:16:21 +07:00
BobJohnson24 9373394f67 Better comment 2026-05-09 23:13:50 +07:00
BobJohnson24 370e26fb4a Clean-up 2026-05-09 23:10:28 +07:00
BobJohnson24 1224ff6df1 Pre-Lora is 99% as good as dynamic lora
Splendid
2026-05-09 23:02:02 +07:00
BobJohnson24 e3a6b43a67 Fix lora properly 2026-05-07 23:24:22 +07:00
BobJohnson24 11575de04d Goodbye, dynamic lora.
Hello dynamic lora 2.0
2026-05-07 03:21:25 +07:00
BobJohnson24 4ea43bc60d Proper ConvRot, Anima improv, Model saving 2026-05-02 23:02:52 +07:00
BobJohnson24 1e15f8f377 Update names 2026-04-17 16:53:49 +07:00
BobJohnson24 9d4e999e22 Fix memory issues in stochastic lora 2026-04-10 01:29:19 +07:00
BobJohnson24 5ff8f74bfa Adding Quarot to OTF because its pretty good 2026-04-06 23:12:48 +07:00
BobJohnson24 55762d16e8 support lokr and loha I guess 2026-03-27 14:13:21 +07:00
BobJohnson24 87fce4edb8 Support Comfy Dynamic Memory 2026-03-26 18:15:09 +07:00
BobJohnson24 b7f7fbddad lora fixes 2026-03-02 22:21:00 +07:00
BobJohnson24 768a2b2735 Merge pull request #24 from jjarquin/feature/int8-row-quantization
Add per-row INT8 weight quantization with fused Triton kernel
2026-03-01 00:36:42 +07:00
BobJohnson24 660f12cbbe Commit the actual files 2026-02-20 01:43:51 +07:00
BobJohnson24 9493079490 Manual on the fly toggle 2026-02-20 01:39:07 +07:00
jjarquin aefad3aff8 Add per-row INT8 weight quantization with fused Triton kernel
- Add int8_forward_dynamic_per_row for per-row weight scale dequantization
- Add fused Triton GEMM kernel with per-row weight scale epilogue
- Auto-detect per-row vs per-tensor scale shape during weight loading
2026-02-19 02:05:13 +01:00
Forkoz 41ca0dfe75 feelin kinda dumb now 2026-02-05 16:40:29 +00:00
Forkoz 4282754619 Stray enter 2026-02-05 16:38:19 +00:00
Forkoz 04a6f53216 Fix fallback for small prompts
if you use FP16 weights bias would be BF16 and then poof
2026-02-05 16:35:00 +00:00
BobJohnson24 25a9f20642 Add files via upload 2026-02-02 19:47:01 +07:00
BobJohnson24 3b1b90a126 Do we believe in ghost nodes?
Clean up code that may be accessed by the supernatural entities
2026-01-24 19:15:45 +07:00
BobJohnson24 71f831b05c Add files via upload 2026-01-24 19:00:07 +07:00
BobJohnson24 549fee9434 Don't quantize layers if model is quantized
Also theoretical Qwen support
2026-01-24 04:29:45 +07:00
BobJohnson24 a37b48f199 Fused Triton Kernel 2026-01-23 22:27:53 +07:00
BobJohnson24 3778653306 Dynamic Lora Nodes for ease of use 2026-01-23 20:00:14 +07:00
BobJohnson24 a87fb012e8 Cleanup unused code 2026-01-23 15:13:43 +07:00
BobJohnson24 da505f2e39 Int8 Lora 2026-01-23 03:43:33 +07:00
BobJohnson24 ab76d9d935 Chroma fix, Theoretical LTX2, WAN2 support
I am bad at this.
2026-01-21 13:09:15 +07:00