CWB Merge Text Encoders (3 Models)
Three text encoders, one consensus-merged CLIP
- cwb_config
- output_filename
- documentation
- cwb_report
The three-input version of the CWB text encoder merger. It takes three text encoder files from models/text_encoders and produces one consensus-blended encoder, where the blend adapts per tensor instead of using a single fixed ratio. Three inputs is where the median consensus earns its keep - a lone outlier encoder can't drag the center around the way it can with a mean.
How it works
Model A is the anchor: output metadata, tensor name/shape anchoring, and the preservation reference for anything missing or incompatible. Models B and C are equal-prior contributors. For each tensor, CWB computes an element-wise mean or median consensus, measures each of the three encoders' cosine similarity to that consensus, rejects below-threshold contributors, powers and normalizes the surviving weights, and produces the weighted sum (with optional norm rescaling). Text-encoder tensors always use fixed coordinate alignment, so no alignment toggle - the layers line up by position, which is correct for a fixed-architecture encoder.
Output keys are the union of all inputs; tensors missing from the anchor but present elsewhere are merged from the sources available; mismatch_mode decides between skip, zeros, and error for incompatible tensors. With three encoders, try a median preset (robust_medn) before the default mean - one out-of-family encoder on a layer is exactly the failure mode median handles best.
Inputs that matter
- execution_mode -
MERGEwrites the file;DOCUMENTATION ONLYreturns the CWB reference and opens nothing. - model_a / model_b / model_c - your three encoders. A anchors metadata.
- cwb_preset (default
balanced_mean) - dense presets;robust_mednrecommended for three inputs. - output_filename (default
cwb_merged_3_text_encoder) - written tomodels/text_encoders. - save_dtype / override_dtype - dtype for generated tensors.
- 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.
- 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 detail). Load the result with a CLIP/Text Encoder Loader and use it for prompt conditioning as normal.
Why you'd reach for it
Three-way encoder merges are rare but real - combining two style-specific CLIPs with a base encoder, for example, to get prompt understanding that none of the three alone provides. It's a batch node: run it, then test the resulting file in a normal workflow. If you want to preview the similarity math first, run CheckpointModelAnalysis or the text-encoder analysis on the pairs.
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 - and expect the occasional experimental edge case.
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. | |
| model_c | COMBO | Third equal-prior contributor. CWB derives its effective per-vector influence from consensus similarity. | |
| cwb_preset | COMBO | balanced_mean | 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_3_text_encoder | 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. |
| 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 | — |