Nodes/ComfyUI/Wan Context Windows
ComfyUI Node Runs on cloud

Wan Context Windows

Push past 81 frames without the identity meltdown

By Comfy-Org·Created 4 years ago·Updated about 2 hours ago· 129,964
Wan Context Windows
  • model
  • MODEL
context_length81
context_overlap30
context_schedulestandard_uniform
context_stride1
closed_loopfalse
fuse_methodpyramid
freenoisetrue
retain_first_framefalse
split_conds_to_windowsfalse

Wan Context Windows is the Wan-tuned version of ComfyUI's context-window sampling, and it exists because Wan's native limit is a hard, annoying wall: 81 frames. That's about five seconds at 16fps. Go past it without help and you get looping, degradation, or a model that "starts acting strangely" - the community's long-standing finding was that ~121 frames is about the ceiling before things fall apart. This node slides a window over the frame sequence during sampling so you can generate longer, and it speaks Wan's units so you don't have to think in latent positions.

Wan is where local video generation consolidated - the 14B diffusion transformer with its 3D causal VAE and 81-frame native context is the base for a whole stack of third-party models (Bernini, SCAIL-2). But Alibaba stopped shipping open weights after 2.2, so the 2.1/2.2 checkpoints you're patching are as good as Wan gets locally. Making them run longer is exactly what this node is for.

How it works

Same machinery as the manual context node - it installs a context handler on a cloned model that slices the sequence into overlapping windows, samples each, and fuses them - but the wrapper handles Wan's specifics for you. Context length is in real frames (must be 4n+1, matching Wan's temporal compression), it defaults freenoise on (the noise shuffling that keeps window boundaries from showing), and it automatically applies the windowing to the temporal dimension. retain_first_frame is the I2V hero: it keeps the first frame's content in every window, which is what stops the reference image from being forgotten the moment window two starts.

Under the hood it converts your frame values into latent values ((length-1)//4 + 1) and forwards to the manual node with cond_retain_index_list set to '0' when you enable retain_first_frame.

The inputs that matter

  • context_length - default 81, in real frames, must be 4n+1. For an 8-second clip at 16fps that's ~129; start at 81 and grow.
  • context_overlap - default 30, real frames of overlap between windows. If you see seams, this is the first knob.
  • retain_first_frame - off by default. For I2V, turn it on; it keeps the first frame in every window and stops the "reference forgotten by window three" problem.
  • context_schedule - default standard_uniform; the uniform schedules pair with context_stride if you want gaps. Leave the defaults unless you know otherwise.

Output: the patched MODEL. It's built into ComfyUI core.

Common issues & troubleshooting

The seams are the whole discussion. The "jump or quick morphing between the context windows" complaint is the #1 thread topic for this node. When it happens, raise the overlap, confirm freenoise stayed on, and consider whether the model you're using (a 2.1 fine-tune, a 2.2 derivative) actually tolerates windowing - some Wan variants "still need tuning," per the release notes themselves.

I2V reference fades or the first frame stops mattering. Enable retain_first_frame. If you're on a concat-style I2V workflow and it still drifts, the manual node's cond_retain_index_list gives you finer control.

Longer windows ≠ better. The point is to keep windows small enough that attention stays cheap. If you set context_length near your full clip length, you've just recreated the OOM you were trying to escape - the node only helps when windows are meaningfully smaller than the sequence.

Categorymodel/patch/wan

Inputs (10)

NameTypeDefaultDescription
modelMODELThe model to apply context windows to during sampling.
context_lengthINT811–16384The length of the context window in real frames. Must be 4*n + 1.
context_overlapINT30The overlap of the context window in real frames.
context_scheduleCOMBOstandard_uniformStep-dependent scheduling algorithm for context windows.
context_strideINT1The stride of the context window; only applicable to uniform schedules.
closed_loopBOOLEANfalseWhether to close the context window loop; only applicable to looped schedules.
fuse_methodCOMBOpyramidThe method to use to fuse the context windows.
freenoiseBOOLEANtrueWhether to apply FreeNoise noise shuffling, improves window blending.
retain_first_frameBOOLEANfalseRetain the first I2V frame in every context window (may help retain initial reference).
split_conds_to_windowsBOOLEANfalseWhether to split multiple conditionings (created by ConditionCombine) to each window based on region index.

Outputs (1)

NameTypeDescription
MODELMODELThe model with context windows applied during sampling.