Windowed negative prompt (Ban et al. 2024)
Your negative prompt is arriving too early
- model
- positive
- negative
- null
- GUIDER
You write plants into the negative box to clean up a background, and the whole composition collapses. That's the problem this node solves. A negative prompt is just a different conditioning for the unconditional pass: the sampler steers away from what you name, from step one. Name something that's part of the early layout and you don't just remove it, you change where everything goes. Ban et al. (ECCV 2024) measured when that steering starts to matter - nouns from roughly step 5 of 30, adjectives from step 10 - so apply the negative there.
Windowed negative prompt (Ban et al. 2024) is one of the CFG Megapack's 50 paper nodes - one node per published guidance method, shipped with that paper's own defaults - in the negative prompts line beside Perp-Neg, Composable NOT and Safe Latent Diffusion.
What it actually does
Outside the window the node runs ordinary CFG with the empty prompt as the unconditional: null + cfg (positive - null). Inside the window - from start to end, expressed as a share of the run - the negative prompt is swapped in for the empty one: negative + cfg (positive - negative). Then it goes back to the empty prompt.
The consequences are the interesting part. Nothing is deleted; the negative simply isn't consulted while the layout is being decided, so you keep the composition the run would have had without a negative at all, and the thing you dislike is removed in the middle of the run, while there's still detail to rework. The pack's own showcase describes it exactly: the plants go, the layout of the run without a negative stays.
Wiring it up (this trips people up)
This is a guider, not a model patch. Its output is a GUIDER, and the only place that goes is the guider input on SamplerCustomAdvanced. On the classic KSampler path there's nothing to plug it into - which is also why the node's own cfg widget is the entire guidance scale: custom-sampler graphs have no CFG box, the guider carries it.
You need three text conditionings, and they are genuinely different things:
- positive - your prompt, as usual.
- negative - the thing you want gone.
- null - an empty prompt, the author's "true unconditional." To delay the negative you have to know what "no negative" means, which plain ComfyUI CFG blurs by putting the negative in the unconditional slot. Wire a third CLIPTextEncode with nothing in it.
Then start and end: shares of the run, not step numbers. The defaults, 0.17 and 0.5, are the paper's steps 5–15 of 30. end at 1 makes it a purely delayed negative - nothing until 17% of the run, then the negative for the rest - which is what to reach for when an early negative is wrecking composition but you don't want to give it up. space says where the rule is computed; the tooltip's rule of thumb is that linear rules give the same image in any space, nonlinear ones don't, and this one is a straight switch, so don't lose sleep over the box.
Costs and traps
Three forward passes per step. Positive and negative go through the model as one batch and the null prediction is a separate pass on top - against two for standard CFG. That's roughly 1.5× a normal guided step, the honest price of being able to change your mind mid-run.
Fractions and step counts don't line up. 0.17 of a 20-step run is step 3.4, so the window edges are coarse; on an 8-step run the whole window covers three steps or fewer and the effect thins to nothing. If end is below start the window is empty (start <= progress < end) and the negative silently never fires.
It doesn't rescue a guidance-distilled model. On Z-Image Turbo, Klein distilled or anything else designed to run at CFG 1, this node's arithmetic collapses to the conditional prediction at the full three-pass cost; negatives are inert there for structural reasons, and the documented fixes are restating the constraint positively or installing NAG. Don't try to buy negatives back by wringing CFG.
Install
Nothing extra is required - no requirements.txt, no model downloads, torch and the standard library only - but the pack needs a recent ComfyUI (>= 0.38.0) since it's built on the comfy_api.latest node API.
# ComfyUI Manager: search "CFG Megapack" > install > restart
comfy node install comfy-cfg-megapack
# or:
cd ComfyUI/custom_nodes && git clone https://github.com/AbstractEyes/comfy-cfg-megapack
It lands under CFG Megapack > papers > negative prompts. Start from the bundled example workflow (Workflow > Browse Templates > Custom Nodes > comfy-cfg-megapack) rather than wiring it from scratch: every example renders plain CFG and the variant from one seed, the only fair way to judge a change this subtle.
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 | — |
| start | FLOAT | 0.170–1 | Where the negative starts (share of the run). |
| end | FLOAT | 0.500–1 | Where it ends (1 = to the end: a delayed negative). |
| space | COMBO | auto (the method's own) | Where the rule is computed. Linear rules give the same image in any space; nonlinear ones do not. 'auto' uses the space the method was published in (noise for most, denoised for APG and the angle rule, velocity for flow models). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| GUIDER | GUIDER | — |