Nodes/ComfyUI-HunyuanVideoWrapper/HunyuanVideo Sampler
ComfyUI Node Runs on cloud

HunyuanVideo Sampler

Where the video actually gets generated

By kijai·Created 2 years ago·Updated 12 months ago· 2,594
HunyuanVideo Sampler
  • model
  • hyvid_embeds
  • samples
  • image_cond_latents
  • stg_args
  • context_options
  • feta_args
  • teacache_args
  • loop_args
  • fresca_args
  • slg_args
  • mask
  • samples
width512
height512
num_frames49
steps30
embedded_guidance_scale6.00
flow_shift9.00
seed0
force_offloadtrue
denoise_strength1.00
schedulerFlowMatchDiscreteScheduler
riflex_freq_index0
i2v_modedynamic

This is the KSampler-equivalent for kijai's Hunyuan wrapper - the node that actually runs the denoising loop and produces latents. It's also the hub of the whole pack: nearly every other settings node in this article series (TeaCache, block swap indirectly through the model, Enhance-A-Video, context options, FreSca, Skip Layer Guidance, loop args) plugs into an optional input here. That's the real draw of this wrapper over native ComfyUI Hunyuan support - you get several acceleration and quality techniques wired into one sampler that native support, as of this pack's last real update, still doesn't fully match.

The inputs that matter

Required: model (HYVIDEOMODEL) and hyvid_embeds (from one of the encode nodes) are non-negotiable. width/height default to 512, stepping by 16. num_frames defaults to 49 and steps by 4 - that's not arbitrary; HunyuanVideo's VAE compresses 4 pixel frames into 1 latent frame, so frame counts follow the "4n+1" convention common across video diffusion models. steps defaults to 30. embedded_guidance_scale (default 6) is HunyuanVideo's baked-in guidance - the model is guidance-distilled, meaning the classifier-free-guidance behavior is trained into the weights rather than requiring a real second forward pass every step, similar to how Flux works. flow_shift (default 9) is the timestep-shift knob that flow-matching models expose to control how sampling effort distributes between overall composition and fine detail.

Optional and worth knowing: samples (vid2vid init latent) and image_cond_latents (i2v init, from HyVideoEncode) cover the older/community image-to-video route; denoise_strength controls how much of that init survives. riflex_freq_index (default 0, disabled) is a real, community-verified technique for generating past the model's native ~129-frame training length without the output looping back on itself - the tooltip's own recommendation is 4 when you actually want it. i2v_mode switches between stability and dynamic image-conditioning behavior. scheduler offers five options, defaulting to FlowMatchDiscreteScheduler - the one matched to how this model was trained; the others exist for experimentation.

Output: samples, a LATENT that goes straight to HyVideoDecode.

How to install it

Ships with the pack. ComfyUI Manager: search ComfyUI-HunyuanVideoWrapper, install, restart. Manual:

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

then restart. This node needs everything upstream working first: a loaded model, embeds from an encode node, and ideally a VAE ready downstream - it's the middle of the pipeline, not something you can test in isolation.

Common issues & troubleshooting

Out of memory as soon as you raise resolution or frame count. Video memory scales fast on both axes at once - width, height, and frame count all multiply together. Drop num_frames first (it's usually the cheapest lever), make sure the model loader has fp8 quantization and a HyVideoBlockSwap attached, and only then reach for lower resolution.

Motion looks mushy, or the model seems to ignore your prompt's dynamics. Check flow_shift - it's tuned for this specific model at its default of 9; wildly different values push the sampling trajectory somewhere the model wasn't trained to handle well.

Generation crashed at a frame count you didn't choose. num_frames snaps to steps of 4 - if you typed an arbitrary number, ComfyUI rounds it, and depending on your workflow the result you expected and the result you got can differ. Stick to the 4n+1 pattern (49, 65, 129...) deliberately.

Output loops or repeats past a certain length. That's a known limitation of this model at longer lengths, not a bug in your workflow. riflex_freq_index set to a nonzero value (try 4) is the documented fix for extending past the native training length without the repeat.

CategoryHunyuanVideoWrapper

Inputs (24)

NameTypeDefaultDescription
modelHYVIDEOMODEL
hyvid_embedsHYVIDEMBEDS
widthINT51264–4096
heightINT51264–4096
num_framesINT491–1024
stepsINT30
embedded_guidance_scaleFLOAT6.000–30
flow_shiftFLOAT9.000–1000
seedINT00–18446744073709550000
force_offloadBOOLEANtrue
samplesoptLATENTinit Latents to use for video2video process
image_cond_latentsoptLATENTinit Latents to use for image2video process
denoise_strengthoptFLOAT1.000–1
stg_argsoptSTGARGS
context_optionsoptHYVIDCONTEXT
feta_argsoptFETAARGS
teacache_argsoptTEACACHEARGS
scheduleroptCOMBOFlowMatchDiscreteScheduler5 options: FlowMatchDiscreteScheduler, SDE-DPMSolverMultistepScheduler, DPMSolverMultistepScheduler, SASolverScheduler, UniPCMultistepScheduler
riflex_freq_indexoptINT00–1000Frequency index for RIFLEX, disabled when 0, default 4. Allows for new frames to be generated after 129 without looping
i2v_modeoptCOMBOdynamicI2V mode for image2video process
loop_argsoptLOOPARGS
fresca_argsoptFRESCA_ARGS
slg_argsoptSLGARGS
maskoptMASK

Outputs (1)

NameTypeDescription
samplesLATENT