CLIPAttentionMultiply
Scaling CLIP attention before it reads your prompt
- clip
- CLIP
CLIPAttentionMultiply is the odd one out in this family of four. The others patch the diffusion model's UNet; this one patches the text encoder. It multiplies the self-attention weights inside the CLIP model by factors you choose, before a single prompt token gets encoded. ComfyUI even lists it under the search aliases "clip attention scale" and "text encoder attention" - which is the clearest hint yet of what it's for.
Text encoders are attention machines too. When your prompt goes through CLIP, every token attends to every other token a stack of times, and the embeddings that come out the far end are the conditioning your sampler later follows. That means the encoder's self-attention shapes how the words relate to each other before diffusion ever runs. This node gives you four knobs on those exact layers. Nudge them and every prompt encoded through that CLIP object changes - the positive and the negative both, since the encoder itself is what's patched, not any one prompt.
How it works
Same clone-and-patch trick as its siblings, just pointed at a different weight layout. It clones the CLIP, walks the state dict, and registers a runtime patch on every key ending self_attn.q_proj, self_attn.k_proj, self_attn.v_proj, or self_attn.out_proj (weights and biases). At inference the patch multiplies those weights by your factor - pure runtime scaling, nothing written back to the model file.
Wire it between the loader and the text encoder:
CLIPLoader → CLIPAttentionMultiply → CLIP Text Encode → Conditioning (→ Sampler)
The output is a patched CLIP, and the CLIP Text Encode node downstream is what uses it. Because the patch lives on the encoder object, every CLIPTextEncode fed from that wire inherits the change.
The knobs
Four floats, 0–10, default 1.0 (identity):
- q - query projection, how each token decides what to look for
- k - key projection, what each token advertises about itself
- v - value projection, what actually gets transferred between tokens
- out - the projection that writes the attended result back into the token stream
The self-attention in an encoder mixes context across your prompt, so the natural experiment is v or out: scale them down and tokens share less context, which tends to flatten long prompts into more independent keywords; scale up and the whole prompt gets blended harder. Values close to 1.0 are the playground; anything past roughly 1.5 or below 0.5 starts producing conditioning that behaves strangely downstream.
Where it falls over
The exact-suffix matching bites here hardest of all. This node speaks self_attn.q_proj - which is the layout of the SD 1.5 / SDXL CLIP encoders - and not the T5 encoder that FLUX ships with (T5 names its attention weights q, k, v, o, no _proj suffix). Feed it a FLUX text encoder and you get a silent no-op: an unchanged CLIP, identical output, no error. Also remember the change is global: it's on the encoder, so it applies to your negative conditioning too, which can interact with CFG in ways you didn't intend. Iterate small, compare against a 1.0 baseline, and don't expect this to be a daily driver - it's an experimental sandbox toy from April 2024 with essentially zero community footprint. That's fine. It's also the cheapest way in ComfyUI to learn what your text encoder is actually doing.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| q | FLOAT | 1.000–10 | — |
| k | FLOAT | 1.000–10 | — |
| v | FLOAT | 1.000–10 | — |
| out | FLOAT | 1.000–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CLIP | CLIP | — |