π― Attention Modifier Parameters
The pack's power tool
- join_parameters
- Attention modifier
- Parameters as string
Most CFG tuning messes with the output of the denoising step. Attention Modifier Parameters goes one level deeper: it patches the attention computation itself, inside specific UNet blocks, for a chosen slice of the denoising run. This is the node family the pack's Advanced CFG Controller (Expert) is built to consume - the "if you really know what you're doing" drawer of the toolbox. LoRA-style thinking, but at the raw attention level, on a per-layer basis.
The idea
Diffusion UNets are stacks of blocks, each with two attention types: attn1 (self-attention - how a region relates to other regions of the image) and attn2 (cross-attention - how the image attends to your prompt tokens). This node hands you the coordinates: which block, which attention type, which part of the sigma range, and a Python expression that replaces how attention is computed there. The default expression attnopt means "run the standard optimized attention." The interesting stuff starts when you mix backends, like the tooltip's attnbc * 0.5 + attnopt * 0.5 - half basic attention, half optimized - to soften or sharpen a specific layer's behavior.
Inputs, the ones that matter:
- self_attn_mod_eval - the Python expression. This is the actual modification; everything else just says where it applies.
- unet_block_id_input / _middle / _output - comma-separated block IDs like
4,5,7,8. Leave a field empty to skip that block group. Finding the right block is the whole game, and it's trial-and-error. - unet_attn - Self-Attention Only, Cross-Attention Only, or Both (which expands into two entries internally).
- sigma_start / sigma_end - when the patch is live. Defaults (1000 β 0) mean the whole run; narrow it to, say, 1000 β 8 to only touch the high-sigma structuring phase.
Outputs are two: the Attention modifier (the pack's custom ATTNMOD wire) and Parameters as string - a readable dump of exactly what got configured. That string output is a lifesaver, because the wire type is opaque; wire the string to a text node when you're iterating.
Where it fits
An ATTNMOD is a list of per-block instruction dicts. The Expert node accepts them on its attention_modifiers_positive, _negative, _fake_negative, and _global inputs; from there it applies each entry via ComfyUI's attention patch_replace mechanism, gated by the sigma window. So the natural pattern is: build one or two of these modifiers, combine them with Attention Modifier Concat if needed, and feed the result into the Expert. You can also chain directly via the optional join_parameters input to stack modifiers into one wire.
Real talk
This is the most experimental corner of an already-young pack. In the shipped code the expression is used to select which attention backend feeds the patch, and the whole sub-system is barely one commit old - expect rough edges, and check the "Parameters as string" output to confirm the expression you typed is actually in the payload. This is not a beginner node; if you're here, you probably came from a Reddit thread about fixing a specific artifact. Change one block at a time, keep the sigma window narrow, and never forget that the Expert node has to be present in the graph for an ATTNMOD to actually do anything. Without a controller to consume it, the modifier just sits there being a very fancy wire.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| sigma_start | FLOAT | 1000.00β10000 | Start applying attention modifications at this sigma level |
| sigma_end | FLOAT | 0.00β10000 | Stop applying attention modifications at this sigma level |
| self_attn_mod_eval | STRING | Python expression for attention modification (e.g., 'attnbc * 0.5 + attnopt * 0.5') | |
| unet_block_id_input | STRING | Input block IDs (comma-separated, e.g., '4,5,7,8') | |
| unet_block_id_middle | STRING | Middle block IDs (comma-separated, e.g., '0') | |
| unet_block_id_output | STRING | Output block IDs (comma-separated, e.g., '0,1,2,3') | |
| unet_attn | COMBO | Both Attention Types | Which attention layers to modify |
| join_parametersopt | ATTNMOD | Chain multiple attention modifiers together |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Attention modifier | ATTNMOD | β |
| Parameters as string | STRING | β |