Automatic CFG - Attention modifiers tester
Brute-force which attention layer your experiment wants
- join_parameters
- Attention modifier
- Parameters as string
The "Attention modifiers" node lets you aim one eval expression at specific blocks. This one does the same thing, but it cycles through a whole list of blocks as you bump a seed, so you can run one experiment across every candidate layer and see where it does something interesting. It's the difference between asking "does this attention tweak work?" and actually finding where it works.
Mechanically it's trivial: give it a comma-separated list of block IDs per UNet section, and it builds the full sequence (input IDs, then middle, then output), then picks seed % len(sequence). Change the seed by one, the patch moves to the next block. The Parameters as string output even tells you your progress: Progress: 3/11 plus which block is active. Combined with a fixed sampler seed, it's a clean sweep of an attention experiment across the network.
The inputs that matter
- self_attn_mod_eval - the expression to evaluate inside attention, same grammar as the plain modifier node (
q,k,v,extra_optionsin scope). The defaults listed on the node come pre-filled with a reasonable sweep: input4,5,7,8, middle0, output0,1,2,3,4,5- 11 blocks total, so seeds 0–10 cover them all. - seed - which block in the sequence gets patched. This is a block selector, not an RNG: it's only used for
seed % len(sequence). - unet_block_id_input / _middle / _output - the candidate lists per section.
- unet_attn -
attn1,attn2, orboth. - sigma_start / sigma_end - when the patch is active during sampling.
Optional join_parameters chains onto an existing ATTNMOD list, same as the parent node.
Outputs
- Attention modifier (ATTNMOD) - feed into the Preset Loader, Advanced, Excellent attention, or Custom attentions.
- Parameters as string - shows
Progress, the active block, and the expression, so you can log which seed produced which render.
How you'd actually use it
Pick a modifier expression, wire the output into whichever patch node you're testing, fix your sampler seed, and render seeds 0, 1, 2, ... n. Each seed = the same tweak on a different layer. The blocks where the image changes dramatically are the ones worth keeping; the blocks where nothing happens were never listening anyway. It's the honest way to find what a perturbation does instead of guessing from architecture diagrams.
Same two caveats as every node in this family: the eval string is arbitrary code, so write your own and don't paste strangers', and most of these attention ideas were only really explored on SDXL. If a render errors mid-sweep, it's usually an expression that referenced something undefined - the traceback will tell you exactly which block died, which is, in a way, information.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| seed | INT | 00–18446744073709550000 | — |
| sigma_start | FLOAT | 1000.00–10000 | — |
| sigma_end | FLOAT | 0.00–10000 | — |
| self_attn_mod_eval | STRING | — | |
| unet_block_id_input | STRING | 4,5,7,8 | — |
| unet_block_id_middle | STRING | 0 | — |
| unet_block_id_output | STRING | 0,1,2,3,4,5 | — |
| unet_attn | COMBO | 3 options: attn1, attn2, both | |
| join_parametersopt | ATTNMOD | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Attention modifier | ATTNMOD | — |
| Parameters as string | STRING | — |