ComfyUI Node

Ties Sum

Merge a pile of LoRAs without them fighting to a standstill

By ljleb·Created 2 years ago·Updated 30 days ago· 101
Ties Sum
  • models (delta)
  • k (1.0)
  • vote_sgn (False)
  • recipe
merge_checkpointingfalse

Add five LoRAs together and they cancel each other out - one wants a key positive, the other wants it negative, and the sum lands somewhere useless. TIES (from the TIES-Merging paper, arXiv 2306.01708) exists to stop that: trim, elect a sign by majority vote, and only then average. The Ties Sum node in comfy-mecha is the plain version of that algorithm, and it's the node people actually mean when they talk about "merging LoRAs without burning."

Inputs:

  • models (delta) - an arbitrary list of deltas to merge. Wire several Lora Mecha Recipe or Subtract outputs into a Mecha Recipe List, then into here. All inputs must be in delta space.
  • k (1.0) - the trim. The fraction of each tensor's largest-magnitude values that survive. Default 1.0 keeps everything (i.e. no trimming); the paper's classic setting is ~0.2, dropping the 80% of small-magnitude noise.
  • vote_sgn (False) - majority vote on sign only. Leave it off unless you want magnitude-weighted voting.

Output is a MECHA_RECIPE in delta space - a merged difference vector, not a model.

Why you'd reach for it

LoRA packing, mostly. If you have a dozen style or character LoRAs and want one merged LoRA that doesn't melt into gray soup, TIES is the standard first stop - the community's shorthand for "this is how you combine LoRAs without them fighting." It also works for merging a batch of checkpoints expressed as deltas from a common base.

How it works

Per tensor: trim each delta to its top-k values, take the sign of each surviving value, vote across the models for the winning sign per position, keep only values that agree with the winner, and average the survivors. The result is a delta that preserves the consensus of the models instead of their average. Feed it back into an Add Difference on a base to get a usable model.

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

The input must be deltas, not raw models - the input label (delta) is not decoration. Feed checkpoints straight in and the node either errors or produces nonsense. And remember the output is still a delta: add it back to a base model, or you've built a difference vector that goes nowhere. If you want the newer options - geometric median, model-stock rescaling - Ties Sum Extended adds them, and Ties Sum With Dropout layers DARE-style dropout on top. merge_checkpointing works like everywhere else in the pack: fp16 CPU caching for stable branches, don't stack with cache units.

Categorymecha

Inputs (4)

NameTypeDefaultDescription
models (delta)optMECHA_RECIPE_LIST
k (1.0)optMECHA_RECIPE1
vote_sgn (False)optMECHA_RECIPEfalse
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