Nodes/ComfyUI_agilly1989_motorway/LoraSave_motorway_edition
ComfyUI Node

LoraSave_motorway_edition

Extract a LoRA from weight differences and save it, in the pipe

By agilly1989Β·Created 2 years agoΒ·Updated about a year agoΒ· 7
LoraSave_motorway_edition
  • MOTORWAY πŸšŒπŸ’¨
  • MOTORWAY πŸšŒπŸ’¨
β—„INPUT_lora_type_keylora_typeβ–Ί
β—„INPUT_model_diff_keymodel_diffβ–Ί
β—„INPUT_text_encoder_diff_keytext_encoder_diffβ–Ί
β—„filename_prefixloras/ComfyUI_extracted_loraβ–Ί
β—„rank8β–Ί
β—„bias_difftrueβ–Ί

Most LoRAs are trained with tools like ai-toolkit or kohya. But there's a second, much lazier path to making one: take a fine-tuned model, subtract the base model, and compress the difference into a LoRA file. That's exactly what LoraSave_motorway_edition (core name: "Extract and Save Lora") does - and this is the version that gets its inputs from your Motorway pipe instead of direct wires.

The mechanics are worth understanding so you don't expect magic. The node needs a model diff (the output of a ModelSubtract node: fine-tune minus base) and optionally a text encoder diff (from CLIPSubtract). It then runs SVD - singular value decomposition - on the weight differences, keeping the top rank components, and writes out a .safetensors LoRA file. Rank is the expressiveness dial: higher rank preserves more of the difference but makes a bigger file; the LoRA-training lore says don't bother porting an SDXL rank table to other architectures, and the same caution applies here. bias_diff controls whether bias terms are stored as plain diffs, and lora_type (standard vs full_diff) picks between the compact SVD LoRA and a bulkier "store everything" format.

Honest expectations: this is the quick-and-dirty extraction path, great for distilling a fine-tune into something shareable, but a real trained LoRA usually beats it on quality per rank. Still, if someone hands you a fine-tuned checkpoint and you want a LoRA out of it in one sitting, this is the tool.

The wrapper

  • MOTORWAY πŸšŒπŸ’¨ - the pipe. Required.
  • INPUT_lora_type_key (default lora_type) - where the type string lives.
  • INPUT_model_diff_key (default model_diff) - the model difference, from a subtract node, stored in the pipe.
  • INPUT_text_encoder_diff_key (default text_encoder_diff) - the CLIP difference.
  • filename_prefix (default loras/ComfyUI_extracted_lora) - where the file is written under ComfyUI/output.
  • rank (INT, 1–4096, default 8) - SVD rank.
  • bias_diff (BOOLEAN, default true) - save biases as diffs.

Output port is just the pipe; the real output is the .safetensors file on disk.

Installing

Part of the Motorway pack:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway
# restart ComfyUI

Or ComfyUI Manager β†’ search ComfyUI_agilly1989_motorway β†’ Install. No model downloads.

Gotchas

  • Nothing gets saved if there's no diff in the pipe - Key: 'model_diff' doesn't exist in motorway means the subtract step never wrote its output.
  • It's a _for_testing core node wrapped in a beta pack: expect rough edges. The author's README says "IF THINGS BREAK ITS BECAUSE I BROKE IT," and generated clones have been toggled off in some releases.
  • Keys are exact strings; match them to whatever your subtract nodes actually wrote.
  • Rank 8 is a starting point, not a rule. For a meaningful extraction you'll often want more - but bigger isn't automatically better.

You're not training here; you're compressing a diff. Set your expectations at "useful baseline," not "production LoRA," and you'll be pleasantly surprised how often it's enough.

Categoryagilly1989 Nodes/Motorway-ed/_for_testing

Inputs (7)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_lora_type_keySTRINGlora_typeβ€”
INPUT_model_diff_keySTRINGmodel_diffβ€”
INPUT_text_encoder_diff_keySTRINGtext_encoder_diffβ€”
filename_prefixSTRINGloras/ComfyUI_extracted_loraβ€”
rankINT81–4096β€”
bias_diffBOOLEANtrueβ€”

Outputs (1)

NameTypeDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”