Nodes/Model Utility Toolkit/Merge LoRAs (3 Models)
ComfyUI Node

Merge LoRAs (3 Models)

Three LoRA files through the generic weighted-merge engine

By silveroxides·Created about a year ago·Updated 7 days ago· 16
Merge LoRAs (3 Models)
    • output_filename
    • documentation
    execution_mode
    model_a
    model_b
    model_c
    calc_mode
    mismatch_modeskip
    alignment_modepad/crop
    alpha0.50
    beta0.50
    gamma0.50
    delta2.00
    epsilon0.01
    zeta0.00
    seed0
    output_filenamemerged_3_lora
    save_dtype
    process_device
    exclude_patterns
    discard_patterns
    glob_patternsfalse
    lazy_loadtrue
    force_clear_cachetrue
    override_dtypefalse
    include_1d_diffsfalse

    LoRATwoMerger with a third slot. Same caveat applies here even more than there: this pack has two separate systems for combining LoRAs, and this one is the generic one - the same weighted-merge engine that powers CheckpointThreeMerger and ModelThreeMerger, just pointed at three LoRA files instead. It treats each LoRA's tensors as arbitrary weights to blend, without any rank-aware logic. If you want to actually stack several trained adapters cleanly - reconciling different ranks and naming conventions on purpose - this pack's LoRAMultiMerge node (up to eight LoRAs, with an explicit concatenate-vs-weighted-sum choice) is the more purpose-built tool. Reach for this one when you specifically want three LoRAs blended with the same math you'd use to blend three checkpoints.

    How it works

    model_a, model_b, model_c are your three source LoRAs. calc_mode picks the merge algorithm (option list not documented in the schema - check the dropdown on your install). The six weight knobs follow this pack's three-input pattern: alpha, beta, gamma default to 0.5 each (one knob per source), delta to 2, epsilon to 0.01, zeta to 0 - identical to CheckpointThreeMerger and ModelThreeMerger. None carry tooltips, so treat the defaults as your best clue until you know what a particular calc_mode does with them.

    mismatch_mode (default skip) and alignment_mode (default pad/crop) are doing real work here - three LoRAs from three different training runs very plausibly have three different ranks and three different naming schemes, and this is what keeps the merge from erroring out on the first shape mismatch it hits. exclude_patterns/discard_patterns (regex, glob with glob_patterns on) let you scope specific layers out. lazy_load and force_clear_cache handle memory (less of a concern here than with three full checkpoints - LoRAs are small), save_dtype/override_dtype control output precision, process_device picks CPU or GPU, and seed covers whichever calc_mode involves randomness. Output is output_filename (default merged_3_lora) and a documentation string.

    Installing it

    ComfyUI Manager: search Model Utility Toolkit, install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-ModelUtils
    

    Restart ComfyUI. No downloads needed beyond the LoRA files themselves.

    Where people get burned

    Three LoRAs averaged generically is a rougher operation than it sounds. Rank mismatches, different training conventions, different base architectures - any one of these across your three sources means the merge is reconciling shape differences (via mismatch_mode/alignment_mode) rather than genuinely combining trained knowledge. The result can load and run and still look worse than any one of the three sources at full strength, because you've diluted three low-rank approximations into one without the rank-aware reconstruction that LoRAMultiMerge's weighted_sum mode does on purpose. If that's what you're actually after - combining several character or style LoRAs into a single portable file - try that node first and come back to this one if you specifically need the generic engine's flexibility (arbitrary calc_mode, exclude/discard patterns, precision control) that LoRAMultiMerge doesn't expose.

    Architecture mismatch remains absolute regardless of node: a LoRA trained for one base model contributes nothing useful when merged into a LoRA stack for a different one.

    CategoryModelUtils/Merging

    Inputs (24)

    NameTypeDefaultDescription
    execution_modeCOMBOMERGE writes the selected result; DOCUMENTATION ONLY returns the operation reference without loading model files.
    model_aCOMBOPrimary LoRA; anchors metadata, tensor shapes, and values preserved by exclusions or skip handling.
    model_bCOMBOSecond LoRA contributing to the selected calculation mode.
    model_cCOMBOThird LoRA contributing to the selected three-model calculation mode.
    calc_modeCOMBOThree-model operation to apply per comparable tensor; DOCUMENTATION ONLY shows its formula and coefficient meanings.
    mismatch_modeCOMBOskipHandle missing or incompatible tensors: preserve Model A, substitute zeros where supported, or abort with an error.
    alignment_modeCOMBOpad/cropResolve compatible shape differences by zero-padding/cropping or by interpolating Model B and Model C to Model A shape.
    alphaFLOAT0.50-10–10Mode-specific coefficient; use DOCUMENTATION ONLY for its exact role in the selected calculation mode.
    betaFLOAT0.50-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
    gammaFLOAT0.50-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
    deltaFLOAT2.00-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
    epsilonFLOAT0.01-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
    zetaFLOAT0.00-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
    seedINT00–18446744073709550000Random seed used only by calculation modes with stochastic behavior.
    output_filenameSTRINGmerged_3_loraOutput filename without extension, written under the matching ComfyUI model directory.
    save_dtypeCOMBOOutput tensor dtype; when Override Dtype is disabled, source tensors with higher precision remain at that precision.
    process_deviceCOMBODevice used for per-tensor merge arithmetic; CUDA out-of-memory retries the affected tensor on CPU.
    exclude_patternsSTRINGNewline-separated regex or glob patterns for tensors excluded from merging and preserved from Model A.
    discard_patternsSTRINGNewline-separated regex or glob patterns for tensors omitted entirely from the output.
    glob_patternsBOOLEANfalseWhen True, exclude/discard patterns use glob syntax (* = any sequence, dots are literal). When False (default), patterns are Python regex matched as substrings.
    lazy_loadBOOLEANtrueLow memory mode: load tensors from disk on demand
    force_clear_cacheBOOLEANtrueClear CUDA cache after each layer
    override_dtypeBOOLEANfalseForce merged non-1D tensors to save_dtype. Enabled 1D direct diffs remain FP32.
    include_1d_diffsBOOLEANfalseMerge 1D tensors. When disabled, preserve Model A's 1D tensors unchanged.

    Outputs (2)

    NameTypeDescription
    output_filename*
    documentationSTRING