Nodes/LoRA Power-Merger ComfyUI/PM NearSwap (Mergekit)
ComfyUI Node

PM NearSwap (Mergekit)

Pull in only the weights where two LoRAs already agree

By larsupb·Created 2 years ago·Updated 30 days ago· 75
PM NearSwap (Mergekit)
    • MergeMethod
    similarity_threshold0.0010
    average_weightsfalse

    Most merge methods combine two models everywhere, with more or less cleverness about how. NearSwap is different: it only blends the parameters that are already similar between the two models, and leaves the genuinely different ones alone. The idea is that if your LoRA and a reference agree on a weight, that agreement is probably real signal worth merging; where they disagree, the reference may be working against you - so don't touch it.

    It's a niche, opinionated method, and you'd reach for it when you want to selectively inherit behavior from a second LoRA without letting its conflicting parts in. Think: "I want the parts of B that agree with A, nothing else." It requires exactly two LoRAs, with one treated as the base.

    How it works

    For each parameter, NearSwap computes a blend weight based on how close the two values are:

    weight = (t / |base - secondary|).clamp(0, 1)
    result = weight * secondary + (1 - weight) * base
    

    The closer the two models are on a given parameter, the larger the weight and the more the result leans toward the secondary; the farther apart they are, the more the base wins. The t in that formula is your control knob - the node's similarity_threshold plays that role: it sets the scale for what counts as "close."

    The inputs that matter

    • similarity_threshold - the closeness threshold (default 0.001, range 0–1). This is the whole node. Lower thresholds mean only very similar parameters get swapped in (more conservative); higher thresholds let more of the secondary model through. Start at the default and raise it if the merge feels too weak, lower it if the secondary's differences are leaking in.

    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 - this method genuinely comes from mergekit.

    Common issues

    The counterintuitive part is that raising similarity_threshold doesn't necessarily make the merge "stronger" in the direction you expect - it makes it lean harder on the secondary model, which can introduce its conflicting changes too. If your result looks like a weird hybrid, back the threshold down. And because it's a two-model method with a base/secondary distinction, feeding it three LoRAs errors out by design. Ranks still need to match - reconcile through PM LoRA Stack Decompose (rSVD) first, as always.

    CategoryLoRA PowerMerge/Specialized Methods

    Inputs (2)

    NameTypeDefaultDescription
    similarity_thresholdFLOAT0.00100–1Similarity threshold for NearSwap merge.
    average_weightsBOOLEANfalseOFF: additive SUM, 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: normalized weighted AVERAGE, so strengths act as ratios and the result is a blend/interpolation (weaker magnitude). Note: strengths control MAGNITUDE only, not the interpolation position.

    Outputs (1)

    NameTypeDescription
    MergeMethodMergeMethod