Lora Extract K Jv2 (QQ)
Turn a fine-tuned checkpoint back into a LoRA, with a VRAM dial
- finetuned_model
- original_model
LoraExtractKJv2 is the "I trained a full model but I only want the diff" tool. It takes a fine-tuned model and the original it was fine-tuned from, subtracts the delta, and compresses it into a LoRA file you can use anywhere - at a fraction of the storage and without carrying the whole checkpoint around. It's the author's VRAM-optimized v2 of the extraction node in KJNodes (the KJNodes/lora category is a tell), and the generic_docs folder in the repo has a full write-up of what changed.
How it works
The node gets two model inputs: finetuned_model and original_model. For each weight, it computes the difference between them, then factorizes that delta with SVD into low-rank up @ down matrices - that's the "LoRA" form. The core dials:
- rank - target rank of the extracted LoRA (also acts as a cap for the adaptive methods). Higher rank = more fidelity, bigger file.
- lora_type -
standardandfullare the simple ones;adaptive_ratio,adaptive_quantile,adaptive_energy, andadaptive_fropick rank per layer based on singular-value statistics instead of a flat cap. For most people,standardat rank 8–32 is the starting point. - algorithm -
svd_linalg(accurate, slower) vssvd_lowrank(faster, approximate). - adaptive_param - the knob that tunes whichever adaptive method you picked (singular-value ratio, quantile, or Frobenius retention).
- bias_diff - whether to extract bias deltas too (default on).
- output_dtype - fp16 default, or bf16/fp32.
The real headline here is the v2 VRAM machinery, which exists because video checkpoints are enormous and this used to be an out-of-memory generator. vram_usage_mode (conservative ≈50% VRAM, balanced ≈75%, aggressive ≈90%+) is the master dial; below it sit blocks_in_gpu (how many transformer blocks stay resident), batch_size (layers processed at once), prefetch_ahead, memory_threshold (when to auto-offload), and debug_mode for performance telemetry. The author's docs claim 30–120% faster extraction than v1 depending on mode. If you're on a 12GB card, stay on balanced; if you're on a 4090+ and impatient, aggressive is usually safe.
There are no outputs - this is an output node that saves the LoRA using filename_prefix (default loras/ComfyUI_v2_extracted_lora) into ComfyUI/models/loras.
When to use it
The honest use case: you trained or received a full fine-tuned checkpoint and want a shareable LoRA version of just the change, or you're curious what a fine-tune actually altered and want to inspect/export the delta. It's also how people salvage knowledge out of big merged checkpoints. It is not a replacement for proper training - the SVD-compressed delta is a lossy approximation of a fine-tune, and identity/style fidelity degrades as you drop rank.
Installing it
Ships in siraxe/ComfyUI-WanVideoWrapper_QQ (install via Manager by searching WanVideoWrapper_QQ/SA-Nodes-QQ, or git clone https://github.com/siraxe/ComfyUI-WanVideoWrapper_QQ.git into custom_nodes and restart). No special deps beyond standard ComfyUI - the VRAM tricks are pure PyTorch. Load your two checkpoints with the usual model loaders and wire them in.
Gotchas
- VRAM first, speed second. If extraction OOMs, drop
vram_usage_modeto conservative before touching anything else - the whole point of this version is that it degrades gracefully. - Save file missing? Check the console output; debug mode prints exactly where it's writing.
- Standard pack caveat: the repo renamed to ComfyUI-SA-Nodes-QQ in v1.3.4, so delete any stale
wanwrapper_qqfolder incustom_nodesif old workflows reference it.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| finetuned_model | MODEL | — | |
| original_model | MODEL | — | |
| filename_prefix | STRING | loras/ComfyUI_v2_extracted_lora | — |
| rank | INT | 81–4096 | The rank to use for standard LoRA, or maximum rank limit for adaptive methods. |
| lora_type | COMBO | 6 options: standard, full, adaptive_ratio, adaptive_quantile, adaptive_energy, adaptive_fro | |
| algorithm | COMBO | svd_linalg | SVD algorithm to use, svd_lowrank is faster but less accurate. |
| lowrank_iters | INT | 71–100 | The number of subspace iterations for lowrank SVD algorithm. |
| output_dtype | COMBO | fp16 | 3 options: fp16, bf16, fp32 |
| bias_diff | BOOLEAN | true | — |
| adaptive_param | FLOAT | 0.150–1 | For ratio mode, this is the ratio of the maximum singular value. For quantile mode, this is the quantile of the singular values. For fro mode, this is the Frobenius norm retention ratio. |
| clamp_quantile | BOOLEAN | true | — |
| vram_usage_mode | COMBO | balanced | VRAM usage mode. Conservative=50% VRAM, Balanced=75% VRAM, Aggressive=90%+ VRAM |
| blocks_in_gpu | INT | 100–40 | Number of transformer blocks to keep in GPU memory (0=offload all, 40=keep all) |
| batch_size | INT | 41–8 | Number of layers to process simultaneously (higher=more VRAM, faster) |
| prefetch_ahead | INT | 20–10 | Number of blocks to prefetch ahead (reduces I/O bottlenecks) |
| memory_threshold | FLOAT | 0.850.5–0.95 | VRAM usage threshold before automatic offloading (0.5-0.95) |
| debug_mode | BOOLEAN | false | Enable detailed performance and VRAM usage debugging |
Outputs (0)
No outputs