KSamplerWithNAG (Advanced)
NAG for multi-stage and refiner sampling chains
- model
- positive
- negative
- nag_negative
- latent_image
- LATENT
This is KSampler (Advanced) with Normalized Attention Guidance folded in - same job as KSamplerWithNAG, but built for the multi-stage sampling patterns the Advanced node exists for: base-plus-refiner chains, splitting a run across two samplers, or resuming a partially-denoised latent. If your graph passes a latent between two KSampler (Advanced) nodes, replacing both with this is the direct swap, and it's the piece of this pack that actually gets a slightly better click-through than its siblings, which tracks - people searching for the Advanced variant by name usually already know exactly why they need it.
Why it's a separate node from KSamplerWithNAG
KSampler (Advanced) exists because a single denoise pass isn't always what you want: SDXL's base+refiner split needs to hand off mid-sequence, hires-fix workflows resample a subset of steps, and some pipelines deliberately stop before full denoise so a downstream node can take over. The extra widgets - start_at_step, end_at_step, return_with_leftover_noise - are what make that possible. NAG doesn't change any of that machinery; it just needs to ride along on whichever stage is doing the actual denoising, which is why this node exists instead of you bolting NAG onto only one half of a two-stage chain.
What NAG adds on top
Same mechanism as the rest of the pack: it extrapolates the model's attention away from a nag_negative conditioning you supply, which keeps a real negative-prompting effect alive even on guidance-distilled models pinned to CFG 1 - Flux, Flux Kontext, Chroma, HiDream, Wan, Hunyuan Video - where a normal negative prompt has no CFG pass left to act through.
Inputs and outputs that matter
Everything KSampler (Advanced) already has: model, add_noise (enum, enable/disable - not a boolean here, unlike the non-Advanced node), noise_seed, steps (default 20), cfg (default 8), sampler_name, scheduler, positive, negative, latent_image, start_at_step (default 0), end_at_step (default 10000), and return_with_leftover_noise (enum, disable/enable).
On top: nag_negative (the conditioning NAG steers away from - separate from negative), and the four shared dials - nag_scale (default 5, your day-to-day strength knob), nag_tau (default 2.5) and nag_alpha (default 0.25, tune these once per model and leave them), and nag_sigma_end (default 0, raise it to switch NAG off early once composition is set, for a real speed win with barely any quality cost).
One output: LATENT, same as the standard node - feeds VAE Decode if this is the last stage, or the next KSamplerWithNAG (Advanced) if you're chaining.
The one thing worth getting right in a chain
If you're splitting a run across two of these - say, steps 0–15 on one and 15–30 on the next - decide once whether nag_negative should stay identical across both stages or change. Most workflows keep it constant: NAG is steering the same unwanted content the whole way through, and there's no established practice around varying it mid-chain. Change one setting at a time here, same as with any multi-stage sampler; splitting a run introduces enough variables on its own without also inventing new NAG behavior between stages.
Installing it
ComfyUI Manager: search "ComfyUI-NAG", install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ChenDarYen/ComfyUI-NAG
then restart. No model downloads, nothing heavy to install - it works on tensors from a model you've already got loaded.
Common issues
Mixing this up with the non-Advanced node in a chain. If one stage of your split uses plain KSamplerWithNAG and the next uses the Advanced variant, start_at_step/end_at_step bookkeeping gets easy to lose track of - keep both stages on the same node type.
Post-update TypeErrors about an unexpected keyword argument. This pack's guider internals track ComfyUI core's sampler interface closely, and a core update has broken that interface before with a real reported inner_sample() got an unexpected keyword argument 'latent_shapes' failure. If sampling errors out right after a ComfyUI update, check for a newer ComfyUI-NAG release before assuming your graph broke.
Negative prompt doing nothing. Check nag_negative specifically - it's a separate slot from negative, and leaving it unwired or empty is the most common reason NAG appears to have no effect.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| add_noise | COMBO | 2 options: enable, disable | |
| noise_seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.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 | — |
| sampler_name | COMBO | 42 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +36 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| nag_negative | CONDITIONING | The conditioning describing the attributes you want to exclude from the image for NAG. | |
| latent_image | LATENT | — | |
| start_at_step | INT | 00–10000 | — |
| end_at_step | INT | 100000–10000 | — |
| return_with_leftover_noise | COMBO | 2 options: disable, enable |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |