⚗ Alchemica Attention Guidance (NAG / PAG / SEG)
A negative prompt that works at CFG 1 — how Alchemica's NAG node earns its 40%
- model
- negative
- model
- report
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-allby default;0-13or5,8,10-12if 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-offby default. Switch it toPAGorSEG(below).- The rest -
nag_tau2.5,nag_alpha0.25,structure_scale,structure_blocks8-19,seg_blur10, 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.
Inputs (14)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| nag_scale | FLOAT | 3.00–20 | NAG: strength of the negative at cfg 1. 0 = off. Validated: 3 (the unwanted element disappears, image unchanged) |
| nag_tau | FLOAT | 2.51–10 | NAG: norm limit (how far it may move away from the positive) |
| nag_alpha | FLOAT | 0.250–1 | NAG: blend with the original attention |
| nag_blocks | STRING | all | DiT blocks (0-27): 'tutti' (all), '0-13', '5,8,10-12' |
| nag_sigma_start | FLOAT | -1.00-1–1 | NAG 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_end | FLOAT | 0.000–1 | NAG active down to this sigma |
| structure | COMBO | off | PAG = 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_scale | FLOAT | 0.00-5–10 | Strength of the structure guidance. 0 = off |
| structure_blocks | STRING | 8-19 | — |
| seg_blur | FLOAT | 10.00.5–1000 | SEG: gaussian sigma in tokens (>=1000 = infinite) |
| structure_sigma_start | FLOAT | -1.00-1–1 | Structure guidance window: from this sigma... (-1 = from the profile) |
| structure_sigma_end | FLOAT | 0.000–1 | ...down to this one (costs only inside the window) |
| negativeopt | CONDITIONING | The negative for NAG (from the ⚗ Text node) |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |
| report | STRING | — |