Search

Search papers and lessons

HunyuanVideo: A Systematic Framework For Large Video Generative Models

Weijie Kong, Qi Tian, Zijian Zhang et al. · 2024

HunyuanVideo is Tencent's open-source 13-billion-parameter text-to-video model, which makes clips by denoising a compressed video latent with a transformer trained by flow matching.

On this page

  • Colour = topic mix
  • Architectures
  • Probability
  • Linear algebra
  • Calculus
  • Generative models
  • Neural network basics
  • ReadReady to readNot yet

TL;DR

HunyuanVideo is an open video foundation model from Tencent. It generates a clip from a text prompt by starting from random noise in a compressed video space and removing the noise in steps, with a transformer that predicts how to move the sample at each step. The authors report a 13-billion-parameter model that was judged best overall against five closed-source baselines in a human evaluation of 1,533 prompts. The report describes the whole system: data curation, a 3D autoencoder, a single transformer for images and video, scaling experiments, staged training, and speed-ups for sampling.

Builds on: Multimodal Diffusion Transformer, Rotary Position Embedding, Vision-Language Model, Flow Matching, Variational Autoencoder · Leads to: CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer

Why it mattered

The report starts from a gap. The strongest video generators in 2024 were closed, and the authors argue that this left the public without a capable base model to build on, which slowed open research. HunyuanVideo was released with code and model weights for the foundation model and some applications, so the wider community could run and adapt it.

Its results are the basis for the claim that an open model could compete with closed ones. In the paper's own human evaluation, HunyuanVideo had the highest overall score, and the paper highlights motion quality, where it scores 66.5% against 62.9% for the next best (Table 3 in the Results section). The report is also useful as a worked example of how a video model of this size is put together, since it gives the choices and the reasons for them, not only the final numbers. Its comparison partner CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer is another open video model from the same period.

The problem

Diffusion models were already strong at images, but video lagged. The introduction blames the lack of robust open-source foundation models for much of this. Video is expensive in a specific way: a 720 by 1280 clip with 129 frames (an example of ours, not a paper setting) has about 357 million numbers in pixel form, and a transformer that attends over every piece of that would be too costly to train. The authors needed a way to choose model size and data size before spending the compute, which they handle with scaling laws, and a way to keep sampling fast enough to use.

Prompts add a third problem. Users write prompts of very different length and style, while the training captions must be consistent. The raw data also varies in duration and quality, so it needs filtering before training.

How it works

Generation runs in the order below.

  1. Rewrite the prompt. A large language model (Hunyuan-Large) rewrites the user's prompt into a standard form, similar to the structured captions used in training. It can take prompts in several languages and simplify complex wording while keeping its meaning. Check: the next step sees the rewritten prompt, not the raw one.
  2. Encode the text twice. A multimodal language model, which reads images and text and outputs next-token predictions, turns the prompt into a sequence of fine-grained feature vectors. CLIP-Large, a model trained to place images and text in one shared space, turns the same prompt into one pooled vector that summarises it. Check: one sequence for detail, one vector for the overall meaning.
  3. Start from noise in latent space. Draw a tensor of Gaussian noise with the shape of the compressed video. The 3D autoencoder sets that shape: it reduces time by 4 and each spatial side by 8, and keeps 16 channels. Check: the noise is a small grid of latent values, not pixels.
  4. Predict a velocity with the transformer. The latent is cut into patches by a 3D convolution and flattened into one sequence of tokens. Twenty dual-stream blocks process the video tokens and the text tokens separately, so each can learn its own modulation. Forty single-stream blocks then concatenate the two sequences and attend across all of them. Rotary position embedding is applied on time, height and width separately. The pooled CLIP vector is added to the timestep embedding. Check: the output has the same shape as the input latent, and it is a predicted direction of motion.
  5. Integrate the directions. Move the latent along the predicted directions in a fixed number of Euler steps. The time value fed to the model is shifted so that the first steps do more of the work, which matters when the number of steps is small. Check: after the last step, the latent describes a clean video.
  6. Decode. The 3D autoencoder's decoder turns the final latent back into frames. Check: frames at the original resolution and length.
flowchart LR
  P[prompt] --> R[LLM rewrite]
  R --> E[text features: MLLM + CLIP]
  N[Gaussian noise in latent space] --> T[transformer: velocity]
  E --> T
  T --> I[Euler steps with time shift]
  I --> D[3D VAE decoder]
  D --> V[video frames]

The math

The autoencoder shapes

For a video of shape (T+1)×3×H×W(T+1) \times 3 \times H \times W, the 3D autoencoder produces latents of shape (Tct+1)×C×Hcs×Wcs(\frac{T}{c_t}+1) \times C \times \frac{H}{c_s} \times \frac{W}{c_s}, with ct=4c_t = 4, cs=8c_s = 8 and C=16C = 16. Its training loss is

Loss=L1+0.1 Llpips+0.05 Ladv+10−6 Lkl,\text{Loss} = L_1 + 0.1\,L_{lpips} + 0.05\,L_{adv} + 10^{-6}\,L_{kl},

