Nodes/Prompt Injection Node for ComfyUI/Attn2 Prompt Injection (advanced)
ComfyUI Node

Attn2 Prompt Injection (advanced)

A block list with per-block weights

By DataCTE·Created 2 years ago·Updated about a year ago· 100
Attn2 Prompt Injection (advanced)
  • model
  • conditioning
  • MODEL
locationsoutput:0,1.0 output:1,1.0
start_at0.000
end_at1.000

"Attn2 Prompt Injection (advanced)" looks backwards at first: instead of a wall of conditioning ports, you get one text box. But that's the point. Where the simple node does one block and the big node gives you per-block ports, this one is "one conditioning prompt, any number of blocks, each with its own weight" - and you express it as a list. It's the compact one.

How it works

The locations input is a multiline string where each line is block,weight. The default is:

output:0,1.0
output:1,1.0

One conditioning input feeds every line, and each block gets patched with the weight written next to it. Under the hood it's the same build_patch / set_model_attn2_patch mechanism as the rest of the pack - the node parses your list and installs one patch per line.

So the pattern this node exists for is "give this one prompt to several blocks, at different strengths." Say you found a subject that only lives in the output blocks: hit output:0 through output:4 at gradually decreasing weights.

output:0,1.2
output:1,1.1
output:2,1.0
output:3,0.9
output:4,0.8

You could build that with the multi-port node plus a weight node per input. This is less wiring, and it reads like a config file, which is nice when you're iterating on a workflow.

Inputs and outputs

  • model (required).
  • locations (multiline STRING) - block,weight per line. Any of the eleven SDXL text-attention blocks: input:4/5/7/8, middle:0, output:0 through output:5. If a line has no comma, weight defaults to 1.0.
  • conditioning - the single prompt to inject into all listed blocks.
  • start_at / end_at - the denoise window, same as the rest of the pack.

Output: a patched MODEL for your KSampler.

Note there's no weight widget on this node. If you go hunting for a weight input, it's per-line in the string, not a float. Easy thing to look for and not find.

Installing

Same as every node in this pack. ComfyUI Manager → search "Prompt Injection", or:

cd ComfyUI/custom_nodes
git clone https://github.com/DataCTE/prompt_injection

Restart ComfyUI. No dependencies beyond what ComfyUI already has, no model files.

Gotchas

  • Blank locations or no conditioning = silent passthrough, no error. Make sure the text box actually has lines in it.
  • If you mistype a block name (output:O instead of output:0), it never matches anything and does nothing - there's no validation. The parser is one split-on-comma; it trusts you.
  • One conditioning and one start/end window for the whole node. If you need different prompts in different blocks, this is the wrong node - that's what the multi-port "Attn2 Prompt Injection" is for.
  • Still SDXL-lineage only; unknown block names mean it silently no-ops on other architectures.
Categoryadvanced/model

Inputs (5)

NameTypeDefaultDescription
modelMODEL
locationsoptSTRINGoutput:0,1.0 output:1,1.0
conditioningoptCONDITIONING
start_atoptFLOAT0.0000–1
end_atoptFLOAT1.0000–1

Outputs (1)

NameTypeDescription
MODELMODEL