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

CWB Merge Models (3 Models)

Three UNets/DiTs, one consensus-merged denoiser

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

The three-input CWB merger for standalone diffusion models - UNet or DiT files in models/diffusion_models. It's the three-model sibling of CWBModelTwoMerger, and with three contributors the consensus math gets meaningfully stronger, because the median becomes a genuinely robust center that a single outlier can't skew.

How it works

Model A anchors the merge: it supplies output metadata, anchors tensor names and shapes, and is the preservation reference for anything missing or incompatible. Models B and C are equal-prior contributors. For each tensor, the engine computes an element-wise consensus (mean or median per preset), measures each of the three models' cosine similarity to that consensus, and weights each contribution by its similarity - no global blend ratio anywhere. Output keys are the union of all inputs; tensors only present in secondary inputs are merged from the sources available or copied; mismatch_mode decides between skip (preserve anchor), zeros (zero contribution), and error (abort).

The practical tip for three inputs: try a median preset first. With three models, one of them being a lone outlier on some layer is common, and robust_medn (or diverse_medn_rn_dsc_softcb if you want the diversity bandpass) handles that far better than a mean that gets dragged toward the outlier.

The result is a single denoiser written to models/diffusion_models - load it with your architecture's UNet/DiffusionModel loader, then bring your own text encoder and VAE.

Inputs that matter

  • execution_mode - MERGE writes the file; DOCUMENTATION ONLY returns the CWB reference and opens nothing.
  • model_a / model_b / model_c - your three files. A anchors metadata and naming.
  • cwb_preset (default balanced_mean) - the dense-model presets; consider robust_medn here.
  • output_filename (default cwb_merged_3_model) - written to models/diffusion_models.
  • save_dtype / override_dtype - dtype for generated tensors; fp32 inputs stay fp32 unless forced.
  • exclude_patterns / discard_patterns / glob_patterns - regex (or glob) lists; excludes preserve matching layers from the anchor, discards drop them.
  • lazy_load (default on) - UEL streaming; keep it on so three large files don't pile up in RAM.
  • force_clear_cache (default on) - per-layer flushing; memory-safe, slower.
  • process_device - CUDA with per-layer CPU retry on OOM.

Outputs

output_filename (the written file), documentation (the CWB reference), and cwb_report (per-layer merge detail worth reading after the first run).

Why you'd reach for it

A base, a style model, and a character/quality specialist - the classic three-way stack that per-layer consensus weighting handles better than any fixed ratio. It's a batch node: it writes a file and stops. Run DiffusionModelAnalysis on the pairs first if you want a preview of the similarity math.

Install

From Model Utility Toolkit (silveroxides/ComfyUI-ModelUtils), one install for the whole pack. 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 updated - newer extension API - and expect the author-flagged experimental edge cases on oddball files.

CategoryModelUtils/Merging

Inputs (16)

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_presetCOMBObalanced_meanUse-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_modelFilename 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.
cwb_configoptCWB_CONFIGOptional settings from CWB Custom Configuration. When connected, it completely overrides the selected preset.

Outputs (3)

NameTypeDescription
output_filename*
documentationSTRING
cwb_reportSTRING