HunyuanVideo: A Systematic Framework For Large Video Generation Model
Merge branch 'main' into 1205v2
feifeibearb3f7473552d1
diff --cc README.mdindex 114a1d4,fd9d3b6..728caca--- a/README.md+++ b/README.md@@@ -265,107 -265,8 +266,107 @@@ We list some more useful configuration| `--save-path` | ./results | Path to save the generated video |+## Parallel Inference on Multiple GPUs by xDiT++[xDiT](https://github.com/xdit-project/xDiT) is a Scalable Inference Engine for Diffusion Transformers (DiTs) on multi-GPU Clusters.+It has successfully provide low latency parallel infernece solution for a varitey of DiTs models, including mochi-1, CogVideoX, Flux.1, SD3, etc. This repo adoped the [Unified Sequence Parallelism (USP)](https://arxiv.org/abs/2405.07719) APIs for parallel inference of the HunyuanVideo model.++### Install Dependencies Compatible with xDiT++```+# 1. create a black conda environment+conda create -n hunyuanxdit python==3.10.9+conda activate hunyuanxdit++# 3. Install PyTorch component with CUDA 11.8+conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia++# 3. Install pip dependencies+python -m pip install -r requirements_xdit.txt+```++You can skip the above steps and pull the pre-built docker image directly, which is built from [docker/Dockerfile_xDiT](./docker/Dockerfile_xDiT)++```+docker pull thufeifeibear/hunyuanvideo:latest+```++### Using Command Line++For example, to generate a video with 8 GPUs, you can use the following command:++```bash+cd HunyuanVideo++torchrun --nproc_per_node=8 sample_video.py \+ --video-size 1280 720 \+ --video-length 129 \+ --infer-steps 50 \+ --prompt "A cat walks on the grass, realistic style." \+ --flow-reverse \+ --seed 42 \+ --ulysses-degree 8 \+ --ring-degree 1 \+ --save-path ./results+```++You can change the `--ulysses-degree` and `--ring-degree` to control the parallel configurations for the best performance. The valid parallel configurations are shown in the following table.++<details>+<summary>Supported Parallel Configurations (Click to expand)</summary>++| --video-size | --video-length | --ulysses-degree x --ring-degree | --nproc_per_node |+|----------------------|----------------|----------------------------------|------------------|+| 1280 720 or 720 1280 | 129 | 8x1,4x2,2x4,1x8 | 8 |+| 1280 720 or 720 1280 | 129 | 1x5 | 5 |+| 1280 720 or 720 1280 | 129 | 4x1,2x2,1x4 | 4 |+| 1280 720 or 720 1280 | 129 | 3x1,1x3 | 3 |+| 1280 720 or 720 1280 | 129 | 2x1,1x2 | 2 |+| 1104 832 or 832 1104 | 129 | 4x1,2x2,1x4 | 4 |+| 1104 832 or 832 1104 | 129 | 3x1,1x3 | 3 |+| 1104 832 or 832 1104 | 129 | 2x1,1x2 | 2 |+| 960 960 | 129 | 6x1,3x2,2x3,1x6 | 6 |+| 960 960 | 129 | 4x1,2x2,1x4 | 4 |+| 960 960 | 129 | 3x1,1x3 | 3 |+| 960 960 | 129 | 1x2,2x1 | 2 |+| 960 544 or 544 960 | 129 | 6x1,3x2,2x3,1x6 | 6 |+| 960 544 or 544 960 | 129 | 4x1,2x2,1x4 | 4 |+| 960 544 or 544 960 | 129 | 3x1,1x3 | 3 |+| 960 544 or 544 960 | 129 | 1x2,2x1 | 2 |+| 832 624 or 624 832 | 129 | 4x1,2x2,1x4 | 4 |+| 624 832 or 624 832 | 129 | 3x1,1x3 | 3 |+| 832 624 or 624 832 | 129 | 2x1,1x2 | 2 |+| 720 720 | 129 | 1x5 | 5 |+| 720 720 | 129 | 3x1,1x3 | 3 |++</details>+++<p align="center">+<table align="center">+<thead>+<tr>+ <th colspan="4">Latency (Sec) for 1280x720 (129 frames 50 steps) on 8xGPU</th>+</tr>+<tr>+ <th>1</th>+ <th>4</th>+ <th>8</th>+</tr>+</thead>+<tbody>+<tr>+ <th>1904.08</th>+ <th>514.08</th>+ <th>337.58</th>+</tr>++</tbody>+</table>+</p>+## 🔗 BibTeX- If you find [HunyuanVideo](https://github.com/Tencent/HunyuanVideo/blob/main/assets/hunyuanvideo.pdf) useful for your research and applications, please cite using this BibTeX:+ If you find [HunyuanVideo](https://arxiv.org/abs/2412.03603) useful for your research and applications, please cite using this BibTeX:```BibTeX@misc{kong2024hunyuanvideo,diff --cc README_zh.mdindex d0e0068,91d7e7f..2e52a7d--- a/README_zh.md+++ b/README_zh.md@@@ -252,84 -255,8 +254,84 @@@ python3 sample_video.py| `--save-path` | ./results | 保存路径 |+## 使用 xDiT 实现多卡并行推理++[xDiT](https://github.com/xdit-project/xDiT) 是一个针对多 GPU 集群的扩展推理引擎,用于扩展 Transformers(DiTs)。+它成功为各种 DiT 模型(包括 mochi-1、CogVideoX、Flux.1、SD3 等)提供了低延迟的并行推理解决方案。该存储库采用了 [Unified Sequence Parallelism (USP)](https://arxiv.org/abs/2405.07719) API 用于混元视频模型的并行推理。++### 安装与 xDiT 兼容的依赖项++```+# 1. 创建一个空白的 conda 环境+conda create -n hunyuanxdit python==3.10.9+conda activate hunyuanxdit++# 2. 使用 CUDA 11.8 安装 PyTorch 组件+conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia++# 3. 安装 pip 依赖项+python -m pip install -r requirements_xdit.txt+```++您可以跳过上述步骤,直接拉取预构建的 Docker 镜像,这个镜像是从 [docker/Dockerfile_xDiT](./docker/Dockerfile_xDiT) 构建的++```+docker pull thufeifeibear/hunyuanvideo:latest+```++### 使用命令行++例如,可用如下命令使用8张GPU卡完成推理++```bash+cd HunyuanVideo++torchrun --nproc_per_node=8 sample_video_parallel.py \+ --video-size 1280 720 \+ --video-length 129 \+ --infer-steps 50 \+ --prompt "A cat walks on the grass, realistic style." \+ --flow-reverse \+ --seed 42 \+ --ulysses_degree 8 \+ --ring_degree 1 \+ --save-path ./results+```++可以配置`--ulysses-degree`和`--ring-degree`来控制并行配置,可选参数如下。++<details>+<summary>支持的并行配置 (点击查看详情)</summary>++| --video-size | --video-length | --ulysses-degree x --ring-degree | --nproc_per_node |+|----------------------|----------------|----------------------------------|------------------|+| 1280 720 或 720 1280 | 129 | 8x1,4x2,2x4,1x8 | 8 |+| 1280 720 或 720 1280 | 129 | 1x5 | 5 |+| 1280 720 或 720 1280 | 129 | 4x1,2x2,1x4 | 4 |+| 1280 720 或 720 1280 | 129 | 3x1,1x3 | 3 |+| 1280 720 或 720 1280 | 129 | 2x1,1x2 | 2 |+| 1104 832 或 832 1104 | 129 | 4x1,2x2,1x4 | 4 |+| 1104 832 或 832 1104 | 129 | 3x1,1x3 | 3 |+| 1104 832 或 832 1104 | 129 | 2x1,1x2 | 2 |+| 960 960 | 129 | 6x1,3x2,2x3,1x6 | 6 |+| 960 960 | 129 | 4x1,2x2,1x4 | 4 |+| 960 960 | 129 | 3x1,1x3 | 3 |+| 960 960 | 129 | 1x2,2x1 | 2 |+| 960 544 或 544 960 | 129 | 6x1,3x2,2x3,1x6 | 6 |+| 960 544 或 544 960 | 129 | 4x1,2x2,1x4 | 4 |+| 960 544 或 544 960 | 129 | 3x1,1x3 | 3 |+| 960 544 或 544 960 | 129 | 1x2,2x1 | 2 |+| 832 624 或 624 832 | 129 | 4x1,2x2,1x4 | 4 |+| 624 832 或 624 832 | 129 | 3x1,1x3 | 3 |+| 832 624 或 624 832 | 129 | 2x1,1x2 | 2 |+| 720 720 | 129 | 1x5 | 5 |+| 720 720 | 129 | 3x1,1x3 | 3 |++</details>++## 🔗 BibTeX- 如果您认为 [HunyuanVideo](https://github.com/Tencent/HunyuanVideo/blob/main/assets/hunyuanvideo.pdf) 给您的研究和应用带来了一些帮助,可以通过下面的方式来引用:+ 如果您认为 [HunyuanVideo](https://arxiv.org/abs/2412.03603) 给您的研究和应用带来了一些帮助,可以通过下面的方式来引用:```BibTeX@misc{kong2024hunyuanvideo,