Nodes/ComfyUI DenseDiffusion/DenseDiffusion Add Cond
ComfyUI Node

DenseDiffusion Add Cond

The DenseDiffusion Add Cond node, explained

By huchenlei·Created 2 years ago·Updated about a year ago· 161
DenseDiffusion Add Cond
  • model
  • conditioning
  • mask
  • MODEL
strength1.00

If you've ever prompted "a red-haired woman on the left and a blue-haired woman on the right" and watched the model hand both of them the same muddy purple hair, you've met the problem this node exists for. Prompts are global: every token fights for attention across the whole image. DenseDiffusion Add Cond is how this pack lets you declare that this prompt applies to this area only.

It's the per-region building block of the two-node DenseDiffusion system. You make one of these for each region you care about, chain them together, and finish with the pack's other node, DenseDiffusion Apply, which actually enforces the regions during sampling. On its own Add Cond does nothing visible - it's pure setup, which is why ComfyUI lists it under the "DenseDiffusion" category alongside its partner.

What it actually does

Under the hood it clones your model and quietly appends a "regional condition" to the model's internal options: your text conditioning, your mask, and a strength value that scales the mask. Nothing is executed yet. The conditioning keeps the pooled_output from your CLIPTextEncode (more on that below), and the whole record waits in transformer_options until Apply comes along and reads it back.

The mechanism matters because it's not the usual "mask the latent" trick. DenseDiffusion works by manipulating the cross-attention scores - the q@k matrix - before the softmax, so each region's prompt literally cannot draw attention from outside its mask. Regional prompting as a concept is old (Latent Couple, Regional Prompter, Forge Couple), but this is a cleaner, attention-native take on it.

The inputs that matter

Three of them, plus one optional:

  • model - your base model. Chain the output of one Add Cond into the next Add Cond's model input so regions accumulate.
  • conditioning - the output of a CLIPTextEncode holding that region's prompt. One per region.
  • strength (default 1.0, range 0–2) - how hard the region's prompt asserts itself. At 1 it's faithful; push toward 2 if a region keeps bleeding; drop below 1 if you want the borders to blend a little.
  • mask (optional) - the region's mask, from any MASK source. Since the Dec 2024 update, no mask input = a solid full-image mask, i.e. "this prompt applies everywhere," which is only useful when you're stacking several partial regions and want one to be the catch-all background.

The output is a single MODEL, which is what you chain onward.

How to install it

ComfyUI Manager → search "DenseDiffusion" → install, then restart ComfyUI. Or, if you prefer the terminal:

cd ComfyUI/custom_nodes
git clone https://github.com/huchenlei/ComfyUI_densediffusion

Then restart ComfyUI. There are no model downloads and no pip dependencies beyond ComfyUI itself - it's pure node code that rides on ComfyUI's model patching, so install is painless.

Where people get burned

  • It needs pooled_output. The node asserts your conditioning has one. CLIPTextEncode on SDXL and SD 1.5 produces it; newer encoders that don't (or exotic conditioning chains) will throw. This pack is really an SDXL / SD 1.5 tool.
  • The whole chain is pointless without the Apply node. If you add a condition and never apply it, nothing happens. The author's example workflow wires one Add Cond per region (masks pulled from a loaded image), then one Apply, and compares against ComfyUI's stock ConditioningSetMask route - worth loading just to see the difference.
  • It won't stack with IPAdapter. Attention replacements in ComfyUI don't compose, so this regional method and IPAdapter fight. That's a pack-wide limitation, not a bug in this node.
  • Multiple masks are fine. Since late 2024 the node accepts batched masks, so one Add Cond can carry several regions if you pass a single mask with multiple labeled areas.

Worth knowing: the author (huchenlei, a prolific ComfyUI node dev) deliberately implemented the Omost flavor of DenseDiffusion, not the original Naver research version, because the original "does not perform very well" in their testing. You're getting the version people actually use.

CategoryDenseDiffusion

Inputs (4)

NameTypeDefaultDescription
modelMODEL
conditioningCONDITIONING
strengthFLOAT1.000–2
maskoptMASK

Outputs (1)

NameTypeDescription
MODELMODEL