CFG Guider: Positive, Negative and Null
Keep your negative prompt out of the unconditional slot
- model
- positive
- negative
- null
- GUIDER
ComfyUI's CFGGuider makes a quiet simplification: it is your negative prompt that stands in for the unconditional prediction. That's fine when your negative is empty and less fine when it isn't, because the negative is then doing two jobs at once - being the thing you steer away from, and being the baseline the prompt is measured against.
This node keeps them separate. Three conditioning inputs: positive, negative, and a genuine empty prompt as null. Then it lets you pick how the negative enters the arithmetic.
The rules
- perp_neg (default) -
u + w ((c - u) - s·perp), whereperpis the part of the negative direction(n - u)that is perpendicular to the positive direction(c - u). Only the component of the negative that doesn't fight your prompt gets applied. This is Armandpour et al. 2023, and the pack notes its per-sample projection is not the same as ComfyUI's built-in PerpNegGuider, which sums over the whole batch. - separate_negative -
u + w (c - u) - s (n - u): composable negation (Liu et al. 2022). The negative is its own signed term, both prompts measured from the empty prompt. - negative_as_null -
n + w (c - n): classic CFG, the negative standing in for the unconditional. "For reference", and bit-identical to ComfyUI's own CFGGuider - which makes it the perfect wiring check.
s is negative_scale.
Inputs and output
model,positive,negative,null. Thenullinput is "The empty prompt: the true unconditional" - wire an emptyCLIPTextEncodethere. This is the whole point of the node, and leaving it unwired or feeding the negative into it puts you back where you started.cfg- default 7. This node's own guidance scale; KSampler's cfg is not consulted.rule- defaultperp_neg.negative_scale- default 1, range 0 to 100, step 0.01. How much of the negative direction to apply. 0 disables the negative entirely; higher values push harder.space- options are the three concrete spaces, defaulting todenoised (x0), with a tooltip noting that perp_neg's projection depends on the space - and that ComfyUI's built-in uses denoised. So the default isn't arbitrary; it's chosen to match what you'd get from the stock node.
Output: a GUIDER, which goes into SamplerCustomAdvanced. Not KSampler.
Cost and behaviour
Three predictions per step: positive, negative, empty. That's one more forward pass than plain CFG, so budget roughly 1.5× the sampling time. negative_as_null is the exception at two, since the empty prompt isn't used.
The model's other CFG Megapack stages still apply - this guider only takes over the combine step, so a schedule or a weak branch installed on the model keeps running.
And once again, if you were expecting a negative prompt to do anything at CFG 1: it won't. At cfg 1 ComfyUI skips the unconditional pass entirely, which is why guidance-distilled models - Z-Image Turbo, the Klein distills - ignore negatives by design, not by bug.
Install
Manager → search CFG Megapack → install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack
No dependencies and no model downloads. The requirement is a recent ComfyUI - this is built on comfy_api.latest and the README reports testing on 0.38.0 with torch 2.11 - so if the pack doesn't import on an older build, that's expected rather than mysterious.
Where people get burned
Wiring it into a KSampler. No guider input, no effect. This node family only works in SamplerCustomAdvanced - check that you're in a Custom Sampler workflow before debugging anything else.
Forgetting the null prompt. The most common mistake, and it fails quietly: a text-filled null just gives you a slightly wrong image rather than an error.
Turning negative_scale up to fix a weak negative. With perp_neg, strength isn't the axis you want; the point is that the perpendicular part is the only part applied. If your negative isn't landing, the prompt is usually the problem - the forty-keyword boilerplate that SD 1.5 handed down rarely survives a fixed-seed A/B, and naming the specific defect you can see works better.
Expecting it to be fast. Three conditioning passes per step. On a 50-step render you'll feel it.
Confusing it with the negative-prompt paper nodes. The pack ships six guiders of this kind - Perp-Neg, Composable NOT, Signed guidance, ContrastiveCFG, Safe Latent Diffusion, and Windowed negative prompt - each one paper-faithful. This node is the manual one with the rule menu; use one at a time, and only the one wired into the sampler runs.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| null | CONDITIONING | The empty prompt: the true unconditional. | |
| cfg | FLOAT | 7.00–100 | — |
| rule | COMBO | perp_neg | 3 options: perp_neg, separate_negative, negative_as_null |
| negative_scale | FLOAT | 1.000–100 | — |
| space | COMBO | denoised (x0) | perp_neg's projection depends on the space (ComfyUI's built-in uses denoised). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| GUIDER | GUIDER | — |