Prompt Relay Encode
Per-segment prompts for Wan video, blended at the attention level
- model
- clip
- latent
- wan_model
- wan_t5
- relay_options
- model
- positive
- wan_model
- wan_text_embeds
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 alatentwhose 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-formsmart_promptthat the node auto-parses (|separated orScene 1: ...blocks).normalize_by_tokensscales 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_modelfrom WanVideoModelLoader and awan_t5text encoder, withlatent_frames(computed as(pixel_frames-1)//4 + 1), anegative_promptencoded once, and anencode_devicetoggle 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.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| backend | COMBO | native | native = MODEL+CLIP; smart = MODEL+CLIP with auto-segmented prompt; kijai = WanVideoWrapper. |
| global_prompt | STRING | Persistent prompt across the whole video. | |
| epsilon | FLOAT | 0.00100.000001–0.99 | Temporal penalty decay (sharpness of segment boundaries). |
| modelopt | MODEL | native/smart only. | |
| clipopt | CLIP | native/smart only. | |
| latentopt | LATENT | native/smart only — frame count read from shape. | |
| wan_modelopt | WANVIDEOMODEL | kijai only — from WanVideoModelLoader. | |
| wan_t5opt | WANTEXTENCODER | kijai only — from LoadWanVideoT5TextEncoder. | |
| local_promptsopt | STRING | Per-segment prompts separated by '|' (native/kijai). | |
| segment_lengthsopt | STRING | Comma-separated pixel-space frame counts. Empty = equal (native/kijai). | |
| smart_promptopt | STRING | smart only — auto-parsed (`|` or `Scene N:`). | |
| normalize_by_tokensopt | BOOLEAN | false | smart only — scale segment weight by token count. |
| latent_framesopt | INT | 811–10000 | kijai only — (pixel_frames-1)//4 + 1. |
| negative_promptopt | STRING | kijai only — encoded once for negative_prompt_embeds. | |
| encode_deviceopt | COMBO | gpu | kijai only — device for T5 encode. |
| relay_optionsopt | RELAY_OPTIONS | Optional Prompt Relay Advanced Options bundle. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |
| positive | CONDITIONING | — |
| wan_model | WANVIDEOMODEL | — |
| wan_text_embeds | WANVIDEOTEXTEMBEDS | — |