Nodes/HunyuanVideo-1.5 nodes/HunyuanVideo Prepare Latents
ComfyUI Node

HunyuanVideo Prepare Latents

Making the noise that becomes your HunyuanVideo 1.5 clip

By yuanyuan-spec·Created 10 months ago·Updated 10 months ago· 28
HunyuanVideo Prepare Latents
  • hyvid_cfg
  • vae
  • latents
  • reference_image
  • latents_dict
  • height
  • width
  • n_tokens
aspect_ratio16:9
target_dtypebfloat16

Every diffusion video starts as noise - a tensor of random values that the transformer gradually denoises into frames. In the complete HunyuanVideo 1.5 workflow, HyVideo15LatentsPrepare is the node that makes that starting noise and works out its shape. It's the spiritual equivalent of EmptyLatentImage in an SD workflow, except it has to think about the temporal axis too: the latent video isn't just 16x smaller in each spatial dimension, it's 4x shorter in time, because the 1.5 VAE compresses both.

What it does

Given hyvid_cfg (from HyVideo15CFG, which supplies the frame count, seed, and scheduler) and the vae (so it knows the compression ratios), it:

  1. Works out the target pixel resolution - from aspect_ratio (e.g. "16:9") mapped to the nearest supported bucket for the model's resolution, or from reference_image if you're doing I2V and want the output to match your input frame.
  2. Compresses that to latent size: (video_length - 1) // 4 + 1 frames, and height / 16 × width / 16 spatial.
  3. Generates the random noise latents with your seed, scaled by the scheduler's init_noise_sigma.

The four outputs are latents_dict (the noise tensor plus its temporal length), and height, width, n_tokens (total latent token count). The height/width outputs wire straight into HyVideo15VaeEncode, which needs the same pixel dimensions for its image conditioning.

The optional latents input accepts a LATENT from elsewhere. Feed one in and this node becomes an img2img-style entry point - instead of fresh noise, the transformer starts from your provided latents, which is how you'd do things like video interpolation or restyling within the complete workflow.

Where it sits

Complete workflow order: HyVideo15CFGHyVideo15LatentsPrepare → feeds HyVideo15VaeEncode, HyVideo15VisionEncode, and HyVideo15Transformer. In the simplified sampler this whole job happens inside HyVideo15I2VSampler/HyVideo15T2VSampler, so again - you only meet this node when you're building the graph by hand.

Installing it

Part of comfyui_hunyuanvideo_1.5_plugin. ComfyUI Manager → "HunyuanVideo-1.5 nodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yuanyuan-spec/comfyui_hunyuanvideo_1.5_plugin
cd comfyui_hunyuanvideo_1.5_plugin
pip install -r requirements.txt

Restart. Needs the VAE present (HyVideo15VaeLoader with path "None" auto-downloads it) and a wired hyvid_cfg.

Common issues

target_dtype defaults to bfloat16 and the node will happily make noise in any of the nine listed dtypes - but if the transformer is running in a different dtype, you get a mismatch error at the first step. Keep them in sync. Also, aspect_ratio must be "W:H" with positive integers (the code explicitly validates this), and a typo like "16x9" throws a ValueError that reads scary but just means "fix the ratio string." If your I2V output keeps coming out at a different size than your reference image, that's this node's bucket-mapping choosing a supported resolution - normal, not a bug.

CategoryHunyuanVideoWrapper1.5

Inputs (6)

NameTypeDefaultDescription
hyvid_cfgHYVID15CFG
vaeHYVID15VAE
aspect_ratioSTRING16:9
target_dtypeCOMBObfloat169 options: float32, float64, float16, bfloat16, uint8, int8, +3
latentsoptLATENT
reference_imageoptIMAGE

Outputs (4)

NameTypeDescription
latents_dictHYVID15LATENTSDICT
heightINT
widthINT
n_tokensINT