Pre CFG norm neg to pos
Pre CFG norm neg to pos
- model
- MODEL
If you've ever had a workflow where the negative prompt seems to be doing way more work than it should - everything comes out muted, shifted, or oddly "repelled" even at a sane CFG - the culprit is often a magnitude mismatch between the two predictions, not the words themselves. Pre CFG norm neg to pos fixes exactly that: it rescales the negative prediction to have the same length as the positive one, so the CFG formula compares like with like.
Every pre-CFG node in this pack hooks the same moment in ComfyUI's sampler: right after the model produces the conditioned and unconditioned noise predictions, and just before CFG combines them. That formula, for the record, is uncond + (cond - uncond) * scale. When the uncond prediction has a much larger magnitude than the cond one, the subtraction overshoots and the negative prompt drags the whole image toward itself. This node normalizes that away - it computes the norm of the uncond prediction, then multiplies it so its norm matches the cond prediction's norm, leaving the direction of the negative untouched.
It's a subtle, low-risk tweak, and honestly that's its selling point. There are no sliders to fight with: just model in and a patched model out. The only toggle is enabled, defaulting to true, so you can flip the node on and off to A/B test in the same graph. Wire it the same way you'd wire any model patch - right after your checkpoint/LoRA loader, before the sampler. Because these nodes chain, you can stack it with the automatic scale or gradient scaling nodes; since it only rescales norms it plays nicely rather than clobbering their per-channel work.
Where you'll actually feel it: chained setups where an earlier pre-CFG node has already rescaled or exponentiated the predictions, knocking the negative's magnitude out of whack. One pass of this node rebalances the pair so the CFG math isn't secretly being driven by whichever prediction is longer. It also quietly helps if you use a strong negative prompt and keep seeing washed-out results - try this before you start hacking the CFG scale down.
Install is the same for every node in this pack: ComfyUI Manager, search for pre_cfg_comfy_nodes_for_ComfyUI, install, restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI
Then restart ComfyUI. There are no model downloads and no extra Python dependencies - the whole pack is plain torch plus ComfyUI's own internals, so this installs in seconds.
One honest caveat: like every pre-CFG node here, it only does anything when there's actually a negative prediction to rescale. On guidance-distilled models running at CFG 1, ComfyUI skips the unconditional pass entirely, so there's nothing for the node to normalize - it passes the predictions through untouched. This is an SD 1.5/SDXL-family tool at heart, which is exactly what the author built and tested it on.
The name is a mouthful, but the job is small and safe: keep the negative honest relative to the positive. If your colors and contrast look like the negative prompt is winning, this is the first thing to reach for.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| enabled | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |