Nodes/ComfyUI-Krea2-MultiRef/Krea2 Model Patcher
ComfyUI Node

Krea2 Model Patcher

Krea2's reference latents do nothing without this patch

By molbal·Created about a month ago·Updated about a month ago· 2
Krea2 Model Patcher
  • model
  • model

Here's the trap that catches everyone first with this pack: you can wire reference images into Krea2ReferenceTextEncode, write a perfect edit prompt, run the sampler - and get output that looks like the reference images never existed. Because they didn't. Stock Krea2 has no idea what to do with the reference_latents key in your conditioning; it just ignores it. Krea2ModelPatcher is the node that closes that gap, and it's the one node in the pack you cannot skip.

What it actually does

Despite the name, it doesn't load an adapter file or apply any weights. It clones your Krea2 model and swaps out the DiT's forward pass so the sampler can consume reference latents. The input is a MODEL, the output is a patched MODEL you feed a KSampler - one-in, one-out, that's the entire schema.

The interesting part is what the replacement forward does. This is a faithful reimplementation of the training-time path molbal used to teach his edit adapter, which itself comes from Ostris's ai-toolkit implementation:

  • Reference latents are patchified into tokens and placed to the right of the target image on the 2D RoPE coordinate grid - same axis-0 index as the target, offset in x. That's the "RoPE coordinate fix": Ostris's original put references on a separate axis-0 row, and molbal moved them sideways to kill grid-pattern artifacts.
  • The noisy target and the text get the real timestep modulation; the clean references get modulated at timestep 0 (index_timestep_zero). Each transformer block then applies split AdaLN - one set of scales/shifts for the [:split] tokens, a second for the [split:] references.

The result is that the model can attend to up to four reference latents while obeying the text instruction, which is exactly how a reference edit is supposed to behave. Without the patch, those latents are just dead weight in the conditioning.

Two useful behaviors fall out of the implementation. If there are no references, the patched model falls back to the original forward - so it's safe to leave in the graph for plain text-to-image runs. And because the LoRA adapter weights are separate, you load them with a normal Load LoRA node and apply the patcher after; the forward swap and the LoRA patching don't fight each other.

Where people get burned

  • Using an unrelated checkpoint. The patch assumes a Krea2 single-stream DiT with a specific structure (_unpack_context, first, blocks, pe_embedder). On a Flux or SDXL model you'll get undefined behaviour or a crash, not an error message that explains itself.
  • Believing the repo docs. The node docs bundled in the repo still describe a patch_path string input for loading adapter weights. The shipped code doesn't have that input - there's no adapter file for this node to load. Don't go hunting for a missing safetensors path; the patch is the code.

Installing it

Same as the rest of the pack - no requirements.txt, just einops which ComfyUI already bundles.

cd ComfyUI/custom_nodes
git clone https://github.com/molbal/ComfyUI-Krea2-MultiRef

Restart ComfyUI, or use ComfyUI Manager → Custom Nodes Manager → search ComfyUI-Krea2-MultiRef → install. You still need the Krea2 model files yourself (checkpoint, Qwen3-VL text encoder, Qwen-Image VAE) and ComfyUI 0.25.0+.

Quick sanity check

If your edit isn't taking, confirm the patch is actually in the graph: wire the model into Krea2DiagnosticNode and check that the printed forward signature now accepts a ref_latents keyword. No refs, no edit - it really is that binary here. And keep expectations calibrated: the adapter behind this is an early training run, so treat it as a promising research build, not a finished product.

Categorykrea2/editing

Inputs (1)

NameTypeDefaultDescription
modelMODEL

Outputs (1)

NameTypeDescription
modelMODEL