Nodes/Ray's Orenchi/🧰 Ray's Model Tools: Model Merge
ComfyUI Node

🧰 Ray's Model Tools: Model Merge

Merge compatible models connected to model_a/model_b or data_a/data_b with Ray's nine strategies. Task-vector strategies require a base_model or base_data connection. Block weights accepts a connected JSON string. Inference outputs load automatically when used. merge_name combines the sources, method, ratio, precision, settings fingerprint and time for use with Save Model.

By MutantSparrowΒ·Created 4 months agoΒ·Updated 3 days agoΒ· 1
🧰 Ray's Model Tools: Model Merge
  • model_a
  • model_b
  • base_model
  • clip_a
  • clip_b
  • base_clip
  • vae_a
  • data_a
  • data_b
  • base_data
  • model
  • clip
  • vae
  • model_data
  • metadata
  • report
  • merge_name
β—„strategyLERPβ–Ί
β—„weight_a0.50β–Ί
β—„weight_formatbf16β–Ί
β—„componentsdiffusionβ–Ί
β—„mismatchforbidβ–Ί
β—„seed0β–Ί
β—„density0.50β–Ί
β—„lambda1.00β–Ί
β—„top_trim0.10β–Ί
β—„bottom_trim0.01β–Ί
β—„path_aβ–Ί
β—„path_bβ–Ί
β—„base_pathβ–Ί
β—„block_weights{}β–Ί
CategoryπŸ‘‘ Ray/🧰 Model Tools

Inputs (24)

NameTypeDefaultDescription
strategyCOMBOLERPMerge method. LERP is a fast weighted average; SLERP blends along layer angles. TIES, DARE, DELLA and Breadcrumbs merge changes from a compatible base model. Open node Help for each method's strengths and limitations.
weight_aFLOAT0.500–1Contribution of A; B uses 1 minus this value. For LERP/SLERP, 1 selects A and 0 selects B. Other methods apply this ratio to pruned changes from the base. Matching block_weights entries override it.
weight_formatCOMBObf16Storage format for merged floating-point weights. Quantized formats target eligible Linear layers; other merged layers stay bf16. Higher precision needs more RAM and disk space and cannot restore precision already lost in a source.
componentsCOMBOdiffusionComponents whose matching tensors are merged: diffusion, diffusion plus text, text encoder only, or all. Unselected components pass through from A unchanged.
mismatchCOMBOforbidForbid: require matching names and shapes. Intersect: merge shared tensors of matching shape. Pad/Trim: resize shared tensors to the larger/smaller shape. Intersect, Pad and Trim preserve tensors present in only one input unchanged.
seedINT00–18446744073709550000Random pruning seed for DARE and DELLA. Each tensor derives its own seed from this value and its name. Keep the seed and inputs fixed for repeatable results.
densityFLOAT0.500–1Retention setting for TIES, DARE and DELLA. TIES keeps the largest changes; DARE uses this keep probability; DELLA adjusts it by change magnitude. Lower values prune more changes and can lose detail or amplify retained updates.
lambdaFLOAT1.000–5DELLA importance exponent. Higher values favor larger changes from the base more strongly. Zero gives uniform keep probabilities; use with density and seed.
top_trimFLOAT0.100–0.99Breadcrumbs fraction of the largest absolute changes to discard as outliers, per tensor. 0.10 means 10%. Top trim plus Bottom trim must be less than 1.
bottom_trimFLOAT0.010–0.99Breadcrumbs fraction of the smallest absolute changes to discard, per tensor. 0.01 means 1%. Top trim plus Bottom trim must be less than 1; excessive trimming can remove learned details.
model_aoptMODELLive model A, including its active patches. Takes priority over data_a and legacy path_a. Effective weights are read one tensor at a time without a temporary source checkpoint.
model_boptMODELLive model B, including its active patches. Takes priority over data_b and legacy path_b.
base_modeloptMODELCompatible original training base for task-vector methods. Required for TIES, DARE, DELLA and Breadcrumbs; unused by LERP and SLERP. Takes priority over base_data.
clip_aoptCLIPText encoder belonging to live model A. Include it when merging text-encoder components or retaining a full checkpoint.
clip_boptCLIPText encoder belonging to live model B when merging text-encoder components.
base_clipoptCLIPText encoder belonging to the live base model when merging text-encoder changes.
vae_aoptVAEVAE to include with live model A. It passes through from A unless the selected components include it.
data_aoptRAY_MODEL_DATAModel data for A, usually from Load Model As. Used when model_a is disconnected; reads file or RAM weights without initializing an inference model.
data_boptRAY_MODEL_DATAModel data for B, usually from Load Model As. Used when model_b is disconnected.
base_dataoptRAY_MODEL_DATAModel data for the compatible base. Used by task-vector methods when base_model is disconnected; not needed for LERP or SLERP.
path_aoptSTRINGLegacy model A path retained for saved workflows. Connect Load Model As to data_a for normal file selection; model_a and data_a take priority.
path_boptSTRINGLegacy model B path retained for saved workflows. Connect Load Model As to data_b; model_b and data_b take priority.
base_pathoptSTRINGLegacy base-model path retained for saved workflows. Connect a compatible base to base_data or base_model instead.
block_weightsoptSTRING{}Connect a STRING containing a JSON map of tensor prefixes to A ratios between 0 and 1, for example {"diffusion_model.blocks.0.": 0.7}. The longest prefix wins. Leave disconnected for the global Weight A ratio.

Outputs (7)

NameTypeDescription
modelMODELNative ComfyUI diffusion model. Inference components are initialized when this output is used; data-only workflows can use model_data instead.
clipCLIPNative text encoder when available in the source and enabled by the selected loading/component options; otherwise absent.
vaeVAENative VAE when available in the source and enabled by the selected loading/component options; otherwise absent.
model_dataRAY_MODEL_DATAModel Tools data handle for a source file or in-memory result. Connect it directly to compatible merge, conversion, inspection, or save nodes without an extra inference load.
metadataRAY_MODEL_METADATAStructured metadata for the source or result, including operation information where applicable.
reportSTRINGReadable inspection or operation report, including compatibility, format, processing, and saved-result information relevant to this operation.
merge_nameSTRINGSuggested merge filename containing resolved source names, strategy, settings, and execution datetime. Connect to Save Model's filename_prefix.