Apply RifleXRoPE WanVideo
Push Wan past its frame limit (sometimes)
- model
- latent
- MODEL
Wan (and Hunyuan) video models are trained to generate a fixed number of frames - for Wan, that famous ~81-frame wall. Try to go longer and the motion often loops or bounces back to where it started, because the model's positional encoding wasn't built to count that high. ApplyRifleXRoPE_WanVideo is an attempt to break that ceiling. It implements the RIFLEx method (from thu-ml), which tweaks the model's rotary positional embeddings so you can extrapolate to longer clips without the obvious repetition. Wire it in before sampling and, in the cases where it works, you get a longer video that doesn't visibly loop.
How it works
Video diffusion models use RoPE - rotary position embeddings - to tell the model where each frame sits in time. When you extend beyond the trained length, one particular frequency component in that encoding is what causes the repeating/looping artifact. RIFLEx identifies and reduces that intrinsic frequency so the temporal signal keeps advancing instead of wrapping around. This node patches the model with that adjustment and passes the modified model on.
The inputs
Just three, and they're simple:
- model - your Wan video model. The node returns a modified MODEL, which is what you feed into your sampler in place of the original.
- latent - the video latent, which the node needs to know the sequence length it's adjusting for.
- k - the intrinsic frequency index to reduce, defaulting to 6. This is the knob that targets which component gets damped. The default is the tuned starting point; nudge it only if you understand what you're doing.
The single output is the patched MODEL.
The honest part
Set expectations here, because the community has. This is not a magic "unlimited length" button. Ask around and you'll find plenty of people who tried RifleX on Wan 2.2 to get past 81 frames and reported seeing no difference - the motion still bounced. What actually seems to help it land: simpler, repeating motion where the subject doesn't leave or dramatically change the frame, plus tighter, simpler prompting. Complex scenes with lots of change are where it tends to fall apart. Treat it as a technique that buys you some extra length in favorable conditions, not a guaranteed fix for arbitrary long video.
Installing KJNodes
ComfyUI Manager: Custom Nodes Manager, search "KJNodes for ComfyUI", install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes, then pip install -r ComfyUI-KJNodes/requirements.txt (portable: python_embeded\python.exe -m pip install -r ComfyUI\custom_nodes\ComfyUI-KJNodes\requirements.txt), restart. The node adds nothing to download - but it only means anything inside a working Wan video workflow, which is the heavy part you set up separately.
Troubleshooting
If it seems to do nothing, that's the common experience, not necessarily a bug. Simplify the prompt and the motion before concluding it's broken, and confirm you're actually routing the node's output model into the sampler rather than accidentally sampling with the original. If longer generations get worse rather than better, dial your extension back - the further past the trained length you push, the more even RIFLEx struggles to hold coherence. It extends the runway; it doesn't remove the cliff.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| latent | LATENT | Only used to get the latent count | |
| k | INT | 61–100 | Index of intrinsic frequency |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |