Nodes/sd-perturbed-attention/Smoothed Energy Guidance (Advanced)
ComfyUI Node

Smoothed Energy Guidance (Advanced)

PAG's softer, more tunable sibling

By pamparamm·Created 2 years ago·Updated 5 months ago· 299
Smoothed Energy Guidance (Advanced)
  • model
  • MODEL
scale3.0
blur_sigma-1.00
unet_blockmiddle
unet_block_id0
sigma_start-1.00
sigma_end-1.00
rescale0.00
rescale_modefull
unet_block_list

If Perturbed-Attention Guidance is the blunt version - swap self-attention for a hard perturbation and guide away from the mess - Smoothed Energy Guidance is the dial-in version. It's built from Susung Hong's "Smoothed Energy Guidance: Guiding Diffusion Models with Reduced Energy Curvature of Attention," and instead of a hard perturbation, SEG blurs self-attention by a controllable amount before computing the guidance term. Same family of trick as PAG - degrade a copy of the prediction and push away from it - but blur strength is a dial instead of an on/off switch, which is why the node exposes a field the plain PAG node doesn't.

The inputs that matter

  • scale (default 3) - same role as everywhere in the pack: how hard you push away from the degraded (here, blurred) prediction.
  • blur_sigma (default -1) - the SEG-specific knob. Per the README, it's the standard deviation of the Gaussian blur applied to attention: higher values increase image "clarity," and negative values set it to infinity - meaning the default is already at maximum blur strength, not a neutral or off state. If you want a gentler SEG effect than the out-of-the-box behavior, you need to set this to a positive finite number, not leave it at default.
  • unet_block / unet_block_id (default middle, 0) - which UNet layer gets the blurred-attention treatment. Same convention as PAG.
  • sigma_start / sigma_end (both -1) - restrict SEG to a noise window; -1/-1 means the whole denoise.
  • rescale / rescale_mode (0 / full) - the same anti-oversaturation valve as PAG: full weighs CFG and SEG together, partial only SEG, snf uses saliency-adaptive noise fusion and ignores the rescale number.
  • Optional unet_block_list overrides the single-block fields with the pack's compact multi-block syntax.

Output is a MODEL, wired straight into your sampler like the rest of this pack.

How to install it

ComfyUI Manager: search "Perturbed-Attention Guidance" (this node ships in that pack, not separately). Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/pamparamm/sd-perturbed-attention

Restart ComfyUI. No models to download, no extra dependencies.

Common issues & troubleshooting

It's doing the maximum thing by default and you didn't realize it. blur_sigma = -1 isn't "off" - it's infinite blur, the strongest setting the node has. If SEG feels too aggressive out of the box, don't reach for scale first; drop in a positive finite blur_sigma (start somewhere moderate and work down) to soften the effect at its source.

Oversaturated or fried output at higher scale. Same fix as everywhere else in this pack: turn on rescale (start around 0.5–0.7) or try rescale_mode: snf, which is specifically pitched at high-guidance-scale quality.

No visible effect. Check the sigma window and the block target before assuming SEG isn't working - the defaults (middle block, always-on) should produce a visible effect at scale 3+ on SD1.5/SDXL, so if you're seeing nothing, verify the model patch is actually landing before the sampler in your graph (it needs to be between your checkpoint/LoRA loaders and the KSampler, not after).

Unsure whether to reach for this or plain PAG. There isn't a documented community verdict on which wins - SEG is genuinely the less-discussed of the two. If you already have a PAG setup you like, SEG's main selling point is the tunable blur_sigma giving you a softer middle ground between "no perturbation" and PAG's harder swap; worth an A/B on your own images rather than assuming one is strictly better.

Categorymodel_patches/unet

Inputs (10)

NameTypeDefaultDescription
modelMODEL
scaleFLOAT3.00–100
blur_sigmaFLOAT-1.00-1–9999
unet_blockCOMBOmiddle3 options: input, middle, output
unet_block_idINT0
sigma_startFLOAT-1.00-1–10000
sigma_endFLOAT-1.00-1–10000
rescaleFLOAT0.000–1
rescale_modeCOMBOfull3 options: full, partial, snf
unet_block_listoptSTRING

Outputs (1)

NameTypeDescription
MODELMODEL