Nodes/⚗ AlchemicaSampler/⚗ Alchemica Attention Guidance (NAG / PAG / SEG)
ComfyUI Node

⚗ Alchemica Attention Guidance (NAG / PAG / SEG)

A negative prompt that works at CFG 1 — how Alchemica's NAG node earns its 40%

By Nessuno76·Created about a month ago·Updated 21 days ago· 4
⚗ Alchemica Attention Guidance (NAG / PAG / SEG)
  • model
  • negative
  • model
  • report
◄nag_scale3.0►
◄nag_tau2.5►
◄nag_alpha0.25►
◄nag_blocksall►
◄nag_sigma_start-1.00►
◄nag_sigma_end0.00►
◄structureoff►
◄structure_scale0.00►
◄structure_blocks8-19►
◄seg_blur10.0►
◄structure_sigma_start-1.00►
◄structure_sigma_end0.00►

Krea 2 Turbo runs at CFG 1, and at CFG 1 the negative prompt box in ComfyUI is decoration. There is no unconditional pass to steer, so "blurry, ugly, deformed" does exactly nothing. This node is the fix: it patches the model so a negative prompt acts in attention space instead, with no second model pass.

That's the pitch of NAG (Normalized Attention Guidance), and it's the reason this node exists in the first place. The rest of it - PAG and SEG - is a smaller, stranger extra.

What it actually does

In every block of Krea 2's single-stream DiT, the image tokens attend to the text tokens. The patch makes them attend a second time, to your negative text, and then extrapolates the result away from the negative. Two guards keep that from wrecking the image: the displacement is norm-limited by nag_tau, and blended back with nag_alpha. The negative gets its own small attention stream, so the cost is one extra attention per block, not a second full forward pass.

That's a different beast from the old "just raise CFG to 1.4" trick, which on a distilled model burns the image and doubles render time. Here the guidance never leaves attention space.

The inputs you'll actually touch

Everything is a widget on the node, plus one optional input.

  • model - in from your LoRA stack or loader, out to any Alchemica sampler.
  • nag_scale - the strength. The author validated 3, and the tooltip is honest about it: at 3 the unwanted element disappears and the image comes back 99.3% identical. 0 = off. Don't be tempted to go to 10; you can, but you're editing the picture at that point.
  • nag_sigma_start - the important one. Its default is -1, which means "start at the hand-off sigma from your calibration profile" (around 0.87). That window is why this is usable: NAG comes on after the composition is already locked, so it removes the thing you don't want without moving the picture. Set it to 1.0 and you get the stronger, classical behaviour - and a different composition.
  • nag_sigma_end - 0 by default, i.e. it stays on to the end. Raise it if the guidance is interfering with the final clean-up.
  • nag_blocks - all by default; 0-13 or 5,8,10-12 if you want to confine it.
  • negative (optional, CONDITIONING) - from the pack's ⚗ Text Encode node. This is the text NAG pushes away from. Without a negative connected there's nothing for NAG to use; it isn't an error, it's just a no-op.
  • structure - off by default. Switch it to PAG or SEG (below).
  • The rest - nag_tau 2.5, nag_alpha 0.25, structure_scale, structure_blocks 8-19, seg_blur 10, both structure sigma windows - you leave alone unless you're deliberately experimenting.

Outputs are model (patched, wire it into the sampler) and report, a string saying what was applied and what the sigma window resolved to. The report is worth reading once - it's how you find out whether your profile was found or whether NAG fell back.

PAG and SEG, and whether you want them

structure is two techniques behind one menu. PAG is a second prediction with identity attention in blocks 8–19: measured at scale 1 from -1, same picture, crisper, slightly more contrast, a few freckles gone. A rendering taste, not a fix. SEG is blurred image queries - keep structure_scale at 0.3 or below, because above that you get halos, which the tooltip admits. Both cost one extra model call per step inside their sigma window, so the window is the budget control.

Installing

The node is part of the AlchemicaSampler pack, which needs ComfyUI 0.36+ (it uses CLIP.generate elsewhere, and Krea 2 support generally). No pip dependencies at all.

# ComfyUI Manager: search "AlchemicaSampler"
# or
comfy node install comfyui-alchemicasampler
# or
cd ComfyUI/custom_nodes && git clone https://github.com/Nessuno76/ComfyUI-AlchemicaSampler

Restart the server afterwards - a browser reload will not register new nodes. Then look under the ⚗ AlchemicaMente category.

Where people get burned

Expecting a free lunch. NAG from the calibrated hand-off adds about 40% to the refinement stage's time. It's cheap, not free, and if you're already on fast mode with a small step budget you'll feel it.

Setting nag_sigma_start to 1.0 first. It looks like the "more correct" setting and it's the one that changes your composition. Start at -1, see if the thing you dislike disappears. If it doesn't, then open the window.

Running it without a profile. -1 falls back to a sane default - it still works, but the hand-off sigma is analytically derived rather than measured. Calibrate once and this node gets sharper about where to switch on.

Forgetting the wire order. Patch the model after your LoRAs. Model → LoRA Stack → Attention Guidance → sampler is the shape of it.

Category⚗ AlchemicaMente/model_patches

Inputs (14)

NameTypeDefaultDescription
modelMODEL—
nag_scaleFLOAT3.00–20NAG: strength of the negative at cfg 1. 0 = off. Validated: 3 (the unwanted element disappears, image unchanged)
nag_tauFLOAT2.51–10NAG: norm limit (how far it may move away from the positive)
nag_alphaFLOAT0.250–1NAG: blend with the original attention
nag_blocksSTRINGallDiT blocks (0-27): 'tutti' (all), '0-13', '5,8,10-12'
nag_sigma_startFLOAT-1.00-1–1NAG active from this sigma downwards. 1.0 = from the start (may change the composition). -1 = from the profile's hand-off sigma (~0.87): removes the negative WITHOUT changing the composition
nag_sigma_endFLOAT0.000–1NAG active down to this sigma
structureCOMBOoffPAG = identity attention: crisper, more contrasty rendering (measured: scale 1 from -1, image unchanged, fewer freckles). SEG = blurred queries: halos above 0.3. Each costs 1 extra model call per step inside the window
structure_scaleFLOAT0.00-5–10Strength of the structure guidance. 0 = off
structure_blocksSTRING8-19—
seg_blurFLOAT10.00.5–1000SEG: gaussian sigma in tokens (>=1000 = infinite)
structure_sigma_startFLOAT-1.00-1–1Structure guidance window: from this sigma... (-1 = from the profile)
structure_sigma_endFLOAT0.000–1...down to this one (costs only inside the window)
negativeoptCONDITIONINGThe negative for NAG (from the ⚗ Text node)

Outputs (2)

NameTypeDescription
modelMODEL—
reportSTRING—