Extract Kohya Lora
Turn a merge delta into an actual LoRA file
- base (delta)
- rank (8)
- use_approximate_basis (True)
- approximate_basis_iters (2)
- approximate_basis_seed (None)
- recipe
Here's a party trick the comfy-mecha pack pulls off that you rarely see anywhere else: take the difference between two checkpoints and compress it into a LoRA. Extract Kohya Lora runs a low-rank decomposition on a delta recipe and spits out a MECHA_RECIPE in LoRA form - lora_up/lora_down matrices plus alpha - that you can then apply to any compatible base with Add Difference, or save out via the mecha serializer. It's the reverse of the Lora Mecha Recipe node.
Why you'd bother
Merges are one-off artifacts; LoRAs are portable. If you've got a fine-tune you like but can't redistribute, or you want to share a style change without shipping a 6 GB checkpoint, extracting a rank-limited approximation of the delta is the classic move. You lose a bit of fidelity - that's the point of the rank knob - but you gain a 100 MB file that works on any SDXL base with the same key layout. Think of it as distillation-by-decomposition: the extractor's rank is your quality-vs-size dial.
The inputs that matter
base (delta)- the difference you're compressing. Feed it aSubtractof two checkpoints, or a delta produced by other merge nodes.rank- default 8. The number of singular values kept. Rank 8–32 is the sane range for SDXL; higher keeps more detail but grows the file and edge cases. If you're used to LoRA training, the same intuition applies.use_approximate_basis(default True) - use a randomized approximate SVD instead of the full one. It's much faster and for a few iters the quality hit is usually invisible; leave it on unless you're chasing maximum fidelity.approximate_basis_iters- default 2. More iters = a more exact approximation. Only matters when the above is on.approximate_basis_seed- seed the randomized SVD so extractions are reproducible. Set it if you're A/B testing.
Output: a single recipe (MECHA_RECIPE) in LoRA weight space. Chain it into Add Difference (as the b (delta) input) with your target base, or into the serializer to store as a .mecha file. Don't feed it straight to Mecha Merger expecting a model - a LoRA recipe is a delta, not a standalone checkpoint.
The merge_checkpointing toggle caches this branch on CPU in fp16 if you're re-running with the same inputs.
Install
ComfyUI Manager → search mecha → "Mecha Merge Node Pack", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ljleb/comfy-mecha.git
pip install -r comfy-mecha/requirements.txt
Restart after. Dependency is sd-mecha==1.1.7, no model downloads.
Gotchas
- The output is a kohya-layout LoRA. If your target base or downstream tooling expects a LyCORIS-style file, use
Extract Lycoris Lorainstead - the decomposition is the same idea, the key naming isn't. - Extracting from a delta that's already rank-limited (like another extracted LoRA) compounds the loss. Extract once, from the full checkpoint difference.
- Low rank on a big semantic change produces a weak LoRA - expect to crank alpha toward 1.0 if you extracted at rank 8 and the effect feels faint.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| base (delta) | MECHA_RECIPE | — | |
| rank (8)opt | MECHA_RECIPE | 8 | — |
| use_approximate_basis (True)opt | MECHA_RECIPE | true | — |
| approximate_basis_iters (2)opt | MECHA_RECIPE | 2 | — |
| approximate_basis_seed (None)opt | MECHA_RECIPE | — | |
| merge_checkpointingopt | BOOLEAN | false | Speeds up an entire branch of a merge graph that does not change often in exchange of memory. - true: store the first output of this recipe node on cpu memory in fp16. On subsequent workflow executions, as long as the inputs do not change, the cached keys are returned after being cast to the original device and dtype. - false: do not store the output. The recipe and its inputs will re-execute on subsequent workflow executions. Note that the memory used to checkpoint the output is distinct from the cache feature. In general, you probably want to either use this *or* a cache unit, but not both at the same time because the memory adds up. The difference between merge checkpointing and cache is that merge checkpointing completely re-merges from scratch if any input changes. Merge checkpointing is also generally much faster than cache in the fast path. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| recipe | MECHA_RECIPE | — |