Nodes/ComfyUI-Krea2GatedLoRAMerge/Krea2 Gate-Aware LoRA Merge
ComfyUI Node

Krea2 Gate-Aware LoRA Merge

Merging Krea 2 LoRAs without breaking the gate layers

By BitPoet·Created 2 months ago·Updated 2 months ago· 0
Krea2 Gate-Aware LoRA Merge
    • info
    lora_a
    lora_b
    strength_a0.50
    strength_b0.50
    gate_strength0.50
    opposite_gate_deltaspick_strongest
    opposite_threshold0.05
    gate_rank32
    balance_modeoff
    gate_compressionattn_to_gate_only
    normal_compressionoff
    compression_devicecpu
    filename_prefixloras/krea2_merged

    Krea 2's LoRA scene exploded fast - a partner published 999 LoRAs within three days of release - so you'll quickly want two of them (a style, a character) in one file at fixed strengths, instead of a workflow that stacks two LoRALoader nodes forever. A file-level merge bakes them into a single .safetensors. The catch: Krea 2 is a diffusion transformer whose gate layers don't take kindly to naive merges. That's the whole point of Krea2GateAwareLoRAMerge.

    This is BitPoet's experimental, one-node, zero-download solution to that problem. The name is the honest part: it's gate-aware, meaning it treats the modulation gates differently from ordinary layers, and conservative, meaning when two LoRAs genuinely fight on a gate it would rather drop one than average garbage. It's a small, unproven node - ComfyUI's own merge nodes and tools like LoRA-Optimizer and Fizgig do adjacent jobs - so reach for it when gate conflicts are the thing biting you.

    What it actually does

    It's an offline merger, not an in-graph LoRA applier. Pick two LoRAs from your models/loras folder via dropdowns, set strengths, hit run, and it writes a new .safetensors into ComfyUI's output folder (more on that trap below). No model loaded, no API key, no text encoder. It's an output node whose only output is an info string: the saved path plus counts of normal layers, gate layers, gate conflicts, balanced layers, and layers found in only one LoRA.

    For ordinary layers, merging two LoRAs by rank-concatenating their A and B factors is exact: it reproduces strength_a * delta_a + strength_b * delta_b mathematically, because the delta is just the product of the two factors. No approximation, no drift. Gate layers are where it gets careful. In a DiT like Krea 2, each block has gate tensors - keys containing .attn.to_gate, .attn.gate, .ff.gate or .mlp.gate - that scale the whole block's contribution. If LoRA A nudges a gate one way and LoRA B nudges it the opposite way, a plain sum can cancel the adjustment or flip it, and since the gate multiplies everything the block does, the damage shows up as flat, off output that takes neither LoRA well.

    So for gates it measures the cosine similarity between the two reconstructed deltas, and when they point in opposite directions (below opposite_threshold, default 0.05) it applies the conflict rule instead of summing. Compression - when you don't want the merged file's rank to balloon - runs QR + SVD in low-rank factor space, never materializing the huge full gate matrix, and compression_device=cuda can speed that up if you have VRAM to spare.

    The inputs that matter

    Fourteen widgets is a lot, but you'll realistically touch a handful:

    • lora_a / lora_b - the two LoRAs, picked from your loras folder.
    • strength_a / strength_b - overall weights (default 0.5 each). These are baked in, so choose the values you'd normally load at.
    • gate_strength - the Krea-specific one: a separate multiplier for gate layers. If the merge looks over-modulated or flat, drop this before touching the main strengths.
    • opposite_gate_deltas - the conflict rule: keep the larger-norm gate delta (pick_strongest) or drop it (zero_out).
    • balance_mode - set to per_layer_norm when one LoRA was trained much hotter than the other and swamps it on matched layers.

    The rest - gate_compression (default attn_to_gate_only), normal_compression, gate_rank, compression_device - are quality/size trade-offs you can leave alone until file size annoys you. A sensible first run is defaults with your two LoRAs and strengths, then read the info string: a high gate_conflicts count means those two genuinely fight, and the output deserves a look.

    Install

    No model files, no heavy dependencies - just torch, safetensors, and ComfyUI internals you already have. Either way:

    cd ComfyUI/custom_nodes
    git clone https://github.com/BitPoet/ComfyUI-Krea2GatedLoRAMerge
    

    then restart. Or search "Krea2GatedLoRAMerge" in ComfyUI Manager and install from there. It shows up under model/merging as "Krea2 Gate-Aware LoRA Merge".

    Where people get burned

    The big one: the merged file is written to ComfyUI/output/loras/, not models/loras/ - same save machinery as Save Image - so it won't appear in your LoRA loader's dropdown until you move it over:

    # find it via the info string, then
    cp output/loras/krea2_merged_00001_.safetensors models/loras/
    

    Two more, both by design rather than bug. Compression truncates - set gate_rank or normal_compression low and you're deliberately discarding rank, so keep compression off if exactness beats file size. And the whole conflict heuristic is experimental: if output looks lifeless, try the other opposite_gate_deltas value or dial gate_strength down. Layers present in only one LoRA are copied through at that LoRA's strength, so merging a full character LoRA with a partial style LoRA works fine - it's just worth knowing what "only_a" in the stats means.

    It's early days and there are competing tools, but if merging Krea 2 LoRAs gives you flat, gate-broken output, this is the one built for it.

    Categorymodel/merging/krea2

    Inputs (13)

    NameTypeDefaultDescription
    lora_aCOMBO0 options:
    lora_bCOMBO0 options:
    strength_aFLOAT0.50-4–4
    strength_bFLOAT0.50-4–4
    gate_strengthFLOAT0.50-4–4
    opposite_gate_deltasCOMBOpick_strongest2 options: pick_strongest, zero_out
    opposite_thresholdFLOAT0.050–1
    gate_rankINT320–256
    balance_modeCOMBOoff2 options: off, per_layer_norm
    gate_compressionCOMBOattn_to_gate_only3 options: off, attn_to_gate_only, all_gates
    normal_compressionCOMBOoff2 options: off, max_input_rank
    compression_deviceCOMBOcpu2 options: cpu, cuda
    filename_prefixSTRINGloras/krea2_merged

    Outputs (1)

    NameTypeDescription
    infoSTRING