Nodes/ComfyUI-Anima-NAG/Anima Normalized Attention Guidance
ComfyUI Node

Anima Normalized Attention Guidance

Anima's negative prompt goes dead at CFG 1 — this node revives it

By hybskgks28275·Created 4 months ago·Updated 4 months ago· 8
Anima Normalized Attention Guidance
  • model
  • model
scale2.0
tau2.5
alpha0.50
start_percent0.00
end_percent1.00
only_animatrue
optimize_outside_rangetrue

If you run Anima with its Turbo LoRA, you've hit the wall this node exists for: at CFG 1 the negative prompt field is a decorative box. Anima's turbo path is guidance-distilled - the "push away from the negative" extrapolation is baked into the weights, so there's no unconditional pass for a negative prompt to attach to, and no amount of worst quality, low quality in the box changes a pixel. NAG (Normalized Attention Guidance) is the workaround that fixes it by poking at attention itself instead of the guidance math. This node is the Anima-specific port of that trick, and it's the one you want for the model - more on why in a second.

NAG isn't new. It made its name on Wan video, got ported to Z-Image Turbo, and Anima users wanted it basically from day one. What's different here is how this implementation hooks in.

How it works

Most SD/SDXL NAG nodes find BasicTransformerBlock.attn2 and patch it. Anima isn't an SDXL fine-tune - it's a 2B Cosmos-Predict2 DiT, and ComfyUI reports it as image_model="anima", running through a different attention path. Those SDXL patches silently no-op on it. This node wraps ComfyUI's optimized_attention_override instead, which is the path Anima actually uses, and if another node already set an override it wraps that rather than clobbering it.

Mechanically, each step inside the active range it:

  1. Runs the normal positive-branch attention, then a second call that keeps your positive query but swaps in the negative prompt's keys/values.
  2. Treats positive − negative as "the direction the negative prompt is pulling," and pushes your output away from it by scale.
  3. Normalizes that pushed result with an L1-norm clamp so it can't blow up (tau), then blends it back with the original positive output (alpha).

Self-attention and masked attention calls are skipped - the former gives itself away by matching token counts, and mask slicing doesn't generalize across backends.

The knobs that matter

Only three of the inputs need real attention; the rest are set-and-forget.

  • scale (2.0) - how hard it pushes away from the negative branch. Start here when you want more "negative-ness."
  • tau (2.5) - the normalization ceiling. Higher = stronger guidance. If your image starts losing details, this is the first one to drop.
  • alpha (0.5) - blend between the raw positive attention and the normalized guided version. 0.5 is a sane default; crank toward 1 for a stronger effect.

start_percent / end_percent set the active sampling range (0.0 = first step, 1.0 = last, converted via percent_to_sigma()), and only_anima (default on) makes the node a no-op unless the model is actually detected as Anima - a nice safety rail if you reuse a workflow with another checkpoint. optimize_outside_range keeps steps outside the NAG range on the cheap single-branch path, which keeps partial ranges fast. The single model output is the patched model; wire it into your sampler.

Install and setup

cd ComfyUI/custom_nodes
git clone https://github.com/hybskgks28275/ComfyUI-Anima-NAG

Restart ComfyUI. It's also registered for ComfyUI Manager (search "ComfyUI-Anima-NAG"). Good news on dependencies: requirements.txt is empty. It does use ComfyUI's newer extension API, so keep ComfyUI reasonably current. You still need the model files: anima-base-v1.0.safetensors in models/diffusion_models, qwen_3_06b_base.safetensors in models/text_encoders, and qwen_image_vae.safetensors in models/vae. A ready-to-run Turbo LoRA + NAG workflow ships in WorkFlow/AnimaTurboLoRAwithNAG.json.

The recommended starting point: Turbo LoRA, CFG 1.0, 8–12 steps, scale 2.0, tau 2.5, alpha 0.5, range 0.0–0.5.

Where people get burned

  • "It does nothing." The node needs a CFG batch with both branches - if you only connect a positive conditioning, there's no negative to push away from, and it silently no-ops. Wire negative conditioning to the sampler.
  • "NAG is a Wan thing, it doesn't work on Anima." That claim floats around the subreddit and it's wrong - the math is generic cross-attention, not Wan tensors, and people have demonstrably used it on Anima (the "fundamentally identical" critique got rebutted with a concrete example of a negated element disappearing). If yours genuinely does nothing, check the wiring above, not the tensor format.
  • Detail loss. The recurring real complaint on Anima is NAG "forgetting" details. The practical fix reported from the wild: drop tau (one user found 1.0 worked well when 2.5+ was stripping things) or shorten end_percent. Start from the defaults and back off until the mush goes away.

It's experimental, and the author says the defaults assume the Turbo LoRA's 8–12 steps - if you're on a different step count or acceleration method, re-tune the range and scale for your workflow.

CategoryAnima/Guidance

Inputs (8)

NameTypeDefaultDescription
modelMODELAnima Preview 3 model to patch.
scaleFLOAT2.00–100NAG scale. Higher values push away from the negative branch more strongly.
tauFLOAT2.50.01–100Normalization threshold. Higher values allow stronger guidance.
alphaFLOAT0.500–1Blend between original positive attention and normalized guided attention.
start_percentFLOAT0.000–1Relative sampling progress to start applying NAG. 0.0 is the first step.
end_percentFLOAT1.000–1Relative sampling progress to stop applying NAG. 1.0 is the last step.
only_animaBOOLEANtrueWhen enabled, do nothing unless the model is detected as image_model='anima'.
optimize_outside_rangeBOOLEANtrueWhen enabled, steps outside the NAG percent range compute only the positive branch. This preserves CFG=1 turbo workflows and makes partial ranges faster.

Outputs (1)

NameTypeDescription
modelMODEL