Token Perturbation Guidance
PAG's idea, one token at a time
- model
- MODEL
PAG perturbs self-attention wholesale - swap the attention map for something degraded, guide away from it. Token Perturbation Guidance, from the paper of the same name, works at a finer grain: it perturbs at the token level rather than disrupting a whole attention map at once. Same family of trick as everything else in this pack - build a deliberately worse prediction and guide away from it - but a more surgical version of how that degraded prediction gets made.
The most distinctive thing about this node isn't a mechanism detail, though - it's that it ships with an actual opinionated default for where it applies, unlike most of its siblings.
The inputs that matter
scale(default 3) - standard guidance strength, same as elsewhere in the pack.sigma_start/sigma_end(both -1) - restrict TPG to a noise window; -1/-1 runs it the whole denoise.rescale/rescale_mode(0 /full) - the same anti-oversaturation valve used by PAG and SEG.- Optional
unet_block_list- and this is the field to pay attention to. Its default isn't empty or "all blocks" - it'sd2.2-9,d3, a specific, narrow slice of the UNet's input blocks. Unlike PAG or SEG, TPG doesn't give you separateunet_block/unet_block_iddropdown fields - this string is the only way to control where it applies, and it comes pre-loaded with the author's own recommended target rather than defaulting to "everything" or "middle only."
Output is a MODEL, wired into your KSampler as usual.
How to install it
ComfyUI Manager: search "Perturbed-Attention Guidance" - TPG ships inside that pack. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/pamparamm/sd-perturbed-attention
Restart. No models to fetch, no extra dependencies.
Common issues & troubleshooting
This is one of the newer, quieter additions to the pack - essentially no community usage trail yet, so treat what follows as grounded reasoning about the schema rather than field-tested advice.
Trying to change where TPG applies and not finding the usual dropdown. There isn't one on this node - unet_block and unet_block_id don't exist here the way they do on PAG and SEG. unet_block_list is the only lever, and if you want the "just target the middle block" behavior those other nodes default to, you'll need to type it explicitly (m0) rather than expect it out of the box - TPG's own default already points somewhere specific (d2.2-9,d3), not at middle.
Wondering why the default block target looks so oddly specific. It is specific on purpose - d2.2-9,d3 targets particular input-block sub-indices rather than a broad sweep, which suggests the author tuned this against those blocks specifically rather than leaving a generic default. If you override it, it's worth A/B-ing against the stock default before assuming your custom target is actually better.
Oversaturated output at higher scale. Same fix as the rest of the pack: enable rescale (start around 0.5–0.7) or try rescale_mode: snf for high-guidance-scale stability.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| scale | FLOAT | 3.00–100 | — |
| sigma_start | FLOAT | -1.00-1–10000 | — |
| sigma_end | FLOAT | -1.00-1–10000 | — |
| rescale | FLOAT | 0.000–1 | — |
| rescale_mode | COMBO | full | 3 options: full, partial, snf |
| unet_block_listopt | STRING | d2.2-9,d3 | Blocks to which TPG is applied. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |