Nodes/More Math/CLIP Math
ComfyUI Node

CLIP Math

The deprecated CLIP merger old workflows still reference

By mcDandy·Created about a year ago·Updated 3 days ago· 5
CLIP Math
  • a
  • b
  • c
  • d
  • CLIP
Modela*(1-w)+b*w
length_mismatcherror
w0.00
x0.00
y0.00
z0.00

If you're looking at mrmth_CLIPMathNode specifically, odds are a downloaded workflow brought it in. This is the legacy, fixed-input version of the More Math CLIP merger - the one that fuses text encoders by running a math expression over their weights. It's superseded by mrmth_ag_CLIPMathNode, marked deprecated in the pack's source, and still works fine for old graphs. Here's the honest rundown.

What it is

The node takes up to four CLIP models - a is the required base, b, c, d are optional extras - plus four float variables w, x, y, z. The expression field is named Model (a quirk left over from when the model-like nodes shared one template) and defaults to a*(1-w)+b*w: a weighted blend of CLIP a and CLIP b by weight w. Feed it two text encoders and a blend factor and you get a patched CLIP that merges their weight distributions - the same trick as checkpoint merging, applied to the thing that reads your prompts.

Under the hood it shares the model-like merge machinery with the model and VAE nodes: it walks the union of state-dict keys across the input CLIPs, evaluates the expression per tensor, and applies the result as patches on a clone of a. length_mismatch handles different layer counts (error default, tile, pad) - the tooltip notes that for model-like nodes this "usually defaults to broadcast (zero for missing layers)."

Inputs and outputs

Required: a (CLIP), Model (the expression). Optional: b, c, d (CLIP), w, x, y, z (floats), length_mismatch. Output: one CLIP. Lazy evaluation skips unconnected inputs.

Installing it

Same as the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/mcDandy/more_math
cd more_math
pip install -r requirements.txt

Restart ComfyUI, or install "More math" from ComfyUI Manager. Only real dependency is antlr4-python3-runtime plus torch. No models.

Why you should care about the new one

The _ag_ version swaps the fixed a/b/c/d inputs for autogrow lists (V0..Vn, F0..Fn), which means more than two CLIPs without re-wiring, and an expression field that's actually labeled. Same engine, better surface. If you're rebuilding a workflow that used this node, migrating is a two-minute change. And as always with this pack: it's brand new and solo-maintained, so merged-CLIP outputs deserve a quick side-by-side test against the parents before you trust them - a subtly wrong text encoder doesn't crash, it just makes your prompts land slightly off.

Categorysd

Inputs (10)

NameTypeDefaultDescription
aCLIPMain CLIP (base)
ModelSTRINGa*(1-w)+b*wExpression to apply on weights
length_mismatchCOMBOerrorHow to handle mismatched layer counts. For models, this usually defaults to broadcast (zero for missing layers).
boptCLIPOptional 2nd CLIP
coptCLIPOptional 3rd CLIP
doptCLIPOptional 4th CLIP
woptFLOAT0.00
xoptFLOAT0.00
yoptFLOAT0.00
zoptFLOAT0.00

Outputs (1)

NameTypeDescription
CLIPCLIP