This branch supports Flux 2 Klein and Anima
Navigate to the ComfyUI/custom_nodes folder, open cmd and run:
git clone https://github.com/BigStationW/ComfyUI-NAG-ExtendedRestart ComfyUI after installation.
Implementation of Normalized Attention Guidance: Universal Negative Guidance for Diffusion Models for ComfyUI.
NAG restores effective negative prompting in few-step diffusion models, and complements CFG in multi-step sampling for improved quality and control.
Paper: https://arxiv.org/abs/2505.21179
Code: https://github.com/ChenDarYen/Normalized-Attention-Guidance
KSamplerWithNAG,KSamplerWithNAG (Advanced),SamplerCustomWithNAGBasicGuider,NAGCFGGuider,NAGCFGGuiderAdvanced
To use NAG, simply replace
KSamplerwithKSamplerWithNAG.KSamplerWithNAG (Advanced)withKSampler (Advanced).SamplerCustomWithNAGwithSamplerCustom.NAGGuiderwithBasicGuider.CFGGuiderwithNAGCFGGuider.
We currently support Flux, Flux Kontext, Wan, Vace Wan, Hunyuan Video, Choroma, SD3.5, SDXL and SD.
Example workflows are available in the ./workflows directory!
When working with a new model, it's recommended to first find a good combination of nag_tau and nag_alpha, which ensures that the negative guidance is effective without introducing artifacts.
Once you're satisfied, keep nag_tau and nag_alpha fixed and tune only nag_scale in most cases to control the strength of guidance.
Using nag_sigma_end to reduce computation without much quality drop.
For flow-based models like Flux, nag_sigma_end = 0.75 achieves near-identical results with significantly improved speed. For diffusion-based SDXL, a good default is nag_sigma_end = 4.
nag_scale: The scale for attention feature extrapolation. Higher values result in stronger negative guidance.nag_tau: The normalisation threshold. Higher values result in stronger negative guidance.nag_alpha: Blending factor between original and extrapolated attention. Higher values result in stronger negative guidance.nag_sigma_end: NAG will be active only untilnag_sigma_end.
- For image-reference tasks (e.g., Image2Video), use lower
nag_tauandnag_alphato preserve the reference content more faithfully. - For models that require more sampling steps and higher CFG, also prefer lower
nag_tauandnag_alpha. - For few-step models, you can use higher
nag_tauandnag_alphato have stronger negative guidance.
