Nodes/⚗ AlchemicaSampler/⚗ Alchemica · Attention guidance (NAG / SEG / PAG) [1.0, use Alchemica Attention Guidance (NAG / PAG / SEG)]
ComfyUI Node

⚗ Alchemica · Attention guidance (NAG / SEG / PAG) [1.0, use Alchemica Attention Guidance (NAG / PAG / SEG)]

Getting a negative prompt to work at CFG 1 without changing the picture

By Nessuno76·Created 23 days ago·Updated 6 days ago· 3
⚗ Alchemica · Attention guidance (NAG / SEG / PAG) [1.0, use Alchemica Attention Guidance (NAG / PAG / SEG)]
  • model
  • negativo
  • model
  • report
◄nag_scala3.0►
◄nag_tau2.5►
◄nag_alpha0.25►
◄nag_blocchitutti►
◄nag_sigma_da-1.00►
◄nag_sigma_a0.00►
◄strutturaspenta►
◄struttura_scala0.00►
◄struttura_blocchi8-19►
◄seg_sfocatura10.0►
◄struttura_sigma_da-1.00►
◄struttura_sigma_a0.00►

At CFG 1 on a distilled model, ComfyUI doesn't compute the unconditional prediction at all - math.isclose(cond_scale, 1.0) and the uncond slot stays a zero tensor the arithmetic cancels. So the negative prompt box isn't weak on Krea 2 Turbo, it's inert. Normalized Attention Guidance is the workaround the community settled on for exactly this, and this node is the pack's implementation of it, wired so the fix doesn't also move your composition.

How NAG works

Rather than steering the guidance term, NAG intervenes inside attention. In each of Krea 2's 28 single-stream DiT blocks the image tokens run attention twice - once against the positive text, once against the negative text - and the result is pushed away from the negative, its norm is clamped, then it's blended back:

Z~  = Z+ + s · (Z+ − Z−)        extrapolate away from the negative
Z^  = Z~ · min(1, τ / ‖Z~‖)     limit how far it can drift, relative to ‖Z+‖
Z   = α · Z^ + (1 − α) · Z+     blend with the original attention

The negative text gets its own small attention stream, which is why the cost is one extra attention per block rather than a whole second model pass. The node implements this through ComfyUI's own DIFFUSION_MODEL wrapper extension - it doesn't patch files, so it plays nicely with other packs.

The inputs that matter

model - the sampler's model, and the node hands you a patched model back. Wire that output into your sampler, not the original.

negativo (optional) - the negative conditioning, from ⚗ Text or ⚗ Two-phase prompt. No negative connected, nothing to push away from; NAG is effectively off.

nag_scala - the strength. Author-validated value is 3, and the wider community's independent experience with NAG converges on the same cap ("do not exceed nag_scale = 3" is the original author's own advice). 0 disables it.

nag_tau (2.5) and nag_alpha (0.25) - the norm limit and the blend fraction above. Leave them; these are the knobs you move only if NAG at 3 is visibly overcooking something.

nag_sigma_da - the interesting one. At −1 it starts at the calibrated hand-off sigma, around 0.87, i.e. after composition is locked. The measured result: the unwanted element disappears and the image is 99.3% identical to the original, at roughly +40% time on the refinement stage. Set it to 1.0 and NAG runs from the first step - stronger, but the picture changes, because you're now steering the part of the trajectory that decides layout. Start at −1.

nag_sigma_a - where NAG stops acting, default 0 (all the way down).

nag_blocchi - which blocks, as a string: tutti for all 28, or 0-13, or 5,8,10-12.

PAG and SEG, the other two

struttura selects a second kind of guidance, and it's a different animal - it computes an extra prediction with the image attention deliberately damaged, then extrapolates. That means one extra model call per step inside its sigma window, so keep the window tight.

  • PAG (perturbed attention, identity attention in struttura_blocchi, default 8-19): with scale 1 from −1 the author measured the image essentially unchanged but the rendering crisper and more contrasty, with a few freckles lost. Style choice, not an upgrade.
  • SEG (smoothed energy guidance, blurred image queries, seg_sfocatura in tokens): keep it at 0.3 or below. At 1 it produces halos.

struttura_scala at 0 turns it off. struttura_sigma_da/_a are the window; −1 means "from the profile".

Outputs and wiring

model → any Alchemica sampler's model input. report is a STRING that prints which sigma the −1 resolved to and where it came from - with no calibration profile it says so and falls back to 0.87.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/Nessuno76/ComfyUI-AlchemicaSampler

Restart the server. This node needs the Krea 2 architecture specifically - NAG here is written against the single-stream DiT's block layout, so don't expect it to do anything useful on a different model.

Traps

Expecting the negative prompt box on your sampler to work too. It won't. This node is the mechanism; the conditioning has to come in through negativo.

nag_sigma_da at 1.0 on your first try. You get a stronger effect and a different image, and if you were hoping to keep a composition you liked, that's the setting that loses it. −1 exists precisely for the "remove the water droplets, keep the photo" case.

Wondering why the report is in Italian. The runtime reports in this pack are Italian; the parameter tooltips are English. The glossary in the README covers the key words, and sigma di passaggio is the hand-off sigma.

Long runs. NAG plus PAG plus SEG, each with its own window, stacks extra cost per step. If a generation got 2× slower, check which of the three you left enabled.

Category⚗ AlchemicaMente/legacy (1.0)

Inputs (14)

NameTypeDefaultDescription
modelMODEL—
nag_scalaFLOAT3.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_blocchiSTRINGtuttiDiT blocks (0-27): 'tutti' (all), '0-13', '5,8,10-12'
nag_sigma_daFLOAT-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_aFLOAT0.000–1NAG active down to this sigma
strutturaCOMBOspentaPAG = 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
struttura_scalaFLOAT0.00-5–10Strength of the structure guidance. 0 = off
struttura_blocchiSTRING8-19—
seg_sfocaturaFLOAT10.00.5–1000SEG: gaussian sigma in tokens (>=1000 = infinite)
struttura_sigma_daFLOAT-1.00-1–1Structure guidance window: from this sigma... (-1 = from the profile)
struttura_sigma_aFLOAT0.000–1...down to this one (costs only inside the window)
negativooptCONDITIONINGThe negative for NAG (from the ⚗ Text node)

Outputs (2)

NameTypeDescription
modelMODEL—
reportSTRING—