Conditioning 交叉注意力
Cross-attend one prompt's conditioning against another — with a big asterisk
- conditioning_q
- conditioning_kv
- CONDITIONING
This node takes two conditionings and runs a real cross-attention pass: the first one's token embeddings act as the queries, the second's as the keys and values, and out comes a new conditioning where every token in conditioning A has been rewritten by paying attention to conditioning B. If you squint, it's the same primitive at the heart of ControlNet-style conditioning - one representation conditioned on another's content - applied to prompt embeddings instead of image features.
The controls you actually set:
conditioning_qandconditioning_kv- the two CONDITIONING wires. Q and KV must share the same feature dimension or the node refuses to run.n_heads(default 8) - attention heads. The feature dim must divide evenly by this; with the default 768-dim SD 1.5 embeddings, 8 heads works, and 4/8/16 are the sane choices.add_residual(default on) - whether the output isQ + attention(Q,K,V)(residual on, the useful default) or just the raw attention output.
One nice touch: if the KV conditioning carries an attention_mask, it's honored as a key-padding mask, so masked-out tokens in B genuinely can't be attended to. That's the same convention as this pack's AllOnesMaskGenerator and ConditioningPacker - ones mean "keep," zeros mean "ignore."
Now the asterisk, and it's a big one. The attention layer here is a stock nn.MultiheadAttention with randomly initialized weights and no training. There is no learned mapping, no saved state, nothing. Run it on the same inputs twice and you get the same result (it's deterministic given the seed state), but what it's doing is a random-projection-flavored mix, not a semantically meaningful fusion. If you're expecting "make the style prompt inform the content prompt" to actually work, this will disappoint you on its own.
Where it genuinely earns its keep: as an architectural primitive. This pack's SaveTrainingDataPair stores embedding pairs, and this whole tensor/conditioning family reads like the building blocks of a custom training pipeline. If you're building a graph you plan to train or fine-tune later, or you're experimenting with attention-based conditioning mixing, this is a working, GPU-native primitive with the masks handled. Just don't mistake "it runs and produces a CONDITIONING" for "it learned something." It didn't - yet.
Install
ComfyUI Manager → search comfyui-spawner-nodes → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/spawner1145/comfyui-spawner-nodes
Requirements are minimal (piexif, pypng, xmltodict), no model downloads. The README is a one-liner, the UI labels are Chinese, and the author (spawner1145) is a Chinese-speaking dev known for a Wan2.1 SD extension. The pack works but you're on your own for documentation.
Troubleshooting
- Dimension errors - Q and KV must have equal feature width, and the width must divide by
n_heads. Both errors are explicit in the message. - "无效的 CONDITIONING 对象" - an input isn't a well-formed conditioning (empty list, or not tuples). Bypassed encoders upstream are the usual culprit.
- Results look like noise or barely change - expected: the attention weights are random. This is a scaffold for training or experimentation, not a finished fusion trick.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| conditioning_q | CONDITIONING | — | |
| conditioning_kv | CONDITIONING | — | |
| n_heads | INT | 8 | — |
| add_residual | BOOLEAN | true | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| CONDITIONING | CONDITIONING | — |