ComfyUI Node

CXH_Lora_Merge

Bake two LoRAs into one file without leaving ComfyUI

By StartHua·Created 2 years ago·Updated 2 years ago· 29
CXH_Lora_Merge
      savename
      main_lora
      merge_lora
      merge_type
      weight50

      CXH_Lora_Merge is the "make it one file" button for your LoRA collection. You feed it two LoRAs from your loras folder, pick a blend strategy, and it writes a merged .safetensors straight into ComfyUI/models/loras. No Python, no Kohya, no drag-and-drop of checkpoints into some external merge GUI - it's a plain output node you run like any other.

      The pack's name says Flux, and it was clearly built for the Flux crowd, but the code doesn't care. It loads two safetensors, merges them tensor-by-tensor, and saves the result. Any LoRA that lives in your loras folder works, Flux or not.

      Why you'd reach for it (and when you shouldn't)

      Here's the honest part, and the community says it about as flatly as I'm about to: merging two LoRAs is usually worse than just stacking them at inference. A LoRA is a patch, not a full model, and loading both through two LoRA loaders keeps their weights independently adjustable, which is most of the point. When r/StableDiffusion first asked about Flux LoRA merges, the answer from people who'd tried was that a merged result was "subpar to using both LoRAs at the same time."

      So reach for CXH_Lora_Merge when stacking isn't an option:

      • You want to hand someone a single self-contained file (or upload it) instead of a zip of dependencies.
      • The pipeline you're using loads exactly one LoRA - some video and audio workflows are like this.
      • You're baking the result into a quantized or distilled build and don't want two loaders in the path.

      If you just have two style LoRAs that work well together, don't merge them. Stack them.

      How the merge actually works

      Under the hood it's simple tensor arithmetic. It loads both files with safetensors, walks the union of their keys, and blends matching tensors. Keys that exist in only one file are passed through untouched. Three merge_type options:

      • adaptive - the default and the interesting one. It weights each layer by its L2 norm, so a layer with a stronger signal in LoRA A contributes more from A. Norm-proportional blending, per layer, no thinking required.
      • manual - plain weighted sum: weight% of the first LoRA plus (100 - weight)% of the second. Predictable, boring, and that's fine.
      • additive - 100% of the first LoRA plus weight% of the second. Good when you want LoRA A intact and just want to sprinkle in a bit of B.

      One quirk worth knowing before adaptive surprises you: because adaptive_weight1 + adaptive_weight2 = 1 by construction, the weight slider cancels out of the math. The blend in adaptive mode is purely norm-proportional, no matter where you set it. So if you want actual control over the balance, use manual. The adaptive default is "merge these sensibly," not "merge these toward 50/50."

      The inputs

      Only five, and none of them are hard:

      • main_lora and merge_lora - dropdowns of every LoRA in your models/loras folder. The tooltip on both just says "The name of the merged LoRA," which is a copy-paste slip; what they actually do is pick your two source files.
      • merge_type - adaptive, manual, or additive, as above.
      • weight - an integer 0–100, default 50. Real in manual and additive, cosmetic in adaptive.
      • savename - the output filename. The node appends .safetensors and writes to ComfyUI/models/loras, so "merged" becomes merged.safetensors. Pick something that doesn't collide with your originals - it saves into the same folder they live in.

      There are no outputs. This is an output node; it doesn't return tensors, it returns a file. Connect nothing, set the fields, queue it. If the log shows Merged LoRA saved as: ... you're done.

      Installing it

      It's a five-minute install and the only dependency is tqdm, which is already in practically every ComfyUI environment:

      • ComfyUI Manager: search "Comfyui_CXH_FluxLoraMerge" and click install, or
      • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/StartHua/Comfyui_CXH_FluxLoraMerge, then restart.

      No model downloads, no torch-versions drama, nothing heavy.

      Gotchas

      • Refresh before you load. The merged file lands in your loras folder, but the dropdowns won't see it until you restart or refresh the list in a LoRA loader.
      • Mismatched shapes get zero-padded. The code pads tensors that differ in size so it can still add them. For same-architecture LoRAs this shouldn't trigger; if you merge different ranks and get something weird, this silent padding is the likely culprit.

      For a genuinely obscure little node, it does exactly what it promises: two LoRAs in, one file out, saved where the loaders will find it.

      CategoryCXH/model

      Inputs (5)

      NameTypeDefaultDescription
      savenameSTRING
      main_loraCOMBOThe name of the merged LoRA.
      merge_loraCOMBOThe name of the merged LoRA.
      merge_typeCOMBO3 options: adaptive, manual, additive
      weightINT500–100

      Outputs (0)

      No outputs