Nodes/sd-perturbed-attention/Sliding Window Guidance (Advanced)
ComfyUI Node

Sliding Window Guidance (Advanced)

Tile-based guidance for large images

By pamparamm·Created 2 years ago·Updated 5 months ago· 299
Sliding Window Guidance (Advanced)
  • model
  • MODEL
scale5.0
tile_width768
tile_height768
tile_overlap256
sigma_start-1.00
sigma_end5.42

Most of the guidance nodes in this pack work on the whole latent at once. Sliding Window Guidance doesn't - it's built from "The Unreasonable Effectiveness of Guidance for Diffusion Models" (Kaiser et al.), and true to the name, it computes guidance over tiled windows of the image rather than globally. That's the same basic idea as tiled VAE decoding or tiled upscaling, but applied to the guidance computation itself, which is a different problem: local guidance can pick up on structure a single global pass would average away, at the cost of needing overlap to avoid seams between tiles.

The inputs that matter

  • scale (default 5) - guidance strength, same role as everywhere else in this pack.
  • tile_width / tile_height (both default 768, range 16–16384 in steps of 8) - the window size guidance operates over. Keep these multiples of 8 like any other latent-dimension field in ComfyUI.
  • tile_overlap (default 256) - how much adjacent tiles overlap, which is what keeps the seams between windows from showing up in the output. Note it's a full third of the default tile size, which tells you the author didn't consider that overlap optional.
  • sigma_start / sigma_end - this is the one place in the pack where the defaults are asymmetric and worth reading carefully: sigma_start defaults to -1 (unbounded, so guidance is active from the very first, noisiest step), while sigma_end defaults to a real value, 5.42. In practice that means SWG is front-loaded out of the box - active through the early, high-noise portion of the sampler and switched off once sigma drops to 5.42, rather than running the whole denoise like PAG or NAG do by default.

Output is a MODEL to plug into your KSampler.

How to install it

ComfyUI Manager: search "Perturbed-Attention Guidance" - this node lives in that pack. Manually:

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

Restart afterward. No models to fetch, no extra dependencies.

Common issues & troubleshooting

This is another of the newer, less-discussed nodes in the pack - there's no accumulated forum wisdom to draw on yet, so take the following as reasoning from how tiled processing generally behaves rather than confirmed community fixes.

Visible seams or repeating patterns at tile boundaries. The classic tiled-processing artifact. tile_overlap is your first lever - raise it before touching anything else. The default (256 against a 768 tile) is already generous, but if your tile_width/tile_height are much larger or smaller than default, scale the overlap proportionally rather than leaving it fixed.

No visible effect. Check the sigma window first - since sigma_end defaults to a real 5.42 rather than -1, SWG is off for the back half of sampling by default. If you expected it to shape the whole render, you'll need to lower sigma_end (or set both to -1) to keep it active longer.

Slow. Smaller tiles mean more of them, which means more guidance computations per step. If speed matters more than local detail, push tile_width/tile_height up before reaching for a lower scale.

Categorymodel_patches/unet

Inputs (7)

NameTypeDefaultDescription
modelMODEL
scaleFLOAT5.00–100
tile_widthINT76816–16384
tile_heightINT76816–16384
tile_overlapINT25616–16384
sigma_startFLOAT-1.00-1–10000
sigma_endFLOAT5.42-1–10000

Outputs (1)

NameTypeDescription
MODELMODEL