Nodes/ComfyUI-DiffAid-Patches/SDXL Diff-Aid Cross-Attention Patch
ComfyUI Node

SDXL Diff-Aid Cross-Attention Patch

Teaching an SDXL U-Net to actually listen

By xmarre·Created 5 months ago·Updated 23 days ago· 17
SDXL Diff-Aid Cross-Attention Patch
  • model
  • model
  • summary
enabledtrue
stage_filterall
block_targets
strength0.35
sigma_start0.000
sigma_end1.000
sigma_ramp0.000
token_weight_modelinear
token_tail0.35
cond_onlytrue

SDXL still refuses to die, and part of why is that it's now the test bench for ideas that didn't exist when it shipped. This node is exactly that: an SDXL port of the Diff-Aid trick, bolted onto a model architecture the paper never considered. The Diff-Aid paper (arXiv:2602.13585) works on rectified text-to-image diffusion transformers - FLUX, SD 3.5 - where you can patch individual transformer blocks. SDXL is a cross-attention U-Net from a different era. No double_blocks to reach into, so the hook point becomes the UNet's cross-attention path itself. That makes this the most explicit "architectural adaptation" of the three nodes in the pack, and the author labels it as such rather than pretending it reproduces paper numbers.

The pitch, though, is the same one that makes the whole pack interesting: instead of one global conditioning strength, selectively boost the text interaction where it matters. On SDXL the lever is the attn2 cross-attention - the place where text context actually meets image features. The node installs an attn2 patch and modulates the conditioning tensors (context_attn2, and value_attn2 when shape-compatible) before the attention op runs: c' = c + c × α.

The inputs that matter

  • stage_filter - all (default), or restrict to input, middle, or output stages of the U-Net. Start at all; narrow down only if something misbehaves.
  • block_targets - an empty string means "everywhere the filter allows". If you want surgical placement, you can target specific blocks, and this is where the node gets quietly clever: input:4, middle:0, output:7 hits named blocks, and output:7:1 reaches into the specific transformer inside a spatial transformer.
  • strength - default 0.35, but the author's own advice for SDXL is linear token weighting at lower strength. His release-thread take: for SDXL, token_weight_mode linear and a modest strength beat the higher-strength approach he used for Flux. Start around 0.20–0.35.
  • sigma_start / sigma_end / sigma_ramp - the shared normalized window; keep the full range until you've seen what uniform does.
  • cond_only - on by default, and on is right; it keeps the modulation off the negative/unconditional rows.

Outputs are a patched MODEL and a summary STRING that echoes back your targets and settings - handy for confirming you actually hit the block you meant to hit.

Install

Nothing special, which is the nice part of this pack: no pip dependencies, no model downloads, no weights to fetch. Either grab it in ComfyUI Manager under ComfyUI-DiffAid-Patches or:

cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-DiffAid-Patches

Restart ComfyUI and it'll be in the model_patches/diffaid category. You need a ComfyUI build that has attention patch hooks - current installs all do.

Where people get burned

Wrong-model errors, mostly. It refuses to run on anything that isn't an SDXL-style cross-attention U-Net (the error message says as much), and it won't behave like the paper's SD 3.5 implementation no matter how you set it. One genuinely useful data point from the author's thread: SD 1.5's architecture is similar enough to SDXL that he suggested trying the same node there. And if someone asks whether it works on Z-Image - the author's own answer was "probably crash, but feel free to test it". That's the honest version of "not built for that". Because this is a from-scratch port of a principle rather than a validated method, your results will swing with the checkpoint, the LoRAs on top, and the seed. Keep the strength low, compare against an unpatched baseline, and treat it as a seasoning dial rather than a quality guarantee.

Categorymodel_patches/diffaid

Inputs (11)

NameTypeDefaultDescription
modelMODEL
enabledBOOLEANtrue
stage_filterCOMBOall4 options: all, input, middle, output
block_targetsSTRING
strengthFLOAT0.35-1–1
sigma_startFLOAT0.0000–1
sigma_endFLOAT1.0000–1
sigma_rampFLOAT0.0000–0.5
token_weight_modeCOMBOlinear3 options: none, linear, exponential
token_tailFLOAT0.350–1
cond_onlyBOOLEANtrue

Outputs (2)

NameTypeDescription
modelMODEL
summarySTRING