Nodes/CFG Megapack/SEG: Smoothed Energy Guidance (Hong 2024)
ComfyUI Node

SEG: Smoothed Energy Guidance (Hong 2024)

Blur the attention queries, then steer away from the blur

By AbstractEyes·Created 5 days ago·Updated 5 days ago· 3
SEG: Smoothed Energy Guidance (Hong 2024)
  • model
  • MODEL
◄scale3.0►
◄blur_sigma10.0►
◄blocksmiddle (PAG / SEG default)►

PAG taught people that you don't need a second prompt to get a useful counter-prediction - you can run the same prompt through a deliberately degraded model and guide away from it. SEG (Smoothed Energy Guidance, Hong, NeurIPS 2024) is the gentler sibling: instead of replacing self-attention with the identity, it blurs the attention queries over the image, flattening the attention energy.

Why that's nicer: PAG's perturbation is brutal by design, and people report it frying images on models that are already sensitive to guidance. SEG's degradation is a smoothness knob. In practice the community consensus is muted - one r/StableDiffusion post from May 2025 asks whether SEG is better than PAG and reports being unable to get good results out of it - so treat blur_sigma as the thing to actually iterate on rather than a set-and-forget default.

The mechanism

One extra forward pass per step. On that pass, the self-attention queries in the selected blocks are Gaussian-blurred across the image grid, so each token's query becomes a local average rather than a point sample. Attention becomes locally uniform - flatter energy - and the resulting prediction seg is smoother and less committed.

Then:

out = mix + s * (c - seg)

s is the strength (default 3, the paper's value). Like PAG, SEG stacks on top of your normal CFG rather than replacing it, so your existing cfg still does its job and the weak branch is an additional push away from the flattened prediction.

Inputs and output

  • model - loader → node → sampler.
  • scale - default 3.0, "Strength s (paper 3)". This is how hard you push away from the blurred pass.
  • blur_sigma - default 10.0, "Blur in tokens (100 = infinite: every query is the mean)". Small sigma means the weak branch is barely degraded and the push does almost nothing; 100 means every query becomes the image-wide mean, which is the maximum-flatness case.
  • blocks - which self-attention blocks get perturbed. Presets: middle (PAG / SEG default), middle + first output, deep output (output 0-2), deep input (input 7-8), all SDXL attention blocks. On Anima and other Cosmos-Predict2 transformers those labels map to the middle two blocks, the first third and the last third.

One output: MODEL.

Worth knowing: the pack's stage-2 node, CFG Weak Branch: Perturbed Self-Attention, is the superset - same SEG mechanism with a method selector plus PAG, temperature and skip, and a mode switch. SEG here is the paper's own settings, with fewer ways to get it wrong. Chaining both is pointless; the later weak-branch node replaces the earlier one.

Cost, and where it shines

The extra pass is real: with CFG you're already running two forward passes per step, and this makes three. On a 30-step SDXL render that's a ~50% time increase. Worth it when guidance is the thing limiting your quality - texture, skin, small-object detail - and not worth it as a default.

On Anima it's one of the two recommended weak branches (STG being the other). PAG and the attention-temperature variant can't run there at all: those blocks only accept patches on the attention inputs, so replacing or re-scaling the attention output has nowhere to land, and the node stops with an error message pointing you here. Checkpoints in the SD 1.5 and SDXL lineage take all four.

Install

Manager → search CFG Megapack → install, restart. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/AbstractEyes/comfy-cfg-megapack

Nothing to install afterwards, no weights, no key. It needs a current ComfyUI (built on comfy_api.latest; the README reports 0.38.0), so on an older build the pack won't import and no amount of restarting fixes it.

Where people get burned

Nothing changes. Two candidates. First, the shared CFG-function slot: another pack's RescaleCFG, Mahiro or RenormCFG node chained after this one silently wins. Second, you also chained another weak-branch node later in the graph, which replaced it. CFG Plan Readout shows which stages are live.

blur_sigma 10 feels like a no-op. Ten latent pixels is a modest blur on a 1024 image. Push it to 20–40 if you want a visible effect; the useful range on SDXL is much wider than the default suggests.

Using it on a model that's already CFG-sensitive at cfg 9. SEG adds guidance on top; at high cfg on Pony or Illustrious-family checkpoints you're compounding saturation. Drop the sampler's cfg to 4–6 when you turn SEG on, as the pack's own recipe table suggests (SEG or PAG at scale 1.5–3 on top of cfg 4–7).

Expecting it to fix hands. It improves texture and coherence around edges. It does not know what a hand is.

CategoryCFG Megapack/papers/weak branch (a degraded pass of the model itself)

Inputs (4)

NameTypeDefaultDescription
modelMODEL—
scaleFLOAT3.00–20Strength s (paper 3).
blur_sigmaFLOAT10.00.1–100Blur in tokens (100 = infinite: every query is the mean).
blocksCOMBOmiddle (PAG / SEG default)Which self-attention blocks are perturbed (SDXL names; the middle block exists on SD1.5 too). On Anima and other Cosmos-Predict2 transformers: middle = the two middle blocks, deep input = the first third, deep output = the last third.

Outputs (1)

NameTypeDescription
MODELMODEL—