Nodes/KJNodes for ComfyUI/Apply RifleXRoPE HunuyanVideo
ComfyUI Node Runs on cloud

Apply RifleXRoPE HunuyanVideo

Push HunyuanVideo past its frame limit

By kijai·Created 3 years ago·Updated a day ago· 3,011
Apply RifleXRoPE HunuyanVideo
  • model
  • latent
  • MODEL
k4

Every video diffusion model is trained on clips of a certain length, and when you ask for more frames than that, the model doesn't gracefully extend - it loops. The motion runs out to the edge of what it learned and then bounces back to where it started, like a GIF that resets. ApplyRifleXRoPE_HunuyanVideo is Kijai's fix for that on HunyuanVideo: it patches the model's positional encoding using the RIFLEx method (from thu-ml, github.com/thu-ml/RIFLEx) so you can generate longer clips without that periodic repeat. (Yes, the class name spells it "Hunuyan" - a typo that's now load-bearing, since renaming it would break everyone's saved workflows.)

HunyuanVideo was the model that first made local video feel real, back in late 2024 - cinematic, uncensored, easy to train - before Wan took the ecosystem by filling the image-to-video gap. If you're still running Hunyuan, its trained frame window is exactly the kind of ceiling this node is meant to lift.

How it works

RoPE (rotary positional embedding) is how the model knows when each frame sits in the sequence. The problem with going long is that the positional frequencies start repeating, and the model reads a later frame as if it were an earlier one - hence the bounce-back. RIFLEx reduces the specific intrinsic frequency responsible for that repetition, stretching the effective window so the model can keep going a bit further before it folds. This node reads your latent (to know the length you're aiming for), applies the patch, and returns a modified model.

The inputs and outputs that matter

  • model (MODEL) - your HunyuanVideo model.
  • latent (LATENT) - the video latent, so the node knows how long the clip is.
  • k (INT, default 4) - which intrinsic frequency to reduce, the one RIFLEx hyperparameter. The default of 4 is the sane starting point; treat it as a dial to nudge, not something to crank blindly.

The single output is a patched MODEL - wire it straight into your sampler in place of the original. Everything else in your Hunyuan graph stays the same.

How to install it

ComfyUI Manager: search KJNodes for ComfyUI, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt

then restart (portable: run the pip step via python_embeded\python.exe). The node itself just patches your existing model - no extra download.

Common issues & troubleshooting

"I don't see any difference." This is the honest, common outcome, and it's worth setting expectations. RIFLEx is not a magic longer-video button - people who've tried it report struggling with the exact frame-count bounce it's meant to solve and seeing little change on complex scenes. It tends to help most on simple, continuous motion where the subject doesn't leave or radically change the frame; busy scenes still degrade past the trained window. If it seems to do nothing, that's a known experience, not necessarily a broken install.

You cranked the frame count and quality collapsed. RIFLEx buys you some extra length, not unlimited. Push far past the model's window and you'll get drift, softening, and repetition anyway. Extend modestly.

Wrong model family. This node is written for HunyuanVideo's architecture specifically. The RIFLEx idea gets applied to other models too (people ask about it on Wan constantly), but this particular node targets Hunyuan - use the matching node for whatever model you're actually running.

Order in the graph. Apply this to the model before it reaches the sampler, and feed it the same latent you're sampling, or the length it patches for won't match the clip you're generating.

CategoryKJNodes/hunyuanvideo

Inputs (3)

NameTypeDefaultDescription
modelMODEL
latentLATENTOnly used to get the latent count
kINT41–100Index of intrinsic frequency

Outputs (1)

NameTypeDescription
MODELMODEL