Weighted Sum
The weighted sum merge, without the 20 GB RAM spike
- a (delta|param|weight)
- b (delta|param|weight)
- alpha (0.5)
- recipe
Weighted sum is the oldest, most boring, most used merge in the hobby: result = (1 - alpha) * model_a + alpha * model_b. Two checkpoints, one slider, and you get a blend - 50/50 of a realism base and an anime base, a touch of style model A over backbone B, whatever. In the A1111 world you'd reach for SuperMerger for this; in ComfyUI this node from the comfy-mecha pack is the modern equivalent, and it has one big advantage: it doesn't need to load both full models into VRAM at once.
How it works
Like every node in this pack, Weighted Sum Mecha Recipe doesn't merge anything itself. It builds a MECHA_RECIPE - a graph of instructions describing the merge - and the graph only gets executed when you feed it to a Mecha Merger. sd-mecha (the underlying library, also by ljleb) processes the merge one tensor key at a time, reading from the safetensors header and streaming results to disk. The author's own pitch is that you can run a weighted sum on a phone. The practical version of that: an SDXL-weighted-sum merge that used to want most of your system RAM now runs comfortably alongside a browser.
Inputs:
aandb- twoMECHA_RECIPEinputs (wire inModel Mecha Recipenodes for your checkpoints).alpha- the blend. Default 0.5, so a straight 50/50. 0 gives you pure A, 1 gives you pure B. The interesting part: alpha is itself aMECHA_RECIPE, so you can feed it per-block weights (seeBlocks Mecha Hyper) for merge-block weighting, or aFloatrecipe for a uniform value. That's how you get the "MBW" merges people obsess over.
Output is one recipe (MECHA_RECIPE), which you chain into Mecha Merger to get a MODEL, CLIP, and VAE you can save.
The merge_checkpointing toggle on the node caches the branch on CPU in fp16 once computed - handy when you're running the same expensive merge repeatedly while fiddling with other inputs. The full default-merge settings (device, dtype, buffer size, threads) live on Mecha Merger, not here.
A note on merges in general
Merging feels like a cheat code until you hit the reality that stacked weighted sums drift toward the mush between two models. Weighted sum is a great first tool, but for "add one thing to another" you usually want Add Difference (a + alpha * delta), and for combining many models the TIES-style merges in this pack exist for a reason. If your goal is just "make checkpoint C look more like B," start here; if you're chasing a specific character or style, a LoRA merge is usually cleaner.
Install
ComfyUI Manager → search mecha → install "Mecha Merge Node Pack". Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/ljleb/comfy-mecha.git
pip install -r comfy-mecha/requirements.txt
Restart after. Only dependency is sd-mecha==1.1.7; no models to download.
Gotchas
- Both inputs need to be in the same merge space (weight) for a plain blend - the node labels tell you which spaces are accepted. If you feed a delta where a weight is expected, the merge may silently produce garbage or refuse with a validation error, which is the better outcome.
- Don't forget
Mecha Merger'soutput_dtype- default fp16 is fine for most, but if you're merging at high precision for later distillation, flip it to fp32 and setdefault_merge_dtypeaccordingly on the merger. - The pack's whole trick is streaming; if you see the RAM spike anyway, check that
total_buffer_sizeon the merger isn't set absurdly high.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| a (delta|param|weight) | MECHA_RECIPE | — | |
| b (delta|param|weight) | MECHA_RECIPE | — | |
| alpha (0.5)opt | MECHA_RECIPE | 0.5 | — |
| merge_checkpointingopt | BOOLEAN | false | Speeds 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)
| Name | Type | Description |
|---|---|---|
| recipe | MECHA_RECIPE | — |