ComfyUI Node

PM SCE (Mergekit)

Merge by variance, not by averaging — the adaptive method

By larsupb·Created 2 years ago·Updated 30 days ago· 75
PM SCE (Mergekit)
    • MergeMethod
    select_topk0.50
    average_weightsfalse

    SCE stands for Select, Calculate, Erase - a three-stage merge method that decides, per parameter matrix, how much each LoRA actually matters, instead of trusting fixed weights. It's the pack's take on the question "which LoRA owns this matrix?" When you merge a character LoRA and a style LoRA, some layers are dominated by one and some by the other; SCE tries to let each matrix be claimed by whichever LoRA is genuinely changing it.

    You reach for it when your LoRAs contribute to different parts of the network and a flat weighted sum flattens that structure. It needs 2+ LoRAs plus a base model.

    How it works

    Three stages, per matrix:

    1. Select - variance-based masking. Parameters with low variance across the different LoRAs' task vectors are candidates to be zeroed; select_topk sets the fraction of highest-variance elements you keep.
    2. Calculate - matrix-level weights are computed for each LoRA's contribution, so each matrix gets its own weighting rather than a global one.
    3. Erase - TIES-style sign consensus removes conflicting changes.

    The result is a merge that weights each matrix adaptively, favoring high-variance, consistently-signed changes.

    The inputs that matter

    • select_topk - fraction of the highest-variance elements to retain (default 0.1, range 0–1). Lower = more selective and weaker; the tooltip's guidance is that 1.0 keeps everything (strongest). For a first run, the middle of the range is a safer bet than the default if the merge comes out faint.

    Output is a MergeMethod config for PM LoRA Merger.

    Installing

    Ships in the LoRA Power-Merger pack. ComfyUI Manager (search "LoRA Power-Merger") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/larsupb/LoRA-Merger-ComfyUI
    cd LoRA-Merger-ComfyUI
    pip install -r requirements.txt
    

    Restart ComfyUI. Dependencies: PyTorch, lxml, mergekit - SCE runs on the mergekit path.

    Common issues

    SCE's signature failure mode is a merge that's too weak, because aggressive selection zeroes most of every matrix. If the output barely moves the image, raise select_topk before you try anything else. It's also a method that quietly assumes your LoRAs genuinely differ per-matrix - merging two near-identical LoRAs with SCE just produces noise, and plain PM Linear or PM TIES would serve you better. Ranks must match at the merger; reconcile with PM LoRA Stack Decompose (rSVD) first. And pair it with the Parameter Sweep Sampler sweeping select_topk if you want to find the sweet spot visually.

    CategoryLoRA PowerMerge/Task Arithmetic

    Inputs (2)

    NameTypeDefaultDescription
    select_topkFLOAT0.500–1Fraction of elements with the highest variance in the delta parameters to retain. 1.0 keeps everything (strongest); lower values merge more selectively (and weaker).
    average_weightsBOOLEANfalseOFF: additive SUM of the sign-agreeing, selected contributions, so per-LoRA strengths act as gains and stacked LoRAs keep full magnitude (matches ComfyUI's native LoRA stacking and the other merge nodes, the default). ON: SCE's normalized weighted AVERAGE, so strengths act as ratios and the result is a blend/interpolation (weaker magnitude). Turn ON only to blend LoRAs.

    Outputs (1)

    NameTypeDescription
    MergeMethodMergeMethod