Nodes/ComfyUI-CustomNodePacks/Prompt Relay Encode
ComfyUI Node

Prompt Relay Encode

Per-segment prompts for Wan video, blended at the attention level

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Prompt Relay Encode
  • model
  • clip
  • latent
  • wan_model
  • wan_t5
  • relay_options
  • model
  • positive
  • wan_model
  • wan_text_embeds
backendnative
global_prompt
epsilon0.0010
local_prompts
segment_lengths
smart_prompt
normalize_by_tokensfalse
latent_frames81
negative_prompt
encode_devicegpu

Wan's dirty secret, and every other video model's too: the whole clip gets one prompt. So if your shot is "person walks into frame, lights flicker, camera pushes in," the model has to cram all three beats into a single string and hope the diffusion sorts out when each thing happens. Prompt Relay fixes that by giving each segment of the video its own prompt and smoothly interpolating between them over time - a technique Gordon Chen's Prompt Relay made famous (the thread that turned it mainstream came with a Benji's Playground walkthrough), and this node is the pack's unified port of it.

How the relay actually works

How it actually works is the interesting part, because it's not frame-by-frame re-encoding. Your global_prompt plus your local_prompts (per-segment, separated by |) get tokenized into one combined stream, and the node records where each segment's tokens sit in that stream. Then it patches the model's cross-attention so that at frame N, the attention weight for segment K's tokens is high, and neighboring segments' tokens fade in and out around it - controlled by epsilon (default 0.001), the temporal penalty that sharpens or softens the boundaries between segments. Low epsilon, crisp cuts. The conditioning is one encode, one model, no per-frame recompute. The Wan-ecosystem doc in the KB is a good place to go deeper on why per-segment prompting matters for this model class.

The three backends

The node is a unified encoder with a backend dropdown, and the sockets are dynamic - a JS extension hides the inputs that don't apply to the backend you picked, so the canvas doesn't drown in irrelevant fields:

  • native (default) - works with a plain MODEL + CLIP (and a latent whose shape supplies the frame count). This is the general path.
  • smart - same native machinery, but instead of manually structured local_prompts, you paste a free-form smart_prompt that the node auto-parses (| separated or Scene 1: ... blocks). normalize_by_tokens scales each segment's weight by token count, which keeps a long segment from being under-weighted against a short one.
  • kijai - the WanVideoWrapper path, taking a wan_model from WanVideoModelLoader and a wan_t5 text encoder, with latent_frames (computed as (pixel_frames-1)//4 + 1), a negative_prompt encoded once, and an encode_device toggle for the T5.

The prompts that matter

The global_prompt is the persistent base ("everything in the clip is true the whole time") and local_prompts are the per-segment beats. segment_lengths (comma-separated pixel-space frame counts, empty = equal segments) sets how many frames each segment gets. Outputs: model + positive on the native/smart paths, wan_model + wan_text_embeds on the kijai path - wire them into your sampler as you would the normal encode.

Where people get burned

Where people get burned: a stale workflow with a disconnected input shows up as "arrived as None" errors - the node deliberately refuses to guess, so check your wiring before the video render, which is expensive to fail. And the kijai latent_frames math must match your actual video length or the segments land in the wrong places. Install is the pack: clone Code2Collapse/ComfyUI-CustomNodePacks into custom_nodes or ComfyUI Manager → "CustomNodePacks". For Wan-specific work this is the node that turns a one-prompt video into a scene-directed one - worth the setup.

CategoryComfyUI-CustomNodePacks/PromptRelay

Inputs (16)

NameTypeDefaultDescription
backendCOMBOnativenative = MODEL+CLIP; smart = MODEL+CLIP with auto-segmented prompt; kijai = WanVideoWrapper.
global_promptSTRINGPersistent prompt across the whole video.
epsilonFLOAT0.00100.000001–0.99Temporal penalty decay (sharpness of segment boundaries).
modeloptMODELnative/smart only.
clipoptCLIPnative/smart only.
latentoptLATENTnative/smart only — frame count read from shape.
wan_modeloptWANVIDEOMODELkijai only — from WanVideoModelLoader.
wan_t5optWANTEXTENCODERkijai only — from LoadWanVideoT5TextEncoder.
local_promptsoptSTRINGPer-segment prompts separated by '|' (native/kijai).
segment_lengthsoptSTRINGComma-separated pixel-space frame counts. Empty = equal (native/kijai).
smart_promptoptSTRINGsmart only — auto-parsed (`|` or `Scene N:`).
normalize_by_tokensoptBOOLEANfalsesmart only — scale segment weight by token count.
latent_framesoptINT811–10000kijai only — (pixel_frames-1)//4 + 1.
negative_promptoptSTRINGkijai only — encoded once for negative_prompt_embeds.
encode_deviceoptCOMBOgpukijai only — device for T5 encode.
relay_optionsoptRELAY_OPTIONSOptional Prompt Relay Advanced Options bundle.

Outputs (4)

NameTypeDescription
modelMODEL
positiveCONDITIONING
wan_modelWANVIDEOMODEL
wan_text_embedsWANVIDEOTEXTEMBEDS