Nodes/Mecha Merge Node Pack/Add Opposite Mask
ComfyUI Node

Add Opposite Mask

Get the mask itself — 'where do these models disagree?' as a param recipe

By ljleb·Created 3 years ago·Updated about a month ago· 101
Add Opposite Mask
  • a (delta|param|weight)
  • b (delta|param|weight)
  • c (delta|param|weight)
  • alpha (1.0)
  • recipe
merge_checkpointingfalse

Most of the merge nodes in the comfy-mecha pack hand you a finished model. This one hands you the diagnostic. Add Opposite Mask computes the "where do these models actually disagree" mask - the same mask Add Opposite uses internally - and outputs it as a param recipe: a per-key set of 0-to-2 weighting values. It doesn't add anything to anything. It just shows you the map.

What the mask means

Give it a, b, and c, and per weight it computes 2 * |a − b| / (|a − b| + |a + b − 2c|), scaled by alpha (default 1.0). High values where a and b genuinely diverge beyond what the anchor c explains; low values where they're effectively aligned. It's the same math as Add Opposite minus the actual add - which is exactly why this node exists: to let you inspect, tune, or reuse the mask without committing to the merge.

Inputs: a, b, c (each accepts delta|param|weight) and alpha. Output: one recipe (MECHA_RECIPE) in param space.

What to do with a param recipe

  • Inspect it. Feed it into a param display or just note the shape - a mask that's near-uniform is a sign your three models aren't as divergent as you thought, and a mask with sharp peaks is telling you exactly which blocks carry the disagreement.
  • Multiply it into another merge. Param recipes slot into the param inputs of other recipe nodes (like Scale or as the alpha slot of a masked operation), so you can apply this disagreement mask as a weighting layer on top of whatever you're actually merging.
  • Build your own Add Opposite. The node that does the full a + (b − c) * mask already exists in this pack; use the Mask version when you want to tune or reuse the mask rather than take the default add.

The pack's Add Strict Opposite Mask is the stricter cousin - same idea, but the mask is clamped so only "truly opposite" weights get through (it uses (c − a)(b − c) sign-aware math instead of the symmetric ratio), which makes it sharper but also more brittle to noise. Reach for the strict version when you're confident the disagreement is clean and you want maximum selectivity.

Install & gotchas

ComfyUI Manager → search mecha → "Mecha Merge Node Pack", or:

cd ComfyUI/custom_nodes
git clone https://github.com/ljleb/comfy-mecha.git
pip install -r comfy-mecha/requirements.txt

Restart after. Dependency is sd-mecha==1.1.7.

The trap is the output type: a param recipe is not a model. Wire it into Mecha Merger directly and you'll get an error or garbage - it's meant to be consumed as a weighting input. And c is the anchor that defines "opposite"; a wrong or missing reference makes the mask meaningless. Use your real base model there.

Categorymecha

Inputs (5)

NameTypeDefaultDescription
a (delta|param|weight)MECHA_RECIPE
b (delta|param|weight)MECHA_RECIPE
c (delta|param|weight)MECHA_RECIPE
alpha (1.0)optMECHA_RECIPE1
merge_checkpointingoptBOOLEANfalseSpeeds up an entire branch of a merge graph that does not change often in exchange of memory. - true: store the first output of this recipe node on cpu memory in fp16. On subsequent workflow executions, as long as the inputs do not change, the cached keys are returned after being cast to the original device and dtype. - false: do not store the output. The recipe and its inputs will re-execute on subsequent workflow executions. Note that the memory used to checkpoint the output is distinct from the cache feature. In general, you probably want to either use this *or* a cache unit, but not both at the same time because the memory adds up. The difference between merge checkpointing and cache is that merge checkpointing completely re-merges from scratch if any input changes. Merge checkpointing is also generally much faster than cache in the fast path.

Outputs (1)

NameTypeDescription
recipeMECHA_RECIPE