Nodes/ComfyUI-WanActivationEditor/WanVideo Latent Encoder
ComfyUI Node

WanVideo Latent Encoder

Capture what Wan's blocks actually do to your prompt — in the model's native 5120-dim space

By fblissjr·Created about a year ago·Updated about a year ago· 9
WanVideo Latent Encoder
  • model
  • text_embeds
  • latent_embeds
  • info
capture_after_blocks3
use_cachetrue

Here's the pack's central irony, stated plainly: block injection works - the runtime patch replaces the context in your chosen blocks, confirmed at strength 1.0 - but the measured difference between your two prompts keeps collapsing through the projection layer. So the author built a workaround that's arguably the most interesting idea in the whole pack: instead of fighting the projection, skip it. Grab the embeddings after Wan's own transformer blocks have started processing them, in the model's native 5120-dim space, where the differences the projection flattened still live.

That's this node. WanVideoLatentEncoder runs your text embeddings through the model's text_embedding layer and then through the first N transformer blocks - capture_after_blocks, default 3, range 1–10 - and returns the resulting internal representation as latent_embeds (LATENT_EMBEDS type), plus an info STRING with the shapes, device, and dtype it worked with. Its own use_cache (default on) means the same input embeds won't re-run the forward pass every time - handy, because this node actually executes model blocks, which is real compute.

The output is meant for WanVideoLatentInjector (its main_latent / injection_latent inputs). Encode both your main and injection prompts, feed both latents to the injector, and the injection operates on the model's own evolved representations rather than on the raw text embeddings. The README's claim: should produce much stronger effects, because it "preserves differences that projection destroys."

What it does and doesn't do

Honest framing time. The encoder is genuinely clever, and it does run the model's blocks - but the code tells you it's a simulation of the generation context rather than the literal one: it fakes the video-token hidden states with scaled random noise before stepping the blocks, because it doesn't have your actual latents at text-encode time. So the captured "latents" are the model's response to your prompt in a simulated context, not a capture of the exact states during your real denoising. They're approximations - good approximations, but if you were hoping for a faithful recording of generation internals, adjust expectations.

Install

Pack install as usual, WanVideoWrapper required first:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-WanVideoWrapper   # required first
git clone https://github.com/fblissjr/ComfyUI-WanActivationEditor
cd ComfyUI-WanActivationEditor && pip install -r requirements.txt

Restart ComfyUI (ComfyUI Manager: search "ComfyUI-WanActivationEditor"). Dependencies are torch, numpy, duckdb, zstandard.

If info comes back with an error about block count, you're on a model the block-walker can't find - update WanVideoWrapper. And capture_after_blocks isn't a free lunch: each block you add costs compute and each step re-shapes the representation, so start at 3 and only push it up if the injector's results justify the cost.

CategoryWanVideoWrapper/Advanced

Inputs (4)

NameTypeDefaultDescription
modelWANVIDEOMODEL
text_embedsWANVIDEOTEXTEMBEDS
capture_after_blocksINT31–10
use_cacheBOOLEANtrue

Outputs (2)

NameTypeDescription
latent_embedsLATENT_EMBEDS
infoSTRING