Nodes/Model Utility Toolkit/CWB Merge LoRAs (3 Models)
ComfyUI Node

CWB Merge LoRAs (3 Models)

Three LoRAs into one file, blended by consensus per layer

By silveroxides·Created about a year ago·Updated about 24 hours ago· 14
CWB Merge LoRAs (3 Models)
  • cwb_config
  • output_filename
  • documentation
  • cwb_report
execution_mode
model_a
model_b
model_c
cwb_presetbroad_sim_medn_rn_softcb
mismatch_modeskip
output_filenamecwb_merged_3_lora
save_dtype
process_device
exclude_patterns
discard_patterns
glob_patternsfalse
lazy_loadtrue
force_clear_cachetrue
override_dtypefalse
include_1d_diffsfalse

The three-input version of the CWB LoRA merger - the one that lets you collapse a three-LoRA stack into a single file. If you've been running two or three LoRA loaders at fractional strengths and fighting the overcooked look, this is the node that does the combination in advance, per layer, without a single global strength guess.

How it works

Same Consensus-Weighted Blending engine as CWBLoRATwoMerger, with a third equal-prior contributor. Model A anchors metadata, naming, and preservation; Models B and C contribute. LoRA down/up pairs are treated as one logical layer each, and for every layer CWB computes a consensus (mean or median), measures each of the three LoRAs' cosine similarity to it, and weights contributions by similarity. Three inputs is where the median consensus really shines - if one LoRA is an outlier on some layer, median keeps it from dragging the blend. The LoRA presets default to similarity-based alignment (LoRA rows have no fixed semantic order), and the default broad_sim_medn_rn_softcb is a solid middle ground; strongfocus_sim_medn_rn_dsc_softcb pushes the differences harder.

Inputs that matter

  • execution_mode - MERGE writes the file; DOCUMENTATION ONLY returns the CWB reference without loading.
  • model_a / model_b / model_c - your three LoRAs. A anchors metadata.
  • cwb_preset (default broad_sim_medn_rn_softcb) - the LoRA registry; consider a median variant, which is the default here.
  • include_1d_diffs (default off) - merges the 1D tensors (alphas, biases) in fp32 instead of preserving Model A's. Leave off unless you need it.
  • output_filename (default cwb_merged_3_lora) - written to models/loras.
  • save_dtype / override_dtype - dtype for generated factors.
  • mismatch_mode - skip / zeros / error for missing or incompatible groups.
  • exclude_patterns / discard_patterns / glob_patterns - regex (or glob) lists.
  • lazy_load (default on), force_clear_cache (default on), process_device - the usual streaming, flushing, and CUDA-with-CPU-fallback.

Outputs

output_filename (the written file), documentation (the CWB reference), and cwb_report (per-layer detail). Load the merged file with a normal LoRA Loader.

The realistic use case

Three LoRAs each doing one job - a character, a style, a quality/detail boost - that you want as a single coherent file rather than a three-loader stack. Merging to one file also tends to reduce the brittle parameter juggling that stacked LoRAs force on you. Run LoRAModelAnalysis on the pairs first if you want to know how much they overlap.

Install

From 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). Keep ComfyUI current - newer extension API, experimental CWB nodes.

CategoryModelUtils/Merging

Inputs (17)

NameTypeDefaultDescription
execution_modeCOMBOMERGE writes a new safetensors file. DOCUMENTATION ONLY returns the CWB reference without loading or merging inputs.
model_aCOMBOPrimary contributor and preservation anchor. Supplies output metadata and anchors shared tensor names and shapes.
model_bCOMBOSecond equal-prior contributor. CWB derives its effective per-vector influence from consensus similarity.
model_cCOMBOThird equal-prior contributor. CWB derives its effective per-vector influence from consensus similarity.
cwb_presetCOMBObroad_sim_medn_rn_softcbUse-case preset. Name suffixes expose alignment, consensus, norm rescaling, DSC, soft comfort bandpass, and prefix preservation. A connected CWB Config overrides it completely.
mismatch_modeCOMBOskipFor missing or incompatible anchored inputs: skip preserves the anchor, zeros inserts a zero contribution where possible, and error aborts. A lone secondary-only tensor is copied unchanged.
output_filenameSTRINGcwb_merged_3_loraFilename without extension. The result is atomically written to this model category under ComfyUI's models directory.
save_dtypeCOMBORequested dtype for generated floating tensors. Participating FP32 inputs keep a result FP32 unless Override Dtype is enabled.
process_deviceCOMBODevice used for per-layer FP32 CWB arithmetic. A CUDA out-of-memory error retries only the affected layer on CPU.
exclude_patternsSTRINGOne pattern per line. Matching layers are preserved from the anchor instead of merged. Uses regex unless Glob Patterns is enabled.
discard_patternsSTRINGOne pattern per line. Matching tensors or logical LoRA groups are omitted from the output. Uses regex unless Glob Patterns is enabled.
glob_patternsBOOLEANfalseInterpret exclude and discard entries as shell-style glob patterns instead of regular expressions.
lazy_loadBOOLEANtrueUse UEL low-memory loading so tensors are read and released per work unit instead of retaining the complete inputs in RAM.
force_clear_cacheBOOLEANtrueRun Python garbage collection and clear the CUDA allocator cache before each layer. Reduces retained memory but can substantially slow merging.
override_dtypeBOOLEANfalseForce generated tensors to save_dtype; guarded tensors and enabled 1D direct diffs are exempt.
include_1d_diffsBOOLEANfalseCWB-merge 1D direct diffs as FP32. Disabled preserves Model A.
cwb_configoptCWB_CONFIGOptional settings from CWB Custom Configuration. When connected, it completely overrides the selected preset.

Outputs (3)

NameTypeDescription
output_filename*
documentationSTRING
cwb_reportSTRING