ComfyUI Krea2 Merge
Exact mixed-rank merging of 2–4 Krea 2 PEFT/Diffusers or Kohya LoRAs, with FP16/BF16 output, FP32 alpha, adapter validation, safe loading, and protected saving.
Nodes (4)
Preview every Krea 2 LoRA at strength before you merge it
The LoRA loader that secretly hands you a raw state dict
Merge 2–4 Krea 2 LoRAs without loading the base model — even when the ranks don't match
Save your merged Krea 2 LoRA without nuking the file you already had
ComfyUI Krea2 Merge
<p align="center"> <img src="assets/icon.png" alt="ComfyUI Krea2 Merge icon" width="200"> </p>ComfyUI Krea2 Merge is a standalone set of nodes for exactly combining two to
four Krea 2 LoRAs without loading or modifying the base model. It supports the
PEFT/Diffusers lora_A + lora_B keys used by Krea 2 LoRAs, while retaining
support for Kohya lora_down + lora_up checkpoints.
This fork uses its own package name, extension name, node IDs, category, and
output folder. It can therefore be installed alongside the original
comfyui-merge extension without replacing its nodes.
Features
- Merge two to four Krea 2 LoRAs without loading a base model.
- Support PEFT/Diffusers
lora_A+lora_Bstate dictionaries. - Retain Kohya
lora_down+lora_upcompatibility. - Infer missing alpha values from the LoRA rank.
- Handle negative merge weights correctly for both
lora_Bandlora_up. - Exactly merge LoRAs with equal or different ranks without unwanted cross terms.
- Optionally cap the output rank with
svd_truncate, an optimal SVD truncation that reports its approximation error. - Enter positive or negative weights from
-4.0to4.0. - Report unsupported files and incompatible tensor shapes clearly.
- Load
.safetensors,.sft, and supported PyTorch checkpoints through ComfyUI's safe loader. - Save only inside
ComfyUI/models/loras/krea2-merged-loras, including subfolders. - Keep alpha in float32 even when the factor tensors use FP16 or BF16.
- Keep merge results independent of input order for equal weights.
Installation
-
Download or clone this repository into:
ComfyUI/custom_nodes/comfyui-krea2-merge -
Restart ComfyUI.
The extension requires PyTorch (provided by ComfyUI). The safetensors
package is required for loading and saving .safetensors files and is included
in normal ComfyUI installations.
Nodes
All nodes appear under Krea2 Merge / LoRA:
- Krea2 Merge • Load LoRA — loads a LoRA as a state dictionary.
- Krea2 Merge • Merge LoRAs — combines two to four LoRAs.
- Krea2 Merge • Save LoRA — saves the merged state dictionary.
- Krea2 Merge • Apply LoRA — loads and applies a LoRA to a connected model.
The internal node IDs are prefixed with Krea2Merge_, so workflows do not
collide with the original extension.
Basic workflow
- Add two Krea2 Merge • Load LoRA nodes and select your Krea 2 LoRAs.
- Connect them to Krea2 Merge • Merge LoRAs.
- Set
weight1andweight2. Optional third and fourth inputs useweight3andweight4. - Keep the default
exact_concatfor a mathematically exact weighted merge. Choosesvd_truncateinstead when you want a smaller file: it limits every module totarget_rank(see the compatibility notes).legacy_linearremains available only for compatibility with the original approximate factor-space behavior. - Select the output precision.
fp16is the practical default; usebf16if that matches your Krea 2 setup. - Connect Krea2 Merge • Save LoRA and choose a filename ending in
.safetensorsor.sft, optionally inside a subfolder such ascharacters/my_merge.safetensors. - Set
allow_overwritetoyeswhen repeated runs should replace the same output file. Keep it onnoto protect an existing merge.
Since version 1.2.1, output paths must stay inside krea2-merged-loras.
Absolute paths, .., and symlinks leading outside that folder are rejected.
If an older workflow uses an absolute output path, replace it with a filename
or relative subfolder. Supported output extensions are .safetensors, .sft,
.pt, .pth, .ckpt, and .bin.
On Windows, overwrite first moves the previous output to a temporary backup. If the new save fails, the original file is restored automatically. If Windows has the destination open or memory-mapped, use another filename or restart ComfyUI.
An example is included at workflow-examples/krea2-lora-merger.json.
The example includes Show Text from ComfyUI-Custom-Scripts to display the saved path. The Save node is also registered as an output node, so saving still works when Show Text is removed from a custom workflow.
Compatibility notes
exact_concatis the default. It concatenates complete A/B or down/up pairs, avoiding the cross terms produced when factors are added separately. It also supports different ranks: a rank-4 plus rank-16 module becomes rank 20.- Concatenation increases the output rank. Combining two rank-32 LoRAs produces rank 64; four produce rank 128. This increases file size and the temporary work needed while ComfyUI applies the LoRA.
svd_truncatefirst composes the LoRAs exactly likeexact_concat, then limits each module to at mosttarget_rank(default 32, only used by this mode). It keeps the best possible rank-target_rankapproximation of the merged weight delta (an optimal SVD truncation), so the output rank no longer grows with the number of inputs. Modules whose combined rank is already withintarget_rankstay exact. The result is deterministic, and the console reports the relative error of the truncated modules. The error is the share of the merged delta that lies beyondtarget_rank: it is small for LoRAs with a decaying spectrum and large for LoRAs whose rank is fully used, so pick atarget_rankclose to the summed input ranks when fidelity matters. Only linear and 1x1-up (LoCon-style) modules are supported; useexact_concatotherwise.legacy_linearpreserves old saved workflows and factor-space results. It is approximate, introduces cross terms, and requires matching shapes and ranks.exact_concatandsvd_truncateapply weights directly and ignoreforce_same_strength. For an even blend, start withweight1 = 0.5andweight2 = 0.5.- All modes operate only on the LoRA files; none changes or saves the Krea 2 base model.
- When a PEFT checkpoint has no embedded alpha tensors, the extension uses
alpha = rank(unit scaling). This is a fallback assumption: the original training alpha cannot be recovered from the factors alone. Files that rely on a separate non-default training alpha need that scaling supplied first. - Alpha is always saved in float32.
save_dtypecontrols the factor tensors; it does not reduce alpha precision. - DoRA, LoCon
lora_mid, LoHa/LoKr,diff/diff_b, factor biases, and other unrecognized adapter keys are rejected in both modes instead of being silently omitted or merged incorrectly. - Inputs should use the same base model and module naming convention. A warning appears when two inputs have no shared module names; separate target layers can be valid, but differently named aliases for the same layer are not converted or combined. Matching shapes alone do not establish compatibility.
- A missing LoRA filename in a saved workflow is retained so ComfyUI can report the missing file. Select its replacement explicitly in the Load or Apply node.
- A connected third or fourth LoRA with a zero weight is ignored with a clear console warning.
Attribution
This project is derived from LingSss9/comfyui-merge and retains its MIT license. Krea 2 support, separate node IDs, validation, tests, and the release branding were added in this fork.
Krea 2 and its model names belong to their respective owners. This community extension is not an official Krea product.