Nodes/RES4LYF/CrossAttn_EraseReplace_HiDream
ComfyUI Node Runs on cloud

CrossAttn_EraseReplace_HiDream

Erase and replace concepts in HiDream's two text encoders

By ClownsharkBatwing·Created 2 years ago·Updated 18 days ago· 1,222
CrossAttn_EraseReplace_HiDream
  • clip
  • positive
  • negative
t5xxl_erase
llama_erase
t5xxl_replace
llama_replace
t5xxl_erase_token
llama_erase_token
t5xxl_replace_token
llama_replace_token

HiDream is unusual among current models in that it conditions on two separate text encoders at once - T5-XXL and Llama-3.1-8B-Instruct - rather than one, or one CLIP/T5 pair. That's a genuinely different conditioning surface, and this node is built specifically for it: instead of just rewriting your prompt text and re-encoding, it lets you edit each encoder's conditioning directly, telling it what to erase and what to replace it with, encoder by encoder. It's not in the README and there's no prose write-up of it anywhere in the pack - what follows is read from the parameter names and HiDream's known dual-encoder architecture, so treat the mechanics as inferred rather than confirmed.

How it works

Text-to-image concept erasure and replacement is usually done at the embedding or attention level rather than by re-prompting, because it lets you target a specific concept's influence without re-running the whole encoder on new text. This node gives you that control twice over - once for the T5-XXL side, once for the Llama side - because HiDream needs both edited consistently for the change to actually take. For each encoder you get a phrase-level pair (erase this, replace it with this) and a token-level pair for finer targeting than a whole phrase.

The inputs and outputs that matter

All nine inputs are required:

  • clip (CLIP) - HiDream's encoder bundle, same as you'd wire into a normal text-encode node.
  • t5xxl_erase / t5xxl_replace (STRING, multiline) - the phrase to erase and what to replace it with, on the T5-XXL side.
  • llama_erase / llama_replace (STRING, multiline) - the same pair, but for the Llama-3.1 encoder.
  • t5xxl_erase_token / t5xxl_replace_token (STRING, multiline) - token-level targeting for the T5-XXL side, for when you need to be more precise than a whole phrase.
  • llama_erase_token / llama_replace_token (STRING, multiline) - the same, for Llama.

Outputs: positive and negative (both CONDITIONING) - the node hands back a full pair, ready to wire straight into your sampler's two conditioning slots.

How to install it

Via ComfyUI Manager, search "RES4LYF". Or:

cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

then restart. Nothing extra to download for this node specifically, but remember HiDream itself is a heavy setup - a 17B transformer plus two resident text encoders - so treat the usual HiDream VRAM/quantization considerations as still in play here; this node doesn't change that footprint.

Common issues & troubleshooting

T5-XXL and Llama don't necessarily "see" the same phrase the same way. They're different architectures with different tokenization, so an erase term that works cleanly on one side may not land the same way on the other. If the effect seems partial, check both the T5 and Llama fields rather than assuming the phrase-level text alone is enough.

If you only want to touch one encoder, the fields for the other appear safe to leave blank - nothing in the schema suggests both sides are mandatory in practice, just that the node exposes both. If you're not seeing that behavior, that's worth flagging back to the pack rather than assuming your workflow is wrong.

This is genuinely advanced, model-specific tooling. If you're new to HiDream or to conditioning editing in general, get a plain HiDream workflow running first - this node only makes sense once you already understand what's in the conditioning you're trying to erase and replace.

Categoryadvanced/conditioning

Inputs (9)

NameTypeDefaultDescription
clipCLIP
t5xxl_eraseSTRING
llama_eraseSTRING
t5xxl_replaceSTRING
llama_replaceSTRING
t5xxl_erase_tokenSTRING
llama_erase_tokenSTRING
t5xxl_replace_tokenSTRING
llama_replace_tokenSTRING

Outputs (2)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING