Nodes/ComfyUI/Self-Attention Guidance
ComfyUI Node Runs on cloud

Self-Attention Guidance

Detail without the CFG burn

By Comfy-Org·Created 4 years ago·Updated 7 minutes ago· 129,953
Self-Attention Guidance
  • model
  • MODEL
scale0.50
blur_sigma2.0

Self-Attention Guidance - SAG to its friends - is one of the oldest nodes in the experimental category, arriving in ComfyUI around late 2023, and it's the classic answer to a classic dilemma: your image is too soft at CFG 7, and the moment you raise CFG to sharpen it, everything starts looking like it's been through a deep fryer. SAG adds real detail without touching the CFG dial, by deriving its guidance from the model's own attention rather than from prompt distance.

The idea. SAG comes from a 2022 paper (Hong et al., "Self-attention Guidance," arXiv 2210.00939, NeurIPS 2023). During the unconditional pass, it records the self-attention map from the UNet's middle block - the map that shows which image regions the model is paying attention to. It then builds a deliberately degraded version of the image: blur the regions the model cares about most, keep the rest. Then it runs the model on that adversarially-blurred image and uses the difference to push the final prediction back toward detail. The result behaves like extra guidance, but the direction comes from the image's own structure, not from the gap between your positive and negative prompts. That's why it sharpens without the saturation blowout.

Inputs and output.

  • model - your checkpoint, patched. Output is a MODEL that goes into the KSampler.
  • scale (default 0.5, range −2 to 5) - how strongly to push toward detail. Above roughly 1 it starts to overshoot and you get artifacts; negative values invert the effect, which is a party trick more than a technique.
  • blur_sigma (default 2.0, range 0–10) - the standard deviation of the Gaussian blur used to build the degraded image. Larger sigma = more aggressively degraded reference = stronger contrast against the sharp output.

When it's worth it. SAG genuinely helped on SD 1.5 and SDXL-era models at moderate CFG, where it was a favorite for adding sharpness to faces and texture. On the guidance-distilled, flow-matching models that dominate 2026 - the ones that run at CFG 1 by design - it's mostly irrelevant: it needs an unconditional pass to record attention from, and at CFG 1 that pass isn't computed. The node even forces disable_cfg1_optimization on, meaning it makes the sampler run the unconditional pass it was skipping, which quietly costs you the CFG-1 speed win.

Gotchas. The attention map is captured from a single UNet call - the source code has a standing TODO about chunked batches - so with batched generation, SAG doesn't reliably apply to every item in the batch. Stacking it with other post-CFG patchers (Mahiro, FreSca) works but nobody's vouching for the combination; test on a fixed seed. And because it forces the unconditional pass, it's slower than plain CFG 1 generation on modern models - a real cost for a feature most 2026 checkpoints don't need.

The honest take: if you still run SDXL-lineage checkpoints at CFG 5–9 and your renders want more crispness, SAG is worth a seed test. If you live on CFG-1 flow-matching models, you can skip it without missing much. It's a well-aged tool for an architecture that's increasingly in the rearview mirror.

Ships with ComfyUI core. Search "Self-Attention Guidance" or "SAG" to add it; no install.

Categoryexperimental

Inputs (3)

NameTypeDefaultDescription
modelMODEL
scaleFLOAT0.50-2–5
blur_sigmaFLOAT2.00–10

Outputs (1)

NameTypeDescription
MODELMODEL