Nodes/Model Utility Toolkit/CWB LoRA Multi-Merge
ComfyUI Node

CWB LoRA Multi-Merge

Merge 2 to 8 LoRAs in one go — the CWB LoRA blender that scales

By silveroxides·Created about a year ago·Updated about 24 hours ago· 14
CWB LoRA Multi-Merge
  • cwb_config
  • output_filename
  • documentation
  • cwb_report
execution_modeMERGE
lora_count2
lora_1
lora_2
lora_3None
lora_4None
lora_5None
lora_6None
lora_7None
lora_8None
cwb_presetbroad_sim_medn_rn_softcb
mismatch_modeskip
output_filenamecwb_merged_multi_lora
save_dtypebf16
process_devicecuda
exclude_patterns
discard_patterns
glob_patternsfalse
lazy_loadtrue
force_clear_cachetrue
override_dtypefalse
include_1d_diffsfalse
counterfactual_weight_sweepfalse

The CWBLoRAMultiMerger is the LoRA merger for people who stopped counting their LoRA stack. It consensus-merges anywhere from 2 to 8 LoRAs into a single file, with the same per-layer Consensus-Weighted Blending as the two- and three-input variants - just with a lot more contributors to keep straight. If you've got a pile of style LoRAs you want to collapse into one loadable file, this is the node.

How it works

You pick a lora_count between 2 and 8, then fill in the matching number of lora_1lora_8 inputs. The first is the anchor - metadata source and preservation reference. The rest are equal-prior contributors, with any beyond your count left on None. Set the count to 4 and only 4 inputs are read; leave one selected-but-None inside your count and the node refuses to run with a clear "LoRA Count includes unselected input(s)" error rather than silently merging the wrong set.

For each logical layer (each down/up pair treated as a unit), CWB computes a consensus, measures every contributor's cosine similarity to it, and weights contributions by similarity. With 5-8 contributors the median consensus and the diversity bandpass matter a lot - that's what keeps two near-identical LoRAs from dominating a merge of six. The default preset broad_sim_medn_rn_softcb is designed for exactly this crowd; the _softcb suffix means the diversity weighting is the soft variety, which behaves better when contributors are genuinely similar.

Two things are worth calling out. lazy_load uses "bounded" UEL streaming here - tensors are read per work unit and released after each completed layer, so merging eight LoRAs stays RAM-friendly even though they're all in play. And there's a counterfactual_weight_sweep toggle: turn it on and the node evaluates a bunch of alpha/beta/threshold/DSC/bandpass weight combinations from the consensus similarities it already computed, appending them to the report without any extra model loads or saved files. It's a cheap way to see how sensitive your merge is to the weighting parameters - a genuinely nice touch if you're trying to understand why a merge came out the way it did.

Inputs that matter

  • lora_count - how many of the consecutive lora_N inputs to include.
  • lora_1 … lora_8 - the files; lora_1 is the anchor.
  • cwb_preset (default broad_sim_medn_rn_softcb) - the LoRA registry.
  • execution_mode - MERGE (default) writes the output; DOCUMENTATION ONLY opens no model files.
  • include_1d_diffs (default off) - merge 1D tensors (alphas, biases) in fp32 instead of preserving the anchor.
  • counterfactual_weight_sweep (default off) - the parameter-sensitivity sweep described above.
  • output_filename (default cwb_merged_multi_lora) - written to models/loras.
  • save_dtype (default bf16) - dtype for the generated factors; bf16 is a reasonable default for LoRA files.
  • mismatch_mode, exclude_patterns, discard_patterns, glob_patterns, force_clear_cache, override_dtype - same meanings as the other CWB mergers.

Outputs

output_filename (the written file), documentation (the CWB reference), and cwb_report (per-layer detail plus sweep results if enabled). Load with a normal LoRA Loader.

Where this pays off

Consolidating a character + style + quality stack you keep re-applying at fractional strengths, or merging a whole batch of similar concept LoRAs into one file to reduce workflow clutter. It's a batch node - write the file, then test it in a normal workflow.

Install

Part of Model Utility Toolkit (silveroxides/ComfyUI-ModelUtils). ComfyUI Manager → search "Model Utility Toolkit", or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-ModelUtils

Restart ComfyUI. Real dependency: unifiedefficientloader (UEL) for the streaming loads. Keep ComfyUI current - the pack uses the newer extension API, and this node is author-flagged experimental.

CategoryModelUtils/LoRA/Merge

Inputs (24)

NameTypeDefaultDescription
execution_modeCOMBOMERGEMERGE writes an output; DOCUMENTATION ONLY opens no model files.
lora_countCOMBO2Number of consecutive LoRA inputs to include.
lora_1COMBOAnchor LoRA and metadata source.
lora_2COMBOSecond equal-prior LoRA contributor.
lora_3COMBONoneOptional third equal-prior contributor.
lora_4COMBONoneOptional fourth equal-prior contributor.
lora_5COMBONoneOptional fifth equal-prior contributor.
lora_6COMBONoneOptional sixth equal-prior contributor.
lora_7COMBONoneOptional seventh equal-prior contributor.
lora_8COMBONoneOptional eighth equal-prior contributor.
cwb_presetCOMBObroad_sim_medn_rn_softcbLoRA-specific preset. A connected CWB Config overrides it completely.
mismatch_modeCOMBOskipPreserve the anchor, insert zeros, or abort for missing and incompatible logical groups.
output_filenameSTRINGcwb_merged_multi_loraFilename without extension under ComfyUI's LoRA directory.
save_dtypeCOMBObf16Requested dtype for generated floating factors.
process_deviceCOMBOcudaPer-layer FP32 processing device; CUDA OOM retries the affected layer on CPU.
exclude_patternsSTRINGPreserve matching logical groups from the anchor.
discard_patternsSTRINGOmit matching tensors or logical groups from the output.
glob_patternsBOOLEANfalseInterpret filter entries as shell-style globs instead of regular expressions.
lazy_loadBOOLEANtrueUse bounded UEL work-unit streaming and release each completed input layer.
force_clear_cacheBOOLEANtrueCollect Python and CUDA caches before each layer at a potential speed cost.
override_dtypeBOOLEANfalseForce generated floating factors to the requested save dtype.
include_1d_diffsBOOLEANfalseCWB-merge 1D direct differences as FP32 instead of preserving the anchor.
counterfactual_weight_sweepBOOLEANfalseEvaluate alpha, beta, similarity-threshold, DSC, and comfort-bandpass weight combinations from each already-computed consensus similarity vector and append them to the report without additional model loads or saved outputs.
cwb_configoptCWB_CONFIGOptional complete override from CWB Custom Configuration.

Outputs (3)

NameTypeDescription
output_filename*
documentationSTRING
cwb_reportSTRING