Nodes/advanced-cfg-controller/πŸ’ͺ Attention Modifier Bruteforce
ComfyUI Node

πŸ’ͺ Attention Modifier Bruteforce

Brute-force which layer does what

By FlareAI-StudiosΒ·Created 8 months agoΒ·Updated 8 months agoΒ· 1
πŸ’ͺ Attention Modifier Bruteforce
  • join_parameters
  • Attention modifier
  • Parameters as string
β—„seed0β–Ί
β—„sigma_start1000.0β–Ί
β—„sigma_end0.0β–Ί
β—„self_attn_mod_evalβ€”β–Ί
β—„unet_block_id_inputβ€”β–Ί
β—„unet_block_id_middleβ€”β–Ί
β—„unet_block_id_outputβ€”β–Ί
β—„unet_attnBoth Attention Typesβ–Ί

The hardest part of the pack's attention modifiers isn't writing the expression - it's finding which UNet block to aim it at. There are dozens of them, they're numbered confusingly, and every checkpoint reacts differently. Attention Modifier Bruteforce is the pack's answer to that: instead of making you pick a block, it cycles through a list of blocks for you, driven by the seed. Change the seed, get a different block; iterate until one of them does what you want.

How the cycling works

You give it three comma-separated lists - unet_block_id_input, unet_block_id_middle, and unet_block_id_output (defaults like 4,5,7,8 / 0 / 0,1,2,3,4,5). The node flattens them into one sequence - all the input blocks, then middle, then output - and picks one entry using seed % len(sequence). So seed 0 targets the first block, seed 1 the second, and so on. Same seed, same block: deterministic, which is the whole point when you're A/B testing generations.

That's what "bruteforce" means here - it's not a clever search, it's a controlled rotation. Bump the seed by one, regenerate, and compare. The Parameters as string output even tells you your progress: Progress: 3/12 plus which block is currently selected. When you land on a block that produces the effect you want, note the seed, then take the same settings over to Attention Modifier Parameters to lock it in without the rotation.

The other inputs

The rest is shared with the sibling modifier nodes:

  • self_attn_mod_eval - the Python expression for the attention modification (default attnopt).
  • sigma_start / sigma_end - the sigma window where the patch is live (defaults 1000 β†’ 0 = whole run).
  • unet_attn - Self-Attention Only, Cross-Attention Only, or Both.
  • join_parameters (optional) - chain this onto an existing ATTNMOD wire.

Outputs: the Attention modifier (ATTNMOD wire) and the Parameters as string.

Where it fits and what to watch

Like every modifier in this pack, it does nothing on its own - the ATTNMOD output has to feed the Advanced CFG Controller (Expert) node's attention_modifiers_positive (or _negative/_global) input to be applied. The standard flow: Bruteforce β†’ (Concat if you're stacking) β†’ Expert.

Two honest warnings. First, the "cycling" is per-wire, not per-generate - the node picks one block and sticks with it for that run, so to actually scan blocks you regenerate with a new seed each time. Second, this whole attention-modifier subsystem is the newest, least-tested part of a pack that already has no community footprint. In this early build the expression field is treated more as a backend selector than a full eval, so keep the Parameters string visible and sanity-check that the block you think you're patching is the one in the payload. Treat it as a tinkering tool with training wheels - the training wheels being the seed, which is the one knob that can't break anything.

Categorymodel_patches/Advanced_CFG_Controller/attention_modifiers

Inputs (9)

NameTypeDefaultDescription
seedINT00–18446744073709550000Seed for selecting which attention block to modify
sigma_startFLOAT1000.00–10000Start applying attention modifications at this sigma level
sigma_endFLOAT0.00–10000Stop applying attention modifications at this sigma level
self_attn_mod_evalSTRINGPython expression for attention modification
unet_block_id_inputSTRINGInput block IDs to cycle through (comma-separated)
unet_block_id_middleSTRINGMiddle block IDs to cycle through (comma-separated)
unet_block_id_outputSTRINGOutput block IDs to cycle through (comma-separated)
unet_attnCOMBOBoth Attention TypesWhich attention layers to modify
join_parametersoptATTNMODChain multiple attention modifiers together

Outputs (2)

NameTypeDescription
Attention modifierATTNMODβ€”
Parameters as stringSTRINGβ€”