TL;DR
CogVideoX is a text-to-video model. It turns a sentence into a clip of up to 10 seconds, at 16 frames per second and 768 by 1360 pixels, with motion that stays coherent from start to end. It does this in three moves. A 3D autoencoder squeezes the video in space and time, a diffusion transformer denoises the squeezed version while reading the text, and a special normalisation step gives text tokens and video tokens their own scale and shift so they can share one sequence.
Builds on: Latent Diffusion Model, Diffusion Transformer (DiT), Adaptive Layer Normalization, Rotary Position Embedding, Variational Autoencoder · Leads to: Stable Video Diffusion: Scaling Latent Video Diffusion Models to Large Datasets (a later video diffusion model, useful for comparison)
Why it mattered
Text-to-video had been limited to short clips with little movement. CogVideoX showed that a diffusion transformer, trained with careful data work and staged resolution increases, could produce longer clips with large, consistent motion. The authors release 2B and 5B parameter versions with code on GitHub, which made the recipe available to other groups. In the paper's own comparisons, the 5B model scores best on five of seven automated metrics and beats Kling, a closed commercial model, on every axis of a human study.
The Diffusion Transformer (DiT) idea comes from Peebles and Xie (2023), who showed that a transformer could serve as the denoising backbone of a diffusion model. Earlier text-to-video systems, such as CogVideo and Phenaki (both 2022), used transformers over discrete video tokens rather than diffusion. CogVideoX is one of the first open releases to bring the diffusion approach to clips of this length and resolution.
The problem
Before this work, video models faced three difficulties at once.
First, a video is very large. A 10-second clip at 768 by 1360 pixels has far more values than an image, and running a transformer over every pixel is out of reach. Earlier systems fine-tuned a 2D image autoencoder frame by frame, which does not model motion across frames and lets flicker through.
Second, text and video are different kinds of data. Their embeddings can have different scales, so putting them in one sequence without care makes the network struggle to fuse them.
Third, the training data is hard to use. Most online video has no good captions, and clips come in many lengths and shapes. Forcing them to one length throws data away, and mixing images with videos in the same batch often makes the model split into two generation modes.
How it works
Here is the generation path, traced in order. The training path uses the same pieces, with a real video in place of the noise in step 2.
- Read the prompt. The text goes through a T5 encoder, which turns it into a sequence of text embeddings . The paper's training setting pads text to 226 tokens.
- Start from noise in latent space. The video is not generated in pixels. It is generated as a compressed block of numbers, the latent. The model starts from random noise with the latent's shape.
- Patchify the latent. The latent block is cut into small patches. Each patch becomes one token, so the video becomes a sequence .
- Concatenate. The text tokens and the video tokens are joined along the sequence dimension into one list.
- Run the expert transformer. Each block applies attention over all tokens at once, which is the paper's 3D full attention. Each token's position is encoded with 3D rotary embeddings. Each block normalises text and video tokens with separate scales and shifts, both set by the diffusion timestep .
- Denoise, step by step. The network predicts what to remove from the current latent. A diffusion sampler moves the latent toward a clean one, and steps 5 and 6 repeat. The paper's timing numbers use 50 inference steps.
- Unpatchify and decode. The clean latent is reshaped back to its video shape and passed through the 3D causal VAE decoder, which returns pixels.
flowchart LR A[Prompt] --> B[T5 encoder] B --> F[Join text and video tokens] N[Noise in latent shape] --> P[Patchify] P --> F F --> T[Expert transformer blocks] T --> D[Denoised latent] D --> U[Unpatchify and 3D VAE decoder] U --> V[Video]
A tiny clip, counted by hand
Take a clip of 8 frames, each 64 by 64 pixels, with 3 colour channels. Use the paper's 8 by 8 by 4 compression and a latent with 16 channels, and treat each group of 4 frames as one latent frame.
- Count the pixel values: .
- Count the latent frames: .
- Count the latent spatial positions: in each direction, so positions per frame.
- Count the latent positions in total: .
- Count the latent values with 16 channels each: .
- Compare: . The latent is 48 times smaller than the pixels.
The transformer sees 2,048 numbers instead of 98,304 before patchifying.
The math
The 3D causal VAE (step 2)
A video has frames, height , width and colour channels. The VAE compresses it by a factor in time and in each spatial direction, which the paper writes as 8 by 8 by 4. It encodes the video into a latent of shape , where is the number of latent channels. The causal part means the convolution pads only at the start of time, so frame never sees frames after .
The VAE is trained with a reconstruction loss, a perceptual loss (a distance computed on features from a pretrained image network), a Kullback–Leibler Divergence term that keeps the latent close to a simple distribution, and, after a few thousand steps, a GAN loss from a 3D discriminator. The Variational Autoencoder lesson covers the reconstruction and KL parts.
Patchify (step 3)
If the latent has shape and a patch covers frames and by spatial positions, the number of tokens is
The count grows with video length and resolution, which is why memory is the bottleneck.
3D rotary positions (step 5)
Each latent token has coordinates . A Rotary Position Embedding of size is split into three parts of sizes , and . Each part is rotated by its own coordinate, and the three results are joined back into one vector of length .
Expert adaptive normalisation (step 5)
For each modality , either text or vision, with hidden states , the block computes
where is Layer Normalization, is elementwise multiplication, and , are the scale and shift that a small network produces from the timestep. This follows the modulation used in Diffusion Transformer (DiT) models. The "expert" part is that each modality gets its own and , while the attention weights are shared.
Training loss and explicit uniform sampling (step 6)
The diffusion objective, as the paper writes it following Diffusion Model and DDPM, is
where is a clean latent, is Gaussian noise, is the noise schedule's cumulative signal factor, and is the network. The timestep is drawn from . With data-parallel ranks, explicit uniform sampling gives rank its own interval and draws uniformly inside it. Independent random draws on each rank can cluster and make the loss jump; this scheme spreads them out.
The paper also uses v-prediction and zero terminal signal-to-noise ratio, which change what the network is asked to output at the final noise level. They are named in the paper's training section and are not re-derived here.
Results
Automated metrics. On the VBench-style suite the paper reports, CogVideoX-5B is best on five of seven metrics and competitive on the other two. Its Dynamic Quality score is 69.5, against 43.6 for VideoCrafter-2.0 and 57.7 for Show-1 in the same table. The 2B model has the highest Dynamic Degree (66.39), above the 5B model's 62.22. Dynamic metrics matter here because some scores reward nearly static clips, so the authors add them on purpose.
Human study. Evaluators scored Sensory Quality, Instruction Following, Physics Simulation and Cover Quality on a 0, 0.5 or 1 scale. CogVideoX-5B beats Kling (2024.7) on all four, with a total of 2.74 against 2.17. VAE. On 256 by 256, 17-frame WebVid validation clips, the paper's 3D VAE has the lowest flicker (85.5) and the highest PSNR (29.1) of the three compared, against 92.4 and 28.5 for Open-Sora.
Cost. For 768 by 1360 pixels and 5 seconds on an H800 with 50 steps, the table reports 500 seconds and 76 GB for the 5B model, and 220 seconds and 53 GB for the 2B model. That is about 2.3 times the time and 1.4 times the memory. Try it: how many GB more does the 5B model use at this setting? Answer: 76 minus 53, which is 23 GB.
Ablations. Full 3D attention beat 2D plus 1D attention, which was less stable and collapsed more often as the model grew. Expert normalisation matched or beat MMDiT with fewer parameters. Explicit uniform sampling gave a steadier loss at every timestep. A 16 by 16 by 8 VAE compression made training very hard to converge, so the authors kept 8 by 8 by 4.
Limits. The main comparisons are the authors' own, the human study uses one closed competitor, and the paper says more compression and larger models are future work. The scaling claim in the introduction is a hope based on the two sizes, not a measured law. Choosing 5B over 2B is a budget decision: the 5B model costs more time and memory for most, though not all, axes.
Common mistakes the paper's choices avoid. A more compressed video is not automatically better, because the reconstruction and training cost rise. Full attention is not automatically too expensive: FlashAttention (see FlashAttention: Fast and Memory-Efficient Exact Attention) makes it affordable in this setting. Text and video do not automatically need separate transformers, as in MMDiT, because the expert normalisation does the job with fewer parameters. The recipe pays off for clips of several seconds with real motion, and is overkill for short or low-resolution clips, where a smaller model or an image-based method is cheaper. See Flow Matching for a different training objective.
Reading guide
- Section 1 (Introduction): the claims and the three contributions. Needs Diffusion Model and Transformer.
- Section 2.1 (3D Causal VAE): needs Variational Autoencoder and Kullback–Leibler Divergence.
- Section 2.2 (Expert Transformer): needs Rotary Position Embedding, Adaptive Layer Normalization and Diffusion Transformer (DiT).
- Section 3 (Training): needs Latent Diffusion Model. Section 3.3 needs the diffusion objective from Diffusion Model.
- Section 3.4 (Data): filtering and captioning. Needs no specific lesson beyond general data quality.
- Section 4 (Experiments): metrics and human study. Read Table 3 and Table 4 with the caveats above.
- Appendix A (Training details): hyperparameters, Tables 5 to 7.