Nodes/Tensor Prism/Advanced Weighted Mask Merge (Tensor Prism)
ComfyUI Node

Advanced Weighted Mask Merge (Tensor Prism)

Merge Checkpoints With a Scalpel, Not a Blender

By Arctenox·Created 12 months ago·Updated 7 months ago· 2
Advanced Weighted Mask Merge (Tensor Prism)
  • model_A
  • model_B
  • mask
  • merged_model
merge_ratio0.50
blend_modelinear
curve_power1.0
preserve_extremesfalse
noise_injection0.000
layer_scalinguniform

If you've ever merged two checkpoints with a plain weighted sum, you know the feeling: the result looks like an average of both parents and an inherits the defects of both too. Plain merges are blunt instruments - that's most of why the checkpoint scene homogenizes. Advanced Weighted Mask Merge is the opposite: a tensor-level, mask-guided merge that lets you decide which weights get blended, not just how much. You tell it a mask, and it selectively pulls from model B in the layers you pointed at while leaving the rest of model A alone.

It ships in Tensor Prism (category Tensor_Prism/Mask), a hobbyist merging pack by Arctenox. Full disclosure on that: the author openly says it was "vibe-coded" with Gemini 2.5 Flash and Claude 4, it's GPL-3.0, and nobody on Reddit is really talking about it. Treat it as a fun toy, verify every merge you make, and don't be surprised if the occasional edge case bites. That honesty is refreshing, honestly.

What it actually does

Wire in two MODELs (same architecture - SDXL with SDXL, SD1.5 with SD1.5), plus a mask. The node clones model A, walks every weight tensor that exists in both models and in the mask, and computes:

merged = weight_A * (1 - blend) + weight_B * blend

where blend starts as your mask's per-tensor value, then gets reshaped by the blend_mode curve, scaled by the layer_scaling mode, and multiplied by the global merge_ratio. The result is applied as an in-memory patch - nothing writes to disk until you save it.

The catch that trips everyone up: this mask is not an image mask. It's Tensor Prism's own tensor mask dict, produced by the Model Mask Generator node sitting right next to it in the menu. A beginner will Google "mask" and think inpainting; here a mask is just a per-parameter weight between 0 and 1 describing how much of B to pull in. Feed a bare mask without a mask_dict and the node quietly treats everything as 1.0 - a full-strength uniform merge that defeats the entire point.

The inputs that matter

  • model_A / model_B - two loadable checkpoints. Merge ratio 0 means A only, 1 means B only, and it goes up to 2.0 if you want to extrapolate past B (usually a bad idea).
  • blend_mode - the curve applied to your mask values before blending. linear is the straight average; sigmoid, cosine, exponential, logarithmic, and smoothstep bend the transition so the mask's mid-range values snap harder or softer. curve_power (0.1–5.0) controls how sharp that bend is.
  • layer_scaling - uniform applies your mask evenly; depth_progressive, shallow_bias, and deep_bias weight early vs. late layers. Handy for "keep the low-level style of A, take B's composition" style moves.
  • preserve_extremes - leave mask values near 0 untouched and near 1 at full strength. Turn it on when your mask is already sharp and you don't want the curve blurring its edges.
  • noise_injection (0–0.1) - adds a tiny bit of noise scaled to the weights, supposedly to break symmetry and find emergent behaviors. At the default 0 it does nothing. If you touch it, keep it under 0.01 and set a seed upstream; this is the fiddliest knob on the node.
  • Output: merged_model - a patched MODEL you can run through a sampler or Save Checkpoint to keep. Remember: in-memory until you save.

Installing it

cd ComfyUI/custom_nodes/
git clone https://github.com/AstrionX/ComfyUI-Tensor-Prism-Node-Pack

then restart ComfyUI, or use ComfyUI Manager and search "Tensor Prism". No model downloads. Dependencies are plain torch + numpy; the code also imports psutil for its memory handling, and the shipped requirements.txt is empty, so if you hit an import error you may need pip install psutil.

Where people get burned

Mismatched shapes and architectures are silently skipped, so a merge can "succeed" while doing almost nothing - check your layer count before trusting it. If you see "expected tensors on same device" errors, you're on an old version; v1.5.0+ fixed those. And the author's own developer notes admit the block-layer merging might not work on ComfyUI 1.6.5+ - if mask merging misbehaves, the plain Weighted Mask Merge node is the simpler fallback. Start with linear and a gentle mask. This node's whole job is precision; a blunt first pass is a waste of it.

CategoryTensor_Prism/Mask

Inputs (9)

NameTypeDefaultDescription
model_AMODEL
model_BMODEL
maskMASK
merge_ratioFLOAT0.500–2
blend_modeCOMBOlinear6 options: linear, sigmoid, cosine, exponential, logarithmic, smoothstep
curve_poweroptFLOAT1.00.1–5
preserve_extremesoptBOOLEANfalse
noise_injectionoptFLOAT0.0000–0.1
layer_scalingoptCOMBOuniform4 options: uniform, depth_progressive, shallow_bias, deep_bias

Outputs (1)

NameTypeDescription
merged_modelMODEL