Tensor Sum
Swap a slice of one model's weights with another's
- a (delta|param|weight)
- b (delta|param|weight)
- width (0.5)
- offset (0.0)
- recipe
Most merge methods blend every weight by one rule. Tensor Sum is the surgical one: for each tensor, it copies a contiguous slice of model B's values into model A, leaving the rest of A alone. Same idea as block-weighting, but at the raw tensor level, with a slider for where and how much.
Inputs:
a (delta|param|weight)- the base you keepb (delta|param|weight)- the values you pull inwidth (0.5)- the fraction of each tensor's first axis that comes from B. 0.5 means half.offset (0.0)- where that slice starts, as a fraction from 0 to 1.
The output is a MECHA_RECIPE in the same space as the inputs. Give it to Mecha Merger and you've got a model where, per tensor, a window of B's weights sits inside A's.
What it's actually for
This is the "keep the early layers from A, the late layers from B" trick, taken further than block weights because it operates on the innermost dimension of each tensor rather than whole layers. With width at 0.5 and no offset, roughly the first half of every tensor is B's and the rest is A's. Cranking width above 0.5 flips the logic - the window inverts, so you keep only a thin band of A. It's a niche, experimental tool; people reach for it when they want to splice model anatomy at a finer grain than the architecture's blocks allow.
How it works
Per key, the node computes the slice bounds from width and offset (handling wraparound), then does a direct element assignment of that region. It's about as cheap as merges get: element-wise, one key at a time, no state between keys - comfortably within the pack's low-memory philosophy.
Install
Pack-level: 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 ComfyUI. Only dependency is sd-mecha; no model downloads.
Gotchas
Don't confuse it with an element-wise sum - the name is misleading. There's no adding here, just region copying. And because it slices the first axis of each tensor (for most diffusion weights, the output-channel dimension), the visual effect of "the first half" isn't the same as "the first layers" - those are different axes entirely. If you want layer-level control, use the block-weights nodes; Tensor Sum is for when you specifically want per-tensor window surgery. The merge_checkpointing toggle works like everywhere else in the pack: fp16 CPU caching for stable branches, don't pair it with cache units.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| a (delta|param|weight) | MECHA_RECIPE | — | |
| b (delta|param|weight) | MECHA_RECIPE | — | |
| width (0.5)opt | MECHA_RECIPE | 0.5 | — |
| offset (0.0)opt | MECHA_RECIPE | 0 | — |
| 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 | — |