Nodes/ComfyUI-Apt_Preset/IPA_XL_PromptInjection
ComfyUI Node

IPA_XL_PromptInjection

Feed different conditioning into different SDXL attention blocks

By cardenluo·Created 2 years ago·Updated 21 days ago· 309
IPA_XL_PromptInjection
  • model
  • all
  • input_4
  • input_5
  • input_7
  • input_8
  • middle_0
  • output_0
  • output_1
  • output_2
  • output_3
  • output_4
  • output_5
  • MODEL
weight1.00
start_at0.000
end_at1.000
noise0.00

This is a genuinely advanced, SDXL-specific node, and it's worth being upfront about that: it isn't for wiring positive/negative prompts the normal way. It patches conditioning directly into individual cross-attention blocks inside the SDXL U-Net, which is a technique from the IP-Adapter world usually described as block-level (or "layer") weighting - pushing different image or text conditioning into different depths of the network instead of applying one prompt uniformly across the whole model.

How it works

Look at the optional inputs and the shape gives it away: input_4, input_5, input_7, input_8, middle_0, and output_0 through output_5 are all CONDITIONING slots, named after SDXL's actual internal attention block indices rather than anything workflow-facing like "positive" or "negative." There's also a catch-all all slot. Instead of returning modified conditioning, the node outputs a MODEL - meaning whatever you feed into these block-specific slots gets patched into the model's forward pass at that layer, not routed through your sampler's usual conditioning inputs. weight (default 1, range -2 to 5), start_at/end_at (the step-range the injection is active for), and noise (default 0) round out the controls, and they match the parameter set on the well-known IPAdapter Advanced node closely enough that this is clearly built in that lineage.

The practical use case for per-block conditioning injection is finer control than a single IP-Adapter weight gives you - for example, letting a style reference dominate the earlier/coarser blocks while your text prompt keeps more influence in the later/fine-detail blocks, or the reverse. It's a real, if niche, technique - but getting the block map right is closer to copying a known-good template than reasoning it out from scratch, which is exactly why this section is short on specifics: block-by-block SDXL attention behavior isn't something to guess your way through.

Inputs and outputs

  • model (required, MODEL) - the SDXL model to patch.
  • all, input_4, input_5, input_7, input_8, middle_0, output_0output_5 (all optional CONDITIONING) - per-block injection points; leave unused ones disconnected.
  • weight, start_at, end_at, noise - strength, step range, and noise controls, matching standard IP-Adapter Advanced conventions.

One output: MODEL - the patched model, wired straight into your KSampler in place of the original.

How to install it

ComfyUI Manager → search ComfyUI-Apt_Preset, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git

then run install.bat for dependencies (Windows-only - on Linux/macOS run its pip install lines by hand) and restart ComfyUI.

Common issues & troubleshooting

This is SDXL-only. The block numbering is specific to SDXL's U-Net architecture - don't expect this to do anything sensible on SD 1.5, Flux, or other architectures with a different internal block layout.

Nothing seems to change. If you connect conditioning to a block slot and see no effect, check weight isn't at zero and that start_at/end_at actually cover the sampling steps you're using - a narrow or zero-width step range means the injection is only active for a sliver (or none) of the generation.

This is worth reaching for only if you already know why you'd want per-block control. For the ordinary "reference image influences the output" case, this pack's simpler IPA_clip_vision feeding a standard IP-Adapter apply node is the more direct path - save this node for when you've specifically hit the ceiling of uniform-weight IP-Adapter and need finer control over which layers a reference affects.

IMPORT FAILED on startup. This pack has at least one reported import failure in the wild on a stock install, generally traced to skipping install.bat's dependency step - which has to be run by hand off Windows. Check the console for the actual missing package before reinstalling.

CategoryApt_Preset/chx_tool/chx_IPA

Inputs (17)

NameTypeDefaultDescription
modelMODEL
alloptCONDITIONING
input_4optCONDITIONING
input_5optCONDITIONING
input_7optCONDITIONING
input_8optCONDITIONING
middle_0optCONDITIONING
output_0optCONDITIONING
output_1optCONDITIONING
output_2optCONDITIONING
output_3optCONDITIONING
output_4optCONDITIONING
output_5optCONDITIONING
weightoptFLOAT1.00-2–5
start_atoptFLOAT0.0000–1
end_atoptFLOAT1.0000–1
noiseoptFLOAT0.00-5–5

Outputs (1)

NameTypeDescription
MODELMODEL