CWB Merge LoRAs (2 Models)
Merge two LoRAs into one file with CWB, instead of stacking them in a workflow
- cwb_config
- output_filename
- documentation
- cwb_report
Merging two LoRAs into one file is a classic move - you stop juggling two LoRA loader nodes at carefully balanced strengths and just load a single file. The catch has always been that naive blending averages the raw down/up matrices, which is wrong in ways that show up as degraded output. CWB's per-layer consensus weighting is a meaningfully better approach here, and this node applies it with LoRA structure in mind.
How it works
A LoRA layer is a down tensor and an up tensor that multiply to the effective delta. This merger treats each pair as one logical unit, so the blend happens on real layers, not individual matrices. Model A is the anchor (metadata, naming, and preservation reference); Model B is the second equal-prior contributor. For each logical layer, CWB computes a consensus (mean or median), measures each LoRA's similarity to it, and weights contributions by that similarity - so a layer where the two LoRAs agree gets averaged calmly, and a layer where they conflict gets a considered blend rather than a straight mean.
Because LoRA rows don't have a fixed semantic order, the LoRA presets default to similarity-based alignment (_sim in the name) rather than index alignment. The default preset is broad_sim_medn_rn_softcb: median consensus, similarity alignment, norm rescaling, and the soft comfort bandpass. The preset menu has gentler and harsher variants - moderate_... and conservative_... raise the alignment threshold, focused_... and strongfocus_... add dynamic similarity contrast to sharpen the differences.
Inputs that matter
- execution_mode -
MERGEwrites the file;DOCUMENTATION ONLYreturns the CWB reference without loading. - model_a / model_b - the two LoRAs.
- cwb_preset (default
broad_sim_medn_rn_softcb) - the LoRA-specific preset registry described above. - include_1d_diffs (default off) - LoRA files carry 1D tensors (alphas, biases) that aren't down/up pairs. Off preserves Model A's copies; on CWB-merges them in fp32. Leave off unless you know you need it.
- output_filename (default
cwb_merged_2_lora) - written tomodels/loras. - save_dtype / override_dtype - dtype for generated factors; fp32 inputs stay fp32 unless forced.
- mismatch_mode -
skippreserves the anchor,zerosinserts zero contributions,erroraborts for missing/incompatible groups. - exclude_patterns / discard_patterns / glob_patterns - regex (or glob) lists; excludes preserve matching logical groups from the anchor, discards drop them.
- lazy_load (default on), force_clear_cache (default on), process_device - the usual UEL streaming, per-layer cache flush, and CUDA-with-CPU-fallback.
Outputs
output_filename (the written file), documentation (the CWB reference), and cwb_report (per-layer merge detail). Load the merged LoRA with a normal LoRA Loader and apply it at whatever strength you want.
What this is really for
Two LoRAs trained on the same character or style, each good at different things, and you want one file. Or the "merge my LoRA into the one I downloaded" cleanup. It also sidesteps a real workflow problem - stacked LoRAs at high combined strength is how you get that overcooked look; a single merged file behaves more like a coherent fine-tune. Run LoRAModelAnalysis first if you want to see whether the two actually overlap before committing.
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). Keep ComfyUI current - newer extension API, and the CWB nodes are author-flagged experimental.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| execution_mode | COMBO | MERGE writes a new safetensors file. DOCUMENTATION ONLY returns the CWB reference without loading or merging inputs. | |
| model_a | COMBO | Primary contributor and preservation anchor. Supplies output metadata and anchors shared tensor names and shapes. | |
| model_b | COMBO | Second equal-prior contributor. CWB derives its effective per-vector influence from consensus similarity. | |
| cwb_preset | COMBO | broad_sim_medn_rn_softcb | Use-case preset. Name suffixes expose alignment, consensus, norm rescaling, DSC, soft comfort bandpass, and prefix preservation. A connected CWB Config overrides it completely. |
| mismatch_mode | COMBO | skip | For 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_filename | STRING | cwb_merged_2_lora | Filename without extension. The result is atomically written to this model category under ComfyUI's models directory. |
| save_dtype | COMBO | Requested dtype for generated floating tensors. Participating FP32 inputs keep a result FP32 unless Override Dtype is enabled. | |
| process_device | COMBO | Device used for per-layer FP32 CWB arithmetic. A CUDA out-of-memory error retries only the affected layer on CPU. | |
| exclude_patterns | STRING | One pattern per line. Matching layers are preserved from the anchor instead of merged. Uses regex unless Glob Patterns is enabled. | |
| discard_patterns | STRING | One pattern per line. Matching tensors or logical LoRA groups are omitted from the output. Uses regex unless Glob Patterns is enabled. | |
| glob_patterns | BOOLEAN | false | Interpret exclude and discard entries as shell-style glob patterns instead of regular expressions. |
| lazy_load | BOOLEAN | true | Use UEL low-memory loading so tensors are read and released per work unit instead of retaining the complete inputs in RAM. |
| force_clear_cache | BOOLEAN | true | Run Python garbage collection and clear the CUDA allocator cache before each layer. Reduces retained memory but can substantially slow merging. |
| override_dtype | BOOLEAN | false | Force generated tensors to save_dtype; guarded tensors and enabled 1D direct diffs are exempt. |
| include_1d_diffs | BOOLEAN | false | CWB-merge 1D direct diffs as FP32. Disabled preserves Model A. |
| cwb_configopt | CWB_CONFIG | Optional settings from CWB Custom Configuration. When connected, it completely overrides the selected preset. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| output_filename | * | — |
| documentation | STRING | — |
| cwb_report | STRING | — |