Nodes/TechNodes/SDNext Merge
ComfyUI Node

SDNext Merge

SD.Next's checkpoint merger, natively in ComfyUI, with Re-Basin

By TechnoByteJS·Created 2 years ago·Updated 2 years ago· 14
SDNext Merge
  • optional_model_a
  • optional_clip_a
  • optional_model_b
  • optional_clip_b
  • optional_model_c
  • optional_clip_c
  • optional_mbw_layers_alpha
  • MODEL
  • CLIP
model_a
model_b
model_c
merge_mode
precision
weights_cliptrue
mem_device
work_device
threads4
mbw_preset_alphanone
alpha0.50
beta0.25
re_basinfalse
re_basin_iterations5

SD.Next - vladmandic's fork of the original A1111 WebUI - has a genuinely capable Models > Merge tab built on a Python merging library called meh. This node ports that whole engine into ComfyUI as a single node and bolts on Git Re-Basin support on top. If you've ever wanted proper checkpoint-merging tooling without leaving your ComfyUI graph, this is the flagship node in the pack - everything else here (the VAE merger, the MBW block-weight builders) either feeds this node or does the same job one level down.

How it works

model_a, model_b, and model_c are dropdowns of checkpoint files already sitting in your models folder - pick two (or three, for the difference-family modes) and merge. If you'd rather merge something that isn't a plain file on disk - a checkpoint you've already patched with a LoRA upstream, say - wire the optional_model_a / optional_clip_a (and _b, _c) inputs instead; they take MODEL/CLIP straight from another loader.

merge_mode gives you 13 options, one more than the pack's VAE Merge node (it adds train_difference). They group the same way: plain interpolation (weighted_sum, weighted_subtraction, tensor_sum, sum_twice, triple_sum), difference-based grafting (add_difference, train_difference, euclidean_add_difference, multiply_difference) for transplanting one model's changes onto another, and a newer batch (top_k_tensor_sum, similarity_add_difference, distribution_crossover, ties_add_difference) - that last name is a giveaway, TIES-style merging is published research from the LLM-merging world, repurposed here for diffusion checkpoints to cut down on interference when you're combining more than one delta. For a first merge, weighted_sum with alpha at 0.5 is a plain 50/50 blend; add_difference (needs model_c/clip_c wired as the shared ancestor) is the classic "graft B's changes onto A" move. beta only matters for the three-model modes.

Two features that make this more than a basic blender:

  • mbw_preset_alpha - 39 named block-weight presets (GRAD_V, GRAD_A, FLAT_25, WRAP08, and so on). Merge Block Weighted (MBW) is a real, community-established technique - it's been floating around A1111 as a dedicated extension since 2023, letting you apply a different blend weight to each block of the UNet instead of one flat number, because different blocks tend to carry different traits (composition versus fine detail). This dropdown ships the standard named presets so you don't have to hand-tune anything. Leave it at none for a flat global alpha. optional_mbw_layers_alpha goes further - wire in an MBW_LAYERS bundle from one of this pack's own MBW Layers nodes for full manual per-block control, which overrides the preset.
  • re_basin (off by default) plus re_basin_iterations (1–25, default 5) - Git Re-Basin permutes one model's internal weight ordering to line up with the other's before averaging, which cuts down on the "ghosting" you get from naively averaging two independently-trained models. It costs real compute per iteration, which is why it's opt-in.

The rest is engine-room control: precision (fp16 halves merge memory, original keeps whatever the inputs came in as), weights_clip (on by default - clamps the merged weights back toward the input range so you don't get exploding outliers), and mem_device/work_device (cuda/cpu) with threads (1–24, default 4) for where and how parallel the merge math runs.

Inputs and output

The required fields you'll actually touch first: model_a, model_b, merge_mode, alpha. Everything else is a knob you turn once you know you need it. Output is MODEL + CLIP - no VAE, so pair it with this pack's own VAE Merge node if you want the VAE merged too.

Installing it

ComfyUI Manager: search TechNodes, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/TechnoByteJS/ComfyUI-TechNodes --depth 1

No extra models, no heavy Python deps to chase down - it runs on checkpoints you already have.

Where people get burned

model_a/model_b sample as none in the dropdown - if you leave them there, nothing sensible happens; actually pick real checkpoints, or wire the optional_model_* inputs. Picking a difference-family mode without a third checkpoint wired in is the same trap as the VAE merger: the merge runs, it just runs wrong. Merging checkpoints from different base architectures (an SD 1.5 file into an SDXL merge) doesn't dilute gracefully - checkpoints are locked to their base architecture, and crossing that line produces garbage rather than a compromise. work_device: cuda needs enough VRAM to hold two or three full checkpoints at once during the merge; if you OOM, drop it to cpu and accept a slower merge instead of failing outright. And Re-Basin is genuinely slow - start at the default 5 iterations before cranking toward 25 on a big model.

CategoryTechNodes/merging

Inputs (21)

NameTypeDefaultDescription
model_aCOMBO1 options: none
model_bCOMBO1 options: none
model_cCOMBO1 options: none
merge_modeCOMBO13 options: weighted_sum, weighted_subtraction, tensor_sum, add_difference, train_difference, sum_twice, +7
precisionCOMBO2 options: fp16, original
weights_clipBOOLEANtrue
mem_deviceCOMBO2 options: cuda, cpu
work_deviceCOMBO2 options: cuda, cpu
threadsINT41–24
mbw_preset_alphaCOMBOnone39 options: none, GRAD_V, GRAD_A, FLAT_25, FLAT_75, WRAP08, +33
alphaFLOAT0.500–1
betaFLOAT0.250–1
re_basinBOOLEANfalse
re_basin_iterationsINT51–25
optional_model_aoptMODEL
optional_clip_aoptCLIP
optional_model_boptMODEL
optional_clip_boptCLIP
optional_model_coptMODEL
optional_clip_coptCLIP
optional_mbw_layers_alphaoptMBW_LAYERS

Outputs (2)

NameTypeDescription
MODELMODEL
CLIPCLIP