ComfyUI Node
Wan Video NAG
Normalized Attention Guidance (NAG) for WAN video models (T2V and I2V, 2.1 and 2.2). Replaces or complements CFG by applying guidance directly in attention space — stable across few-step and multi-step sampling. Recommended starting values — T2V multi-step: scale=11, tau=2.5, alpha=0.25 | T2V few-step (Lightning): scale=11-15, tau=2.5-5, alpha=0.25-0.5 | I2V (any): scale=11, tau=1.5-2.0, alpha=0.10-0.20 (lower to preserve reference image)
Wan Video NAG
- model
- conditioning
- MODEL
- CONDITIONING
◄enabledtrue►
◄nag_scale11.000►
◄nag_alpha0.250►
◄nag_tau2.500►
◄nag_sigma_end0.00►
◄input_type▾►
◄inplacefalse►
◄cond_zero_outtrue►
◄nag_scale_end0.000►
Categorynifty/model
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | BOOLEAN | true | Master switch. When false the node is a no-op: model and conditioning pass through unchanged. |
| model | MODEL | — | |
| conditioning | CONDITIONING | Your NEGATIVE conditioning (empty or negative prompt). NAG uses this as its internal reference — the direction the model is guided AWAY from in attention space. Do NOT connect the positive conditioning here. With cond_zero_out=True, this also flows to the CONDITIONING output as a zeroed tensor for the sampler's negative slot. | |
| nag_scale | FLOAT | 11.0000–100 | Guidance strength (φ), analogous to CFG scale. Good range for WAN: 8–15. Setting to 0 disables NAG. Tune this last — first settle on nag_tau and nag_alpha. |
| nag_alpha | FLOAT | 0.2500–1 | Blend weight (α) between NAG-guided and original positive attention (Eq. 10). 0 = no effect, 1 = full NAG. T2V default: 0.25 | I2V: use lower (0.10–0.20) to preserve the reference image. Few-step (Lightning LoRA): can go higher (0.3–0.5). |
| nag_tau | FLOAT | 2.5000–10 | L1-norm clipping threshold (τ): caps how far guided attention deviates from positive attention (Eq. 9 in paper). Lower = safer, less drift. Higher = stronger correction. T2V default: 2.5 | I2V: use lower (1.5–2.0) to preserve the reference image. Few-step (Lightning LoRA): can go higher (3–5). Paper ablation: both tau and alpha are critical — without them output degrades sharply above scale=5. |
| nag_sigma_end | FLOAT | 0.000–1 | NAG is skipped when denoising sigma drops below this value. 0.0 = always active (correct for two-model high/low-noise pipelines). For single-model pipelines: 0.75 achieves near-identical quality with significantly less compute (paper authors' recommendation for flow-based models). Note: WAN uses Rectified Flow where sigma runs 1.0 → 0.0. |
| input_type | COMBO | default: sampler sends a [positive, negative] batch pair (standard CFG setup). batch: single conditioning without a paired negative — use when sampling without CFG (e.g. distilled/few-step WAN models with Lightning LoRA). | |
| inplace | BOOLEAN | false | Modify tensors in-place to reduce peak VRAM. Slightly alters numerical results. Enable only if out of memory. |
| cond_zero_out | BOOLEAN | true | Output a zeroed-out (neutral) conditioning instead of the input conditioning. Recommended: NAG handles guidance internally, so the sampler's negative slot should be empty to avoid interference. Disable only if intentionally stacking NAG on top of CFG. |
| nag_scale_endopt | FLOAT | 0.0000–100 | Sigma-adaptive scale: linearly interpolates from 'nag_scale' (at sigma=1.0) to 'nag_scale_end' (at sigma=0.0). 0.0 = disabled (uses constant nag_scale). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| CONDITIONING | CONDITIONING | — |