Nodes/Negative-attention-for-ComfyUI-/Negative cross attention concatenate
ComfyUI Node

Negative cross attention concatenate

The conditioning smuggler that sneaks your negative prompt into the positive

By Extraltodeus·Created 2 years ago·Updated about a year ago· 9
Negative cross attention concatenate
  • positive
  • negative
  • empty
  • Positive
  • Negative
concat_mode
negative_out

What it's for

This is the quieter half of Extraltodeus's Negative-attention pack, and on its own it looks pointless: it takes your positive and negative CONDITIONING and concatenates them into one long tensor. By itself that's a worse positive prompt - your image prompt now literally contains the tokens you're trying to avoid. The trick only pays off because the pack's other node, "Negative cross attention," splits the combined tensor in half and subtracts the negative half inside the attention math. Think of this node as the smuggler, and that one as the border guard.

The inputs that matter

Four required, one optional:

  • positive / negative (CONDITIONING): straight from your two CLIP Text Encode nodes.
  • concat_mode: what to do when the positive and negative aren't the same token length (weighted prompts, long negatives). crop_to_shortest cuts both down - the safe default for a first run. prolongate_to_longest_by_loop loops the shorter one to match. prolongate_to_longest_with_empty_or_0 pads with the empty conditioning, or with zeros if you don't supply one.
  • negative_out: what the Negative output carries. empty_or_0 gives a genuinely empty/unconditional negative - which is the whole point of the pack, so the sampler's unconditional pass stays truly unconditional while the negative's real content is applied inside attention. invert swaps the halves so the negative branch also sees pos+neg - the "doubling down" mode the author warns produces overblown results. crop_to_77_tokens just passes your original negative, cropped.
  • empty (CONDITIONING, optional): an empty-prompt conditioning, used for padding in the third concat mode and as the empty_or_0 negative.

The outputs

Two CONDITIONING outputs, and the wiring is short:

  • Positive → the KSampler's positive input.
  • Negative → the KSampler's negative input.

With the patcher upstream: Load Checkpoint → Negative cross attention (model), the two CLIP encodes → this node, then both outputs into the sampler.

Installing it

Same pack, same install - you get both nodes in one go. ComfyUI Manager: search "Negative-attention-for-ComfyUI-". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Extraltodeus/Negative-attention-for-ComfyUI-

Restart ComfyUI. No requirements.txt, no model downloads, nothing extra to configure.

Gotchas

  • It's a matched pair. Run it without the "Negative cross attention" patcher and the negative tokens just sit inside your positive conditioning - worse prompts, not better.
  • Very short prompts can silently kill the effect. With crop_to_shortest and terse prompts, the combined tensor can shrink under 77 tokens, at which point the patcher's split falls back to plain attention. Keep both prompts reasonably populated.
  • SDXL / SD 1.x only, by design. The pack is an experiment and explicitly doesn't support Flux.

This is the node doing all the plumbing, so it's the one with zero search impressions while its flashier sibling gets all the clicks. If a shared workflow has it, that's exactly why it's there.

Categorymodel_patches/negative attention

Inputs (5)

NameTypeDefaultDescription
positiveCONDITIONING
negativeCONDITIONING
concat_modeCOMBO3 options: crop_to_shortest, prolongate_to_longest_by_loop, prolongate_to_longest_with_empty_or_0
negative_outCOMBO3 options: empty_or_0, invert, crop_to_77_tokens
emptyoptCONDITIONING

Outputs (2)

NameTypeDescription
PositiveCONDITIONING
NegativeCONDITIONING