Nodes/ComfyUI-DonutNodes/Donut Txtfusion RMS Guard (model-wide)
ComfyUI Node

Donut Txtfusion RMS Guard (model-wide)

An experimental leash on Krea 2's text-fusion blocks

By DonutsDelivery·Created about a year ago·Updated about 8 hours ago· 26
Donut Txtfusion RMS Guard (model-wide)
  • model
  • MODEL
enabledfalse

What it is, and who it's for

A MODEL-in, MODEL-out patch with exactly two widgets and one of them is a switch. It normalizes the internal txtfusion contributions - attention and MLP - plus the projector output, of a Krea 2 model, against an independently reconstructed reference of the same model taken before adapters were applied.

You'd only reach for this if you're stacking things on Krea 2. Specifically: Krea 2's open checkpoint went through an alignment pass the hosted model never got, and the community's fix for its flattened expressions and dropped prompt clauses came in two flavours - tiny weight files that edit vectors inside diffusion_model.txtfusion.projector, and properly trained "refusal reduction" LoRAs on the same text-fusion path. Stack a couple of those, add a merge and a style LoRA, and you're editing the scale of a module that was trained to sit at a specific magnitude. When that goes wrong, colors go weird, black levels drift, or the render falls apart in ways no prompt fixes. This node is the author's attempt to put a single bounded leash on that, instead of asking you to hand-tune.

The author labels it EXPERIMENT, defaults it to Off, and explicitly states it "does not guarantee removal of image artifacts." Believe that sentence.

How it works

The interesting part is where the reference comes from. When you enable it, the guard walks the effective model's merge recipe, keeps the genuine checkpoint/merge entries, and discards the added adapters - LoRA, LoKr, DoRA and friends - then rebuilds that clean version on the CPU as an independent copy, including quantisation scales and block scales so live requantization can't quietly mutate it. That copy gets its own ModelPatcher registered as an additional model.

Then it installs forward hooks on the txtfusion attention, MLP and projector components. On each prediction it compares the guarded component's output against the reference's, computes the RMS ratio, and clamps the correction into a 0.25x–4x gain band. It wraps OUTER_SAMPLE and hooks pre-run/cleanup/detach, so the reference is released with the run.

Two things follow, and both matter. The enabled tooltip is precise: it applies to all callers of that model - base, upscale, detailer, with or without NAG, including NAG at alpha 0. You cannot scope it to one sampler. And the guard is not a conditioning fix: rebalance conditioning is untouched, so if your problem is the safety filter's bias in the conditioning path, this is the wrong tool.

The inputs

  • model (MODEL) - a Krea 2 model, merged or LoRA'd, from wherever you load it.
  • enabled (BOOLEAN, default false) - the whole node. Off introduces no reference allocation and no callbacks, so leaving it in the graph costs nothing.

Output: MODEL. There is no strength, no gain cap, no per-block toggle. The 4x ceiling and the 0.25x floor are compiled in. Put it in the model line after your merges and LoRA loaders.

The pack's Fusion Control node carries the same feature as a txtfusion_rms_guard boolean, for people already running that node. Wiring both is redundant rather than harmful - an identical guard on the same model is a no-op.

Installing it

Nothing extra to download: no weights, no dependency beyond the pack itself.

cd ComfyUI/custom_nodes
git clone https://github.com/DonutsDelivery/ComfyUI-DonutNodes.git donutnodes
cd donutnodes
python -m pip install -r requirements.txt

Or in ComfyUI Manager, search DonutNodes. Then restart and refresh. The pack's requirements are floors rather than pins (opencv-python-headless, scipy, matplotlib, psutil, tqdm, requests) and it warns against globally downgrading NumPy, since every pack on that interpreter shares it.

Where people get burned

  • Non-Krea-2 model. The guard looks for the text-fusion blocks and projector by name and refuses with "Txtfusion RMS guard needs Krea2 text-fusion blocks" / "Missing Krea2 txtfusion projector". It doesn't silently no-op, which is the right behaviour.
  • Reference capture order. The guard wants to snapshot the model before certain patches. It will refuse rather than guess, with a message about capturing the reference before unrecorded model injections. If you see it, your model line already has something on it the guard can't account for - capture earlier in the chain.
  • Memory and speed. An independent CPU copy of the reference tensors plus hooks on every txtfusion call is real overhead. On a 12B model, expect it. Turn it off unless you're chasing a specific problem.
  • It's a scale fix, not a quality knob. It constrains how far those components move, bounded to 4x. It cannot add detail, restore a refused subject, or repair a bad merge. If your images look wrong because of a bypass file, the guard may smooth the symptom; the actual fix is a better bypass or a cleaner merge.
  • A/B or don't bother. Same prompt, same seed, guard off then on, and look at black level, highlight rolloff and skin/background separation. If you can't see a difference, you didn't need it - and the author would agree with you.
Categorymodel/patches/Krea2

Inputs (2)

NameTypeDefaultDescription
modelMODEL
enabledBOOLEANfalseEXPERIMENT: normalize internal txtfusion attention/MLP contributions and the projector (bounded 0.25x-4x gains) against an independent pre-adapter reference of the effective model/merge. Applies to ALL callers of this model: base, upscale and detailer, with or without NAG (including alpha 0). Rebalance conditioning is not changed. Adds reference weights and computation. Default Off. Does not guarantee removal of image artifacts.

Outputs (1)

NameTypeDescription
MODELMODEL