a pixel reconstruction term, a perceptual term, an adversarial term and a small KL term.

Step 3 in symbols: noise and time

Let x0\mathbf{x}_0 be Gaussian noise with the latent shape, x0∼N(0,I)\mathbf{x}_0 \sim \mathcal{N}(\mathbf{0}, \mathbf{I}), and let x1\mathbf{x}_1 be the latent of a training video. The time tt is a number in [0,1][0, 1]. The paper samples tt from a logit-normal distribution, which is what you get when a normal random number is passed through the logistic function 1/(1+e−z)1/(1 + e^{-z}); it puts more samples in the middle of the range than near the ends.

Training in symbols

The paper builds xt\mathbf{x}_t by linear interpolation and trains a network vt\mathbf{v}_t to predict the velocity ut\mathbf{u}_t. The paper names the interpolation but does not print it. The usual straight path is xt=(1−t) x0+t x1\mathbf{x}_t = (1 - t)\,\mathbf{x}_0 + t\,\mathbf{x}_1, which has velocity ut=x1−x0\mathbf{u}_t = \mathbf{x}_1 - \mathbf{x}_0. Note that the paper's sampler starts from noise at t=1t = 1 and halts at t=0t = 0, the reverse of this training path, so read tt in each part with the paper's convention for that part. The loss is the mean squared error

Lgeneration=Et,x0,x1∥vt−ut∥2.\mathcal{L}_{\text{generation}} = \mathbb{E}_{t, \mathbf{x}_0, \mathbf{x}_1}\bigl\|\mathbf{v}_t - \mathbf{u}_t\bigr\|^2.

Step 5 in symbols: the time shift and Euler steps

With QQ inference steps and step index qq, the time is t=1−q/Qt = 1 - q/Q. The model receives a shifted time

t′=s t1+(s−1) t,t' = \frac{s\,t}{1 + (s - 1)\,t},

where ss is the shift factor. When s=1s = 1, t′=tt' = t. When s>1s > 1, the model sees more of the early, noisy part of the schedule. The paper uses s=7s = 7 for 50 steps and s=17s = 17 when there are fewer than 20 steps. Each Euler step then moves the sample by its predicted velocity times the step size 1/Q1/Q.

Scaling laws in symbols

The paper fits power laws Nopt=a1Cb1N_{\text{opt}} = a_1 C^{b_1} and Dopt=a2Cb2D_{\text{opt}} = a_2 C^{b_2}, where NN is model size, DD is training data, and CC is compute in petaFLOPs. For images the fitted constants are a1=5.48×10−4a_1 = 5.48 \times 10^{-4}, b1=0.5634b_1 = 0.5634, a2=0.324a_2 = 0.324 and b2=0.4325b_2 = 0.4325. For video they are a1=0.0189a_1 = 0.0189, b1=0.3618b_1 = 0.3618, a2=0.0108a_2 = 0.0108 and b2=0.6289b_2 = 0.6289. The model size of 13 billion was chosen from these curves together with training and inference cost.

Worked examples

Example
Tiny: the time shift at one value

Use s=7s = 7 and t=0.5t = 0.5.

  1. Compute the denominator: 1+(s−1) t=1+6×0.5=41 + (s - 1)\,t = 1 + 6 \times 0.5 = 4.
  2. Compute the numerator: s t=7×0.5=3.5s\,t = 7 \times 0.5 = 3.5.
  3. Divide: t′=3.5/4=0.875t' = 3.5 / 4 = 0.875.
  4. Check the case s=1s = 1: the formula gives t′=t/1=tt' = t / 1 = t, so no shift happens.

The shift moves the time from 0.5 to 0.875, so the model is told it is closer to the noisy end than the step count alone suggests.

Example
Standard: one flow-matching training target

Take scalar stand-ins for the latents: x0=−1x_0 = -1 for the noise, x1=2x_1 = 2 for the data, and t=0.25t = 0.25.

  1. Build the input with the straight path: xt=(1−t) x0+t x1=0.75×(−1)+0.25×2=−0.75+0.5=−0.25x_t = (1 - t)\,x_0 + t\,x_1 = 0.75 \times (-1) + 0.25 \times 2 = -0.75 + 0.5 = -0.25.
  2. Compute the target velocity: ut=x1−x0=2−(−1)=3u_t = x_1 - x_0 = 2 - (-1) = 3.
  3. Suppose the network predicts vt=2v_t = 2.
  4. Compute the squared error: (vt−ut)2=(2−3)2=1(v_t - u_t)^2 = (2 - 3)^2 = 1.
  5. Training pushes the prediction toward 3, which lowers this error.
Example
Realistic: the latent for a 720 by 1280 clip

