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

CWB Merge Checkpoints (2 Models)

CWB's adaptive blend

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

Checkpoint merging usually means one number: a fixed interpolation weight between two models, applied to every layer identically. CWB - Consensus-Weighted Blending - is the smarter version. Instead of one global blend ratio, it computes, per layer, how similar each model is to a consensus, then weights each model's contribution by that similarity. Two layers that agree get one treatment; two layers that disagree get another. The result is a merged checkpoint where the blend adapts to what the models actually contain, and you never have to dial a single global alpha.

How it works

Pick two checkpoints from models/checkpoints. Model A is the primary contributor and the anchor - it supplies the output metadata, anchors tensor names and shapes, and is what you "preserve" when something goes missing. Model B is the second equal-prior contributor.

For each tensor, the merger does this: it computes an element-wise consensus (mean or median, depending on preset), measures each model's cosine similarity to that consensus, rejects contributors below a similarity threshold, raises the surviving similarities to a power, normalizes the weights, and produces a weighted sum. Then it optionally rescales the merged vector's norm to match the participating average. Nothing about this requires you to guess a ratio - the similarities are the weights.

The output key set is the union of both inputs. A tensor only present in B is copied unchanged. If a tensor is missing from A but present in B, it's still merged from the sources available rather than dropped. You control what happens with incompatible or missing tensors via mismatch_mode: skip preserves the anchor, zeros inserts a zero contribution where possible, error aborts loudly.

Inputs that matter

  • execution_mode - MERGE writes the new safetensors file. DOCUMENTATION ONLY returns the full CWB reference without loading or merging anything. Use it to read the spec before your first merge.
  • model_a / model_b - the two checkpoints.
  • cwb_preset (default balanced_mean) - complete use-case settings. Preset names are self-describing: _medn means median consensus, _rn enables norm rescaling, _dsc dynamic similarity contrast, _softcb the soft comfort bandpass. balanced_mean is the mild default; robust_medn is a median-based starting point; strongdiv_medn_rn_dsc_softcb pushes diversity hard. Don't overthink the first try - balanced_mean is fine.
  • output_filename - no extension; written atomically to models/checkpoints.
  • save_dtype - fp32/fp16/bf16 for generated tensors. Participating fp32 inputs stay fp32 unless override_dtype is on.
  • exclude_patterns / discard_patterns - regex (or glob) lists. Excludes preserve matching layers from the anchor instead of merging; discards omit matching tensors from the output entirely.
  • lazy_load (default on) - UEL streaming so the inputs aren't held in RAM. Leave it on.
  • force_clear_cache (default on) - clears Python and CUDA caches before each layer. Slower, but keeps memory bounded. This is the setting to flip off on a machine with plenty of VRAM.

Outputs

output_filename (the written file), documentation (the CWB reference), and cwb_report (a per-layer account of what was merged). Load the result with a regular CheckpointLoader to use it. The reports are worth a read after your first merge - they tell you which layers were preserved, merged, or discarded, so a weird result is diagnosable rather than mysterious.

What this is really for

The old workflow of "weight-sum 0.5 between anime and photoreal and pray" is exactly what this replaces. It's also the natural next step after running CheckpointModelAnalysis from the same pack - that node's CWB report is literally a preview of this node's math. It's a batch tool, not a generation node: it writes a file and stops, so run it, then switch to a normal workflow to test the result.

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. The meaningful dependency is unifiedefficientloader (UEL); the pack's other requirements.txt entries belong to its downloader nodes. These nodes use ComfyUI's newer extension API, so keep ComfyUI current. And note the CWB merger nodes are flagged experimental by the author - they work, but don't expect them to be battle-scarred yet.

CategoryModelUtils/Merging

Inputs (15)

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.
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_2_checkpointFilename 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