ComfyUI Node

Pre CFG uncond zero

Pre CFG uncond zero

By Extraltodeus·Created 2 years ago·Updated about a year ago· 66
Pre CFG uncond zero
  • model
  • MODEL
scale0.75
start_at_sigma100.00
end_at_sigma1.00
scaling_methodaverage_of_all_channels

Here's a problem nobody warns you about: if you stop generating the negative prediction partway through sampling - the Support empty uncond speed trick, or a conditioning that cuts out early - CFG suddenly has nothing to subtract against, and your image goes black or behaves badly. Support empty uncond fixes the arithmetic in that case. Pre CFG uncond zero takes a different, more aggressive route: instead of fixing the math, it synthesizes a negative prediction from the positive one so CFG always has both inputs it needs.

This is the pre-CFG version of the "uncond zero" idea the author developed in their separate Uncond-Zero project. When the node's patch runs and finds an empty uncond slot (while sigma is within your active range), it builds a stand-in negative out of the positive prediction itself. It measures the positive prediction's per-channel value range, computes a scale from it, and applies that scaling to shape the substitute. The scale input (default 0.75) is the master knob for how strong that synthesized negative is, and scaling_method - individual, all_as_one, average_of_all_channels, smallest_of_all_channels, biggest_of_all_channels - decides how the per-channel scaling is applied, mirroring the same enum used by Pre CFG automatic scale.

The start_at_sigma (default 100) and end_at_sigma (default 1) pair gates when the node bothers doing any of this. Outside that sigma window it passes the predictions through untouched, which is how you confine the effect to the part of sampling where the negative is genuinely absent.

So when do you reach for this instead of Support empty uncond? If you want the negative pass to stop being computed for a speed win, Support empty uncond is the cleaner fit - it's designed exactly for that and the README recommends it. Pre CFG uncond zero is more of a fallback for setups where the uncond simply goes missing (a conditioning that ended, an empty negative) and you'd rather CFG keep running on a synthesized negative than break the math. It's the "keep the pipeline alive" option, and it doubles as a flavor control - the synthesized negative changes how CFG steers, so it can read as a mild style shift on its own.

Wire it like any model patch: model in, patched model out, right after your loader and before the sampler. Install is the pack standard:

cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/pre_cfg_comfy_nodes_for_ComfyUI

or via ComfyUI Manager searching pre_cfg_comfy_nodes_for_ComfyUI, then restart. No models, no extra dependencies.

One caveat to keep in your back pocket: a synthesized negative is not a real negative prompt. It rescues the math and nudges the style, but it won't steer away from things you write in your negative field - if you're cutting the negative pass for speed, you've already decided the last third of generation doesn't need your negative words anyway.

Categorymodel_patches/Pre CFG

Inputs (5)

NameTypeDefaultDescription
modelMODEL
scaleFLOAT0.750–10
start_at_sigmaFLOAT100.000–1000
end_at_sigmaFLOAT1.000–1000
scaling_methodCOMBOaverage_of_all_channels5 options: individual, all_as_one, average_of_all_channels, smallest_of_all_channels, biggest_of_all_channels

Outputs (1)

NameTypeDescription
MODELMODEL