NAGCFGGuiderAdvanced
Run NAG and CFG together in a custom sampler chain
- model
- positive
- negative
- nag_negative
- latent_image
- GUIDER
Your negative prompt box is a lie on half the models you run. On anything guidance-distilled - Z-Image Turbo, Klein, Anima with a turbo LoRA, most things that ship at CFG 1 - there's no unconditional pass for the negative text to steer, so "blurry, ugly, bad anatomy" does literally nothing. NAG (Normalized Attention Guidance) fixes that by steering the attention maps instead of the model output, and this node is the version you reach for when you're building a custom sampler chain and want NAG and plain CFG at the same time.
NAGCFGGuiderAdvanced is one of the six nodes in BigStationW's ComfyUI-NAG-Extended pack, which ports NAG to far more architectures than the original: Flux and Flux Kontext, Klein, Wan, Hunyuan Video, Chroma, SD3.5, SDXL, SD, Anima, HiDream and more. This is the custom-sampling guider variant - if you just want one-click replacement, KSamplerWithNAG does the same job with less ceremony. You reach for the guider when you're already wiring SamplerCustom and want full control.
How it actually works
NAG comes from a paper (arXiv 2505.21179) that noticed negative prompting doesn't need the expensive second model pass at all. Instead it patches the model's forward pass to run attention with your negative text concatenated in, then extrapolates the image attention maps away from that negative: roughly z_pos * scale - z_neg * (scale - 1), normalizes the result with an L1 norm capped at nag_tau, and blends it back toward the positive by nag_alpha. Guidance happens inside attention, not in the score extrapolation, so it works at CFG 1 where ordinary negative prompts are dead. This node's guider is a CFGGuider subclass, so at cfg above 1 you get regular CFG layered on top - the "complements CFG in multi-step sampling" claim from the README, and why it's a good fit for SDXL/SD rigs as well as distilled models.
The inputs that matter
Only a few you'll actually touch:
nag_negative- the conditioning NAG uses for its attention extrapolation. Wire a CLIP Text Encode of your negative prompt here; it's separate from the normalnegativeinput, though people usually feed the same text to both.nag_scale- extrapolation strength. Default 5.0. Higher = stronger negative guidance. The original NAG author cautioned against pushing this too high (community consensus cited "don't exceed 3"), so treat the default as a starting point, not a rule.nag_tau(default 2.5) andnag_alpha(default 0.25) - the normalization cap and the blend factor. Lower both for image-reference jobs like i2v so you don't wash out the reference; on few-step models you can raise them for punchier negatives.nag_sigma_start/nag_sigma_end- the sigma window where NAG is active. This is the "Advanced" part: the plainNAGCFGGuiderhardcodes the start at 14.7; here you get both bounds plusdisplay_logs, which prints[NAG]activation lines per step. That logging is gold when you're dialing in the window. For flow-based Flux,nag_sigma_end = 0.75gets near-identical quality with a real speed win; diffusion-based SDXL likesnag_sigma_end = 4. Defaults (14.7 → 0) keep NAG on the whole schedule.cfg- ordinary CFG scale, default 1. Leave it at 1 on distilled models; raise it on multi-step ones.
Output is a single GUIDER - plug it into the guider input of SamplerCustom.
Installing it
ComfyUI Manager (search "ComfyUI-NAG-Extended") or:
cd ComfyUI/custom_nodes
git clone https://github.com/BigStationW/ComfyUI-NAG-Extended
Restart ComfyUI. No extra pip dependencies, no model downloads - it patches whatever model you already have.
Where people get burned
- Wrong model type → hard error. The pack only knows the architectures it has switchers for, and unsupported ones raise
Model type ... is not support for NAGCFGGuider. Check the supported list in the README before wiring it to an exotic new release. - Compatibility moves. Early NAG didn't get along with TeaCache, and some users reported the Wan sampler "breaking" after ComfyUI upgrades. This fork ships TeaCache and WaveSpeed-aware forward passes, which helps, but if a ComfyUI update breaks your chain, update the custom node - that's the usual fix, not your workflow.
- Overcooking the negative. Crank
nag_scaleandnag_tautoo high together and you'll get artifacts, not obedience. Fixnag_tauandnag_alphafirst, then tune onlynag_scale- the README's own advice.
Inputs (12)
| 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_start | FLOAT | 14.700–20 | — |
| nag_sigma_end | FLOAT | 0.000–20 | — |
| latent_image | LATENT | — | |
| display_logs | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| GUIDER | GUIDER | — |