Nodes/sd-perturbed-attention/Normalized Attention Guidance
ComfyUI Node

Normalized Attention Guidance

Negative prompts that actually work at CFG 1

By pamparamm·Created 2 years ago·Updated 5 months ago· 299
Normalized Attention Guidance
  • model
  • negative
  • MODEL
scale2.0
tau2.5
alpha0.500
sigma_start-1.00
sigma_end-1.00
unet_block_list

Negative prompts ride entirely on CFG. At CFG 1, the unconditioned pass that a negative prompt needs to act through often isn't even computed, so anything you type in that box is silently ignored - and CFG 1 is exactly where a growing share of models live now (Flux, step-distilled checkpoints, Turbo/Lightning variants). NAG is the fix: it reintroduces negative steering by working inside the model's attention instead of through the two-pass CFG math, so it keeps working even when CFG doesn't.

The node's own description is blunt about the point of it: "An additional way to apply negative prompts to the image... compatible with CFG, PAG, and other guidances, and can be used with guidance- and step-distilled models as well." Mechanically, rather than computing an unconditioned prediction and subtracting it, NAG extrapolates the positive and negative attention features directly and blends the result back in - no second CFG pass required, which is why it doesn't care that CFG is pinned at 1.

One naming note worth flagging: there's a separate, standalone ComfyUI-NAG pack from the original NAG paper's author (ChenDarYen) floating around the ecosystem too. This node is pamparamm's own implementation of the same NAG paper, bundled here alongside PAG, SEG, and the rest - same idea, different pack, so don't be surprised if you see NAG referenced elsewhere with a different install path.

The inputs that matter

  • model - the diffusion model. The node's own tooltip has a real gotcha here: if you're also using another attn2 replacer (like IPAdapter), place this node after it in the chain. Get the order wrong and the patches can fight each other silently.
  • negative (CONDITIONING) - your negative, whether that's the same one you'd feed a normal negative CFG slot or something entirely different.
  • scale (default 2) - strength of the effect. Per the tooltip it "does nothing when tau=0," so scale and tau work together, not independently.
  • tau (default 2.5) - the normalization threshold; the tooltip notes a larger value should increase scale's impact, which is a little counterintuitive if you're expecting it to work like a damper.
  • alpha (default 0.5) - a straight linear blend between the original prediction (alpha=0) and the full NAG result (alpha=1). This is your safety valve if NAG is overcorrecting.
  • sigma_start / sigma_end (both -1) - restrict NAG to part of the denoise; -1/-1 means the whole run.
  • Optional unet_block_list - comma-separated blocks NAG applies to; empty (the default) means all blocks.

Output is a MODEL you wire straight into your sampler.

How to install it

ComfyUI Manager: search "Perturbed-Attention Guidance" (the pack's registry name - NAG ships inside it, it isn't a separate install). Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/pamparamm/sd-perturbed-attention

Restart ComfyUI. No models, no extra dependencies.

Common issues & troubleshooting

Wrong order with IPAdapter or similar. This is the one explicitly called out by the node itself: NAG has to go after any other node that replaces attn2 (IPAdapter being the common case). If your IPAdapter reference stops working or gets weird once you add NAG, check the patch order first.

Cranking scale way up doesn't help. The upstream guidance is not to exceed roughly 3 - the default of 2 already sits close to that ceiling. If the negative isn't biting hard enough, reach for tau or alpha before pushing scale further; going past the recommended range tends to degrade quality rather than strengthen the negative.

Grainy output. There's a known, still-unresolved community report of extremely grainy results when NAG-style nodes are paired with a zeroed-out negative conditioning instead of a real one (even an empty-string encode). If you're feeding this an all-zeros conditioning to save a CLIP encode, try swapping in an actual (even blank) encoded negative first - no confirmed root cause, but it's a cheap thing to rule out.

No visible effect on a distilled model. Double-check you're actually at CFG 1 or otherwise in a regime where normal negatives are dead - NAG earns its keep specifically there. If you're running a normal SD1.5/SDXL workflow with real CFG active, your existing negative prompt is probably already doing the work and NAG has less to add.

Categorymodel_patches/unet

Inputs (8)

NameTypeDefaultDescription
modelMODELThe diffusion model. If you are using any other attn2 replacer (such as `IPAdapter`), you should place this node after it.
negativeCONDITIONINGNegative conditioning: either the one you use for CFG or a completely different one.
scaleFLOAT2.00–100Scale of NAG, does nothing when `tau=0`.
tauFLOAT2.50–100Normalization threshold, larger value should increase `scale` impact.
alphaFLOAT0.5000–1Linear interpolation between original (at `alpha=0`) and NAG (at `alpha=1`) results.
sigma_startFLOAT-1.00-1–10000
sigma_endFLOAT-1.00-1–10000
unet_block_listoptSTRINGComma-separated blocks to which NAG is being applied to. When the list is empty, NAG is being applied to all block. Read README from sd-perturbed-attention for more details.

Outputs (1)

NameTypeDescription
MODELMODEL