Views
No views yet
| Model Name | CogVideoX1.5-5B (Latest) | CogVideoX1.5-5B-I2V (Latest) | CogVideoX-2B | CogVideoX-5B | CogVideoX-5B-I2V |
|---|---|---|---|---|---|
| Release Date | November 8, 2024 | November 8, 2024 | August 6, 2024 | August 27, 2024 | September 19, 2024 |
| Video Resolution | 1360 * 768 | Min(W, H) = 768 768 ≤ Max(W, H) ≤ 1360 Max(W, H) % 16 = 0 | 720 * 480 | ||
| Number of Frames | Should be 16N + 1 where N <= 10 (default 81) | Should be 8N + 1 where N <= 6 (default 49) | |||
| Inference Precision | BF16 (Recommended), FP16, FP32, FP8*, INT8, Not supported: INT4 | FP16*(Recommended), BF16, FP32, FP8*, INT8, Not supported: INT4 | BF16 (Recommended), FP16, FP32, FP8*, INT8, Not supported: INT4 | ||
| Single GPU Memory Usage | SAT BF16: 76GB diffusers BF16: from 10GB* diffusers INT8(torchao): from 7GB* | SAT FP16: 18GB diffusers FP16: 4GB minimum* diffusers INT8 (torchao): 3.6GB minimum* | SAT BF16: 26GB diffusers BF16 : 5GB minimum* diffusers INT8 (torchao): 4.4GB minimum* | ||
| Multi-GPU Memory Usage | BF16: 24GB* using diffusers | FP16: 10GB* using diffusers | BF16: 15GB* using diffusers | ||
| Inference Speed (Step = 50, FP/BF16) | Single A100: ~1000 seconds (5-second video) Single H100: ~550 seconds (5-second video) | Single A100: ~90 seconds Single H100: ~45 seconds | Single A100: ~180 seconds Single H100: ~90 seconds | ||
| Prompt Language | English* | ||||
| Prompt Token Limit | 224 Tokens | 226 Tokens | |||
| Video Length | 5 seconds or 10 seconds | 6 seconds | |||
| Frame Rate | 16 frames / second | 8 frames / second | |||
| Position Encoding | 3d_rope_pos_embed | 3d_sincos_pos_embed | 3d_rope_pos_embed | 3d_rope_pos_embed + learnable_pos_embed | |
| Download Link (Diffusers) | 🤗 HuggingFace 🤖 ModelScope 🟣 WiseModel | 🤗 HuggingFace 🤖 ModelScope 🟣 WiseModel | 🤗 HuggingFace 🤖 ModelScope 🟣 WiseModel | 🤗 HuggingFace 🤖 ModelScope 🟣 WiseModel | 🤗 HuggingFace 🤖 ModelScope 🟣 WiseModel |
| Download Link (SAT) | 🤗 HuggingFace 🤖 ModelScope 🟣 WiseModel | SAT |
diffusers library enabled all optimizations included in the library. This scheme has not been
tested on non-NVIDIA A100/H100 devices. It should generally work with all NVIDIA Ampere architecture or higher
devices. Disabling optimizations can triple VRAM usage but increase speed by 3-4 times. You can selectively disable
certain optimizations, including:pipe.enable_sequential_cpu_offload()
pipe.vae.enable_slicing()
pipe.vae.enable_tiling()enable_sequential_cpu_offload() optimization needs to be disabled.torch.compile,
significantly improving inference speed. FP8 precision is required for NVIDIA H100 and above, which requires source
installation of torch, torchao, diffusers, and accelerate. Using CUDA 12.4 is recommended.diffusers versions of models support quantization.1# diffusers (from source)
2# transformers>=4.46.2
3# accelerate>=1.1.1
4# imageio-ffmpeg>=0.5.1
5pip install git+https://github.com/huggingface/diffusers
6pip install --upgrade transformers accelerate diffusers imageio-ffmpeg1import torch
2from diffusers import CogVideoXPipeline
3from diffusers.utils import export_to_video
4
5prompt = "A panda, dressed in a small, red jacket and a tiny hat, sits on a wooden stool in a serene bamboo forest. The panda's fluffy paws strum a miniature acoustic guitar, producing soft, melodic tunes. Nearby, a few other pandas gather, watching curiously and some clapping in rhythm. Sunlight filters through the tall bamboo, casting a gentle glow on the scene. The panda's face is expressive, showing concentration and joy as it plays. The background includes a small, flowing stream and vibrant green foliage, enhancing the peaceful and magical atmosphere of this unique musical performance."
6
7pipe = CogVideoXPipeline.from_pretrained(
8 "THUDM/CogVideoX1.5-5B",
9 torch_dtype=torch.bfloat16
10)
11
12pipe.enable_sequential_cpu_offload()
13pipe.vae.enable_tiling()
14pipe.vae.enable_slicing()
15
16video = pipe(
17 prompt=prompt,
18 num_videos_per_prompt=1,
19 num_inference_steps=50,
20 num_frames=81,
21 guidance_scale=6,
22 generator=torch.Generator(device="cuda").manual_seed(42),
23).frames[0]
24
25export_to_video(video, "output.mp4", fps=8)torch.compile, which can significantly accelerate inference.1# To get started, PytorchAO needs to be installed from the GitHub source and PyTorch Nightly.
2# Source and nightly installation is only required until the next release.
3
4import torch
5from diffusers import AutoencoderKLCogVideoX, CogVideoXTransformer3DModel, CogVideoXImageToVideoPipeline
6from diffusers.utils import export_to_video
7from transformers import T5EncoderModel
8from torchao.quantization import quantize_, int8_weight_only
9
10quantization = int8_weight_only
11
12text_encoder = T5EncoderModel.from_pretrained("THUDM/CogVideoX1.5-5B", subfolder="text_encoder",
13 torch_dtype=torch.bfloat16)
14quantize_(text_encoder, quantization())
15
16transformer = CogVideoXTransformer3DModel.from_pretrained("THUDM/CogVideoX1.5-5B", subfolder="transformer",
17 torch_dtype=torch.bfloat16)
18quantize_(transformer, quantization())
19
20vae = AutoencoderKLCogVideoX.from_pretrained("THUDM/CogVideoX1.5-5B", subfolder="vae", torch_dtype=torch.bfloat16)
21quantize_(vae, quantization())
22
23# Create pipeline and run inference
24pipe = CogVideoXImageToVideoPipeline.from_pretrained(
25 "THUDM/CogVideoX1.5-5B",
26 text_encoder=text_encoder,
27 transformer=transformer,
28 vae=vae,
29 torch_dtype=torch.bfloat16,
30)
31
32pipe.enable_model_cpu_offload()
33pipe.vae.enable_tiling()
34pipe.vae.enable_slicing()
35
36prompt = "A little girl is riding a bicycle at high speed. Focused, detailed, realistic."
37video = pipe(
38 prompt=prompt,
39 num_videos_per_prompt=1,
40 num_inference_steps=50,
41 num_frames=81,
42 guidance_scale=6,
43 generator=torch.Generator(device="cuda").manual_seed(42),
44).frames[0]
45
46export_to_video(video, "output.mp4", fps=8)@article{yang2024cogvideox,
title={CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer},
author={Yang, Zhuoyi and Teng, Jiayan and Zheng, Wendi and Ding, Ming and Huang, Shiyu and Xu, Jiazheng and Yang, Yuanming and Hong, Wenyi and Zhang, Xiaohan and Feng, Guanyu and others},
journal={arXiv preprint arXiv:2408.06072},
year={2024}
}