KSamplerWithNAG
Negative prompts that actually work on CFG-1 models
- model
- positive
- negative
- nag_negative
- latent_image
- LATENT
This is the node most people actually want out of the whole ComfyUI-NAG pack: a straight drop-in replacement for KSampler that makes negative prompts work again on models where they've quietly stopped doing anything. If you're on Flux, Flux Kontext, Chroma, Wan, Hunyuan Video, or any other guidance-distilled model running at CFG 1, your negative prompt box is inert - not weak, inert, because at CFG 1 ComfyUI doesn't even compute the pass a negative prompt needs to steer through. KSamplerWithNAG swaps in Normalized Attention Guidance, which gets a working negative back by working in attention space instead.
Why you'd reach for it
CFG works by running the model twice per step - once conditioned on your prompt, once not - and pushing the result away from the unconditioned prediction. At CFG 1 that push is mathematically zero, so ComfyUI skips the second pass entirely as a speed optimization. That's fine when you don't need a negative prompt. It's a real problem when you do, because raising CFG back up on a guidance-distilled model doesn't gently restore control - it burns the image, since the model was trained assuming that correction wasn't needed. NAG doesn't touch CFG at all. It extrapolates the model's attention away from a separate negative conditioning, which is why it keeps working exactly where CFG-based negatives give up.
How it works, at the level you need
Same architecture, same speed characteristics as KSampler - this node just adds an attention-space nudge on top. You give it a nag_negative conditioning (what you want to steer away from), and during sampling it extrapolates the model's attention features away from that target, blends the result back in by a set fraction, and normalizes the whole thing so it doesn't run away into artifacts. The four dials that control this are shared across every node in this pack.
The inputs and outputs that matter
It's KSampler's full input list - model, seed, steps (default 20), cfg (default 8), sampler_name, scheduler, positive, negative, latent_image, denoise (default 1) - plus one new required conditioning and four NAG-specific floats:
nag_negative- the conditioning NAG actually reads. Separate fromnegative, which only matters ifcfgis above 1.nag_scale(default 5) - your main strength knob day to day. Higher pushes harder away fromnag_negative.nag_tau(default 2.5) andnag_alpha(default 0.25) - normalization internals. Find a combo that's effective without artifacts on a new model, then leave them alone and just tunenag_scale.nag_sigma_end(default 0) - NAG stays active until this sigma. Raising it above 0 turns NAG off early in the denoise process, which the pack's author notes buys back speed with barely any quality loss once composition is locked in (around 0.75 on Flux-family models, closer to 4 on SDXL-style diffusion models).
One output: LATENT, feeding a VAE Decode exactly like KSampler always did.
Installing it
Via ComfyUI Manager, the fast path: search "ComfyUI-NAG", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ChenDarYen/ComfyUI-NAG
then restart ComfyUI. No models to download and nothing heavy in the dependency chain - it's pure math on the attention maps of a model you've already loaded.
Common issues
Confusion about the example workflow. The pack's official example graph has two KSamplers side by side - a plain KSampler and a KSamplerWithNAG, both fed the same latent - and more than one person has assumed the first one must feed into the second and gotten stuck trying to figure out why it doesn't. It doesn't need to: that first sampler is just there to render an unguided comparison image, not to hand off a latent. If you're not doing a before/after comparison, you only need the NAG one.
A ComfyUI core update breaks it with a TypeError about an unexpected keyword argument. Under the hood this node builds an NAG guider and runs it through the same core sampling machinery as SamplerCustom, and that internal interface has moved before - a real reported failure was inner_sample() got an unexpected keyword argument 'latent_shapes' after a core update added that argument upstream. If your workflow errors out right after updating ComfyUI, check for a pack update before assuming your graph is wrong.
The negative "isn't doing anything." Almost always nag_negative is unwired or pointed at an empty conditioning - it's easy to plug your prompt only into negative out of habit and miss the NAG-specific slot entirely.
Keep the pack updated if you're on Flux, Flux Kontext, or Chroma specifically - there was a real bug shortly after release that degraded guidance quality on exactly those three architectures, fixed within days. Old cached copies of the node can still be running it.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model used for denoising the input latent. | |
| seed | INT | 00–18446744073709550000 | The random seed used for creating the noise. |
| steps | INT | 201–10000 | The number of steps used in the denoising process. |
| cfg | FLOAT | 8.00–100 | The Classifier-Free Guidance scale balances creativity and adherence to the prompt. Higher values result in images more closely matching the prompt however too high values will negatively impact quality. |
| 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 | — |
| sampler_name | COMBO | The algorithm used when sampling, this can affect the quality, speed, and style of the generated output. | |
| scheduler | COMBO | The scheduler controls how noise is gradually removed to form the image. | |
| positive | CONDITIONING | The conditioning describing the attributes you want to include in the image. | |
| negative | CONDITIONING | The conditioning describing the attributes you want to exclude from the image. | |
| nag_negative | CONDITIONING | The conditioning describing the attributes you want to exclude from the image for NAG. | |
| latent_image | LATENT | The latent image to denoise. | |
| denoise | FLOAT | 1.000–1 | The amount of denoising applied, lower values will maintain the structure of the initial image allowing for image to image sampling. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | The denoised latent. |