Extract and Save Lora
Turn a model difference into a LoRA without training
- model_diff
- text_encoder_diff
LoraSave - "Extract and Save Lora" in the menu - is ComfyUI's answer to a very specific problem: you have two checkpoints and you want to keep only what's different between them, as a lightweight LoRA file. No training run, no dataset, no hours of waiting. It's the compression step at the end of a "model subtraction" workflow, and it's a genuinely handy trick for personal merges.
The workflow it's built for. LoRA extraction - taking the diff between a base and a fine-tune and compressing it as a LoRA - is a well-established middle ground in the community when you want to share a style without shipping a whole checkpoint (see the knowledge base's LoRA training essay). The graph is: load your base model, load the fine-tuned or merged variant, run ModelSubtract to get model1 − model2, then feed that difference into LoraSave. There's a matching CLIPSubtract for the text encoder, and LoraSave accepts both. Run it once and a .safetensors file lands on disk.
How it works. For every weight layer in the difference, the node runs an SVD decomposition and keeps only the top rank singular values, splitting the result into lora_up and lora_down matrices - exactly the factorization a trained LoRA has, which is why the file drops right into your normal LoRA loader. Values get clamped at the 0.99 quantile so a few wild outlier weights don't dominate. Everything is saved in fp16.
The inputs that matter. Four required inputs plus two optional ones (filename_prefix sets the save name and isn't in the list below):
- model_diff - the
ModelSubtractoutput (the diffusion model difference). If you only have a text-encoder diff, you can skip this. - text_encoder_diff - the
CLIPSubtractoutput. Both are optional, but at least one must be wired or the node just silently does nothing. - rank - default 8, up to 4096. The rank of the factorization. Higher rank = closer to the original diff but bigger files. The node clamps it to the layer's actual dimensions, so cranking it to 4096 rarely does what you hope.
- lora_type -
standard(the SVD lora_up/lora_down split) orfull_diff(store the entire weight difference as-is, much bigger but lossless). - bias_diff - on by default; also saves bias differences as
.diff_bweights.
It has no outputs - it's an output node. It writes to {your_output_dir}/{filename_prefix}_{counter:05}_.safetensors; with the default prefix that's something like ComfyUI/output/loras/ComfyUI_extracted_lora_00001_.safetensors. Set filename_prefix to name it yourself.
Gotchas. This is extraction, not training. A rank-8 extracted LoRA is a decent approximation of a model diff, but it won't reproduce a fine-tune's quality the way a properly trained LoRA does - treat it as "good enough for personal merges," not as a distribution artifact. If a layer's weight difference is effectively zero, you'll get a warning in the console and that layer is skipped. And keep the source checkpoints around: the extraction is only as reproducible as your graph, and the base you subtracted against has to be the same one you load the LoRA on top of.
It ships with ComfyUI core - search "LoraSave" or "extract lora" from the node menu. No install.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| filename_prefix | STRING | loras/ComfyUI_extracted_lora | — |
| rank | INT | 81–4096 | — |
| lora_type | COMBO | 2 options: standard, full_diff | |
| bias_diff | BOOLEAN | true | — |
| model_diffopt | MODEL | The ModelSubtract output to be converted to a lora. | |
| text_encoder_diffopt | CLIP | The CLIPSubtract output to be converted to a lora. |
Outputs (0)
No outputs