Magnitude Masker
Protect a model's biggest weights during a merge
- model_a
- model_b
- MODEL_MASK
Magnitude Masker is the node at the heart of this pack's recommended workflow. It builds a MODEL_MASK - a boolean signature of which parameters a merge is allowed to touch - based on the magnitude of the deltas between two models. Feed it two checkpoints, and it returns a mask that says "these are the parameters where the two models differ a lot" or "these are the ones where they barely differ," depending on how you set it.
Why does that matter? Training (and overtraining) creates high-magnitude parameters - weights that grew large because they're load-bearing. Different models have those big weights in different places, so if you merge without protection, you can stomp on a weight that model A was depending on. The pack's core idea, straight from the README: "filtering out high magnitude parameters (by selecting 'below', with model A as your filter target and SD1.5 as the base) will allow a merge to not disturb the high strength parameters of model A." That's the exact recipe this node is built for.
The inputs that matter
- model_a, model_b - the two models whose deltas define the mask. Per the recipe, model A is the model you want to protect in the upcoming merge, and model B is the reference (often a plain base like SD1.5).
- threshold - a quantile between 0 and 1. The node computes, for each layer, the magnitude of
delta = B - A, finds the threshold value at this quantile, and marks parameters accordingly. - threshold_type -
medianorquantile. The tensors are huge, so the node processes them in chunks and combines per-chunk thresholds. The author's notes:medianerrs toward the middle,quantileerrs toward the edges. Start withmedian(the default). - select -
aboveorbelow(defaultbelow). "Select parameters whose delta magnitude is below the threshold" - i.e. the parameters where the two models barely differ - which is what you want when you're protecting model A's high-magnitude weights from being disturbed.
The output
A MODEL_MASK, one boolean per parameter. Wire it into any merger's optional model_mask input (Model Merger (DARE), Block/DARE, Advanced, Advanced/DARE all take one), or through Mask Operations / Mask Edit to combine or hand-tune it first. Note the mask is built from the delta between A and B, so it's specific to that pair - reuse it for a different pair only if you understand the semantics.
Install and gotchas
ComfyUI Manager (search "DareMerge") or:
cd ComfyUI/custom_nodes
git clone https://github.com/54rt1n/ComfyUI-DareMerge
Restart ComfyUI. Dependencies: matplotlib, numpy, torch, pillow, no downloads.
The real gotcha is memory: a mask is a boolean per parameter of a whole checkpoint, and building it means materializing the delta tensors. The pack chunks the quantile math to cope, and it prints peak VRAM usage to the console after the run - if you're near your card's limit, this is the node that will find out. And remember the mask only protects; it does nothing on its own. A Magnitude Masker with nothing attached is just a very expensive boolean tensor sitting in memory.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| model_a | MODEL | — | |
| model_b | MODEL | — | |
| threshold | FLOAT | 0.000–1 | — |
| threshold_type | COMBO | median | 2 options: median, quantile |
| select | COMBO | below | 2 options: above, below |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL_MASK | MODEL_MASK | — |