NAGCFGGuider
Get real negative prompting back in the custom-sampling chain
- model
- positive
- negative
- nag_negative
- latent_image
- GUIDER
If you've moved from plain KSampler into ComfyUI's modular "custom sampling" graph - the one where you wire up RandomNoise, a guider, a sampler and a scheduler separately instead of one big node - NAGCFGGuider is the drop-in swap for CFGGuider when your model is one of the guidance-distilled ones that made CFG stop working in the first place. Flux, Flux Kontext, Chroma, HiDream, SD3.5-style models: most of them run at CFG 1, where a normal negative prompt is mathematically inert. NAGCFGGuider gets the negative back without turning CFG back on.
Why this exists
At CFG 1, ComfyUI doesn't just weight the negative pass to zero - it skips computing it entirely. That's a real speed optimization, and it means "just raise CFG a bit" isn't free: it roughly doubles your per-step compute, and on a model trained without that correction it burns the image. NAG (Normalized Attention Guidance, from the same ChenDarYen who wrote this pack) sidesteps the whole problem by intervening in the model's attention rather than in a second denoising pass. It extrapolates away from your nag_negative conditioning inside attention space, which is why it works even when CFG can't run at all.
Inputs and outputs that matter
NAGCFGGuider takes three separate conditioning slots, which trips people up the first time they see it: positive (what you want), negative (the standard CFG negative - only does anything if cfg is above 1), and nag_negative (the NAG negative - this is the one doing the real work at CFG 1). You can point negative and nag_negative at the same encoded text if you want; they don't have to differ.
The rest: model, latent_image, and cfg (default 1 here, not 8 - a tell that this node is built for the guidance-distilled use case rather than a full-CFG model). Then the four NAG knobs, all shared across the whole pack: nag_scale (default 5, strength of the guidance), nag_tau (default 2.5, the normalization threshold), nag_alpha (default 0.25, how much of the extrapolated attention gets blended in), and nag_sigma_end (default 0, meaning NAG runs the whole way through - set it above 0 to switch NAG off early and save compute once the composition is locked in).
The output is a single GUIDER, which doesn't go into a KSampler - it plugs into SamplerCustomAdvanced alongside a SAMPLER and SIGMAS node. If you don't already have that graph built, this node isn't the easiest entry point into NAG; KSamplerWithNAG is the simpler swap for a normal KSampler setup.
Tuning, per the author
Find nag_tau and nag_alpha first, on a model you haven't tuned before - you want the negative to actually bite without artifacts showing up. Once those feel right, lock them and use nag_scale as your main strength dial for day-to-day prompting. For image-reference tasks or models that already run more steps at higher CFG, keep tau and alpha on the lower side to preserve the reference more faithfully; few-step distilled models can tolerate pushing both higher. nag_sigma_end is a free efficiency win once you're happy with the composition - 0.75 on Flux-family models gets you near-identical results for meaningfully less compute; SDXL-style diffusion models want something more like 4.
Installing it
ComfyUI Manager is the easy way: search "ComfyUI-NAG", install, restart. Manual install is just as fast:
cd ComfyUI/custom_nodes
git clone https://github.com/ChenDarYen/ComfyUI-NAG
then restart ComfyUI. There's no model download and no heavyweight dependency here - NAG works on tensors from the model you've already loaded, it isn't fetching new weights.
Where people get stuck
A ComfyUI core update breaks it with a TypeError about an unexpected keyword argument. This is a real, reported failure, not a hypothetical: after a ComfyUI update added a latent_shapes argument to the core sampler's inner_sample, users started hitting NAGCFGGuider.inner_sample() got an unexpected keyword argument 'latent_shapes'. The pack's guider classes subclass ComfyUI's own and need to track its signature - when core moves faster than the pack's releases, this is what breaks. If you see it, check for a pack update first; if none exists yet, pin your ComfyUI core to a slightly older commit until one lands.
The negative "does nothing." Nine times out of ten this is nag_negative left unwired or pointed at an empty conditioning - the node has no way to guess what you want to steer away from. Check that slot specifically, separately from negative.
Pushing nag_scale far past its default starts producing artifacts rather than a stronger effect - this behaves like most guidance-style parameters: there's a useful range and then a cliff. Treat any big jump from the default 5 as an experiment you verify on a fixed seed, not an assumed improvement.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| nag_negative | CONDITIONING | — | |
| cfg | FLOAT | 1.00–100 | — |
| nag_scale | FLOAT | 5.00–100 | — |
| nag_tau | FLOAT | 2.51–10 | — |
| nag_alpha | FLOAT | 0.250–1 | — |
| nag_sigma_end | FLOAT | 0.000–20 | — |
| latent_image | LATENT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| GUIDER | GUIDER | — |