Take a clip of 720 by 1280 pixels with 129 frames as our example. The paper's autoencoder takes T+1T + 1 frames, and 129 fits that form with T=128T = 128. The size is our choice, not a paper setting.

  1. Latent frames: T/ct+1=128/4+1=33T / c_t + 1 = 128 / 4 + 1 = 33.
  2. Latent height: 720/8=90720 / 8 = 90. Latent width: 1280/8=1601280 / 8 = 160.
  3. Latent channels: C=16C = 16. The latent shape is 33×16×90×16033 \times 16 \times 90 \times 160.
  4. Count the numbers before and after. The input has 129×3×720×1280=356,659,200129 \times 3 \times 720 \times 1280 = 356{,}659{,}200 values. The latent has 33×16×90×160=7,603,20033 \times 16 \times 90 \times 160 = 7{,}603{,}200 values.
  5. The ratio is about 47, so the transformer works on about 47 times fewer numbers than raw pixels. This is our arithmetic from the stated shapes, not a figure the paper prints.

Try it: a 65-frame clip at the same resolution gives how many latent frames? Answer: T=64T = 64, so 64/4+1=1764 / 4 + 1 = 17 latent frames.

Results

Autoencoder. Table 1 compares reconstruction quality with PSNR, where higher is better. On ImageNet at 256 by 256, the paper's autoencoder scores 33.14, against 32.70 for FLUX-VAE and 31.73 for CogVideoX-1.5. On MCL-JCV video at 33 by 360 by 640, it scores 35.39, against 33.22 for CogVideoX-1.5 and 30.15 for OpenSora-1.2. The authors say the autoencoder shows significant advantages on text, small faces and complex textures.

Human evaluation. The authors used 1,533 prompts, one run each, and 60 evaluators who scored text alignment, motion quality and visual quality (Table 3). The overall column is reported as a percentage, and the paper does not define how it is computed.

ModelText alignmentMotion qualityVisual qualityOverall
HunyuanVideo61.8%66.5%95.7%41.3%
CNTopA (API)62.6%61.7%95.6%37.7%
CNTopB (Web)60.1%62.9%97.7%37.5%
GEN-3 alpha (Web)47.7%54.7%97.5%27.4%
Luma1.6 (API)57.6%44.2%94.1%24.8%
CNTopC (Web)48.4%47.2%96.3%24.6%

HunyuanVideo is not first on every column. CNTopA has a higher text-alignment score, and CNTopB has a higher visual-quality score. Its lead is in the overall column and in motion quality.

Acceleration. Distilling classifier-free guidance into one student gives about 1.9 times faster inference, according to the paper. The time shift is presented as giving better visual quality at 10 steps than the linear-quadratic schedule used by MovieGen. That comparison is shown in a figure, and the text reports it only qualitatively.

Training stability. The report says the automatic fault-tolerance mechanism gives a training stability of 99.5%. The paper does not define how this figure is measured.

Limits. The evaluation is the authors' own, on their prompt set, with the baselines run at default settings by the authors. The clips in the table are five or six seconds long. The scaling study was done on images and then carried over to video, and the authors say the scaling of progressive training is left to future work. The avatar and audio sections have no comparison table like Table 3.

Reading guide

Check yourself

QuestionIn the 3D autoencoder, what happens to the number of latent frames when the input has 33 frames, and why does the paper say the encoder handles images as well as video?Show answer

With T+1=33T + 1 = 33, so T=32T = 32, the latent has 32/4+1=932 / 4 + 1 = 9 frames. The paper says images are treated as single-frame videos, so one encoder covers both, built from causal 3D convolutions.

QuestionA sampler uses Q = 10 steps and shift factor s = 17. At step q = 2, what is the time fed to the model?Show answer

Here t=1−2/10=0.8t = 1 - 2/10 = 0.8. The shifted time is t′=17×0.8/(1+16×0.8)=13.6/13.8t' = 17 \times 0.8 / (1 + 16 \times 0.8) = 13.6 / 13.8, which is about 0.986. The shift moves the time toward 1, so the model sees more of the early part of the schedule.

QuestionWhy does the paper use a dual-stream stage before the single-stream stage?Show answer

In the dual-stream blocks, video and text tokens are processed separately, so each modality can learn its own modulation without interference. In the single-stream blocks the two sequences are concatenated, so attention can fuse them. The order lets each modality set up its own representation before the fusion.

QuestionTable 3 shows HunyuanVideo with the top overall score but not the top text-alignment score. Name the baseline that has the higher text alignment and explain what this tells you about the overall column.Show answer

CNTopA has text alignment 62.6% against 61.8% for HunyuanVideo. The overall column cannot be a plain average of the three criteria, since those sit between 48% and 98% while the overall scores sit between 25% and 41%. The paper does not define the overall column, so the table cannot be reproduced from it.

QuestionWhy would a team pick a shifted schedule over a plain one when it can afford only 10 sampling steps?Show answer

With few steps, each step has to cover more of the change, and the early, noisy part of the schedule does most of the visible work. The shift spends more of the time budget on that part. The paper reports better visual quality at 10 steps than the linear-quadratic schedule, which is qualitative in the text and shown in its figure.

Sources

Read the full paper

Weijie Kong, Qi Tian, Zijian Zhang et al., 2024. arXiv:2412.03603