ComfyUI Node

Merge LoRA

Combine two LoRAs into one file, right in the graph

By laksjdjf·Created 3 years ago·Updated 2 years ago· 23
Merge LoRA
  • lora_1
  • lora_2
  • LoRA
mode
rank16
threshold1.00
device
dtype

Merging checkpoints is how half of CivitAI was born. Merging two LoRAs is the quieter cousin of that trick, and it's exactly what this node does. The payoff is the same kind: you bake a style and a character, or two styles, into one adapter so you apply it in a single pass, ship it as one file, or stop babysitting three strength sliders that all fight each other.

Merge LoRA is the middle of this pack's three-step pipeline. Load LoRAs into memory without applying them, combine them here, then either apply the result to your model or save it out to ComfyUI/models/loras. If you remember kohya's lora_merge scripts or A1111's LoRA tab, this is that math redone as a graph node - no training involved, just weighted arithmetic on the up/down matrices.

The three merge modes

The input side is simple: lora_1 (required), lora_2 (optional), and the output is a single LoRA object. All the real decisions are in mode.

  • add - weighted element-wise addition of the up and down matrices. Fast, but it's the crude one: because the two LoRAs' contributions get cross-multiplied, it's not an exact combination, and the author's own README says accuracy tanks if the two LoRAs are nothing alike. Both LoRAs must also have the same rank, or you'll get a shape error.
  • concat - stacks the two LoRAs along the rank dimension with rescaling to keep the math exact. This is the "correct" merge, but the output rank becomes r1 + r2, so the file gets fatter. If you care about fidelity above all, this is the mode to reach for.
  • svd - reconstructs the combined weight matrix, then runs truncated singular value decomposition to squeeze it back down to whatever rank you set. Slower, loses a little precision, and it's the only mode where you get to choose the final rank - handy when you want a compact result or when the two inputs have different ranks. The device dropdown (cuda/cpu) only matters here: if you're on a cramped card, run the SVD on CPU.

Three supporting knobs: dtype sets the output precision - float16 or bfloat16 if you want a smaller file, and you'll barely notice the difference on most LoRAs. threshold (default 1.0) is the power-user lever: drop it below 1 and the node ignores your fixed rank and instead auto-picks the rank that captures that fraction of the weight's energy (Frobenius explained variance), which is a neat way to merge to "good enough, as small as possible" without guessing.

Wiring it up

Load LoRA Weight OnlyMerge LoRALoad LoRA from Weight is the canonical chain, and you can tap a Save LoRA node off the merged output to write the .safetensors. One thing to know before you bake the file: the saved LoRA has whatever strengths were set upstream baked into the weights - this node outputs strength 1/1, so merge directly and you get a clean file, but if you scaled block weights on the loader, that scaling is now permanent.

Install and gotchas

cd ComfyUI/custom_nodes && git clone https://github.com/laksjdjf/LoRA-Merger-ComfyUI

then restart ComfyUI. There's no requirements.txt and no model to download - it's pure PyTorch plus ComfyUI internals, so nothing to pip install. ComfyUI Manager can find it too, but be careful: two repos answer to the name "LoRA-Merger-ComfyUI" (larsupb's LoRA Power-Merger is the other, and it's the more famous one). If you use Manager, make sure you're grabbing the one by laksjdjf, the author of the Attention Couple regional-conditioning pack.

Where people get burned: the repo is effectively archived - the README now points to a moved copy at laksjdjf/cgem156-ComfyUI/scripts/lora_merger, and the last commit is just the relocation notice. It still works, but don't expect fixes. The author's own caveats, still true in the code: LyCORIS LoHA/LoKr files aren't supported, and merging LoRAs produced by different training scripts can silently go wrong. And none of it does anything until the merged LoRA actually reaches a model via Load LoRA from Weight - merge alone just makes a blob of tensors.

Categorylora_merge

Inputs (7)

NameTypeDefaultDescription
lora_1LoRA
modeCOMBO3 options: add, concat, svd
rankINT161–320
thresholdFLOAT1.000–1
deviceCOMBO2 options: cuda, cpu
dtypeCOMBO3 options: float32, float16, bfloat16
lora_2optLoRA

Outputs (1)

NameTypeDescription
LoRALoRA