Compare commits

...
1 Commits
Author SHA1 Message Date
Hao Zhang e8986b0b79 hao test 2025-04-09 08:46:18 +00:00
9 changed files with 27 additions and 14 deletions
+3 -1
View File
@@ -2,7 +2,9 @@
# 🔧 Installation # 🔧 Installation
The code is tested on Python 3.10.0, CUDA 12.4 and H100. The code is tested on Python 3.10.0, CUDA 12.4 and H100.
``` ```
./env_setup.sh fastvideo ./env_setup.sh fastvideo
``` ```
To try Sliding Tile Attention (optional), please follow the instruction in [here](#sta-installation) to install STA.
To try Sliding Tile Attention (optional), please follow the instruction in [here](#sta-installation) to install STA.
+6 -5
View File
@@ -3,30 +3,31 @@
# FastHunyuan # FastHunyuan
## Inference FastHunyuan on single RTX4090 ## Inference FastHunyuan on single RTX4090
We now support NF4 and LLM-INT8 quantized inference using BitsAndBytes for FastHunyuan. With NF4 quantization, inference can be performed on a single RTX 4090 GPU, requiring just 20GB of VRAM. We now support NF4 and LLM-INT8 quantized inference using BitsAndBytes for FastHunyuan. With NF4 quantization, inference can be performed on a single RTX 4090 GPU, requiring just 20GB of VRAM.
```bash ```bash
# Download the model weight # Download the model weight
python scripts/huggingface/download_hf.py --repo_id=FastVideo/FastHunyuan-diffusers --local_dir=data/FastHunyuan-diffusers --repo_type=model python scripts/huggingface/download_hf.py --repo_id=FastVideo/FastHunyuan-diffusers --local_dir=data/FastHunyuan-diffusers --repo_type=model
# CLI inference # CLI inference
bash scripts/inference/inference_hunyuan_hf_quantization.sh bash scripts/inference/inference_hunyuan_hf_quantization.sh
``` ```
For more information about the VRAM requirements for BitsAndBytes quantization, please refer to the table below (timing measured on an H100 GPU):
For more information about the VRAM requirements for BitsAndBytes quantization, please refer to the table below (timing measured on an H100 GPU):
| Configuration | Memory to Init Transformer | Peak Memory After Init Pipeline (Denoise) | Diffusion Time | End-to-End Time | | Configuration | Memory to Init Transformer | Peak Memory After Init Pipeline (Denoise) | Diffusion Time | End-to-End Time |
|--------------------------------|----------------------------|--------------------------------------------|----------------|-----------------| |--------------------------------|----------------------------|--------------------------------------------|----------------|-----------------|
| BF16 + Pipeline CPU Offload | 23.883G | 33.744G | 81s | 121.5s | | BF16 + Pipeline CPU Offload | 23.883G | 33.744G | 81s | 121.5s |
| INT8 + Pipeline CPU Offload | 13.911G | 27.979G | 88s | 116.7s | | INT8 + Pipeline CPU Offload | 13.911G | 27.979G | 88s | 116.7s |
| NF4 + Pipeline CPU Offload | 9.453G | 19.26G | 78s | 114.5s | | NF4 + Pipeline CPU Offload | 9.453G | 19.26G | 78s | 114.5s |
For improved quality in generated videos, we recommend using a GPU with 80GB of memory to run the BF16 model with the original Hunyuan pipeline. To execute the inference, use the following section: For improved quality in generated videos, we recommend using a GPU with 80GB of memory to run the BF16 model with the original Hunyuan pipeline. To execute the inference, use the following section:
## FastHunyuan ## FastHunyuan
```bash ```bash
# Download the model weight # Download the model weight
python scripts/huggingface/download_hf.py --repo_id=FastVideo/FastHunyuan --local_dir=data/FastHunyuan --repo_type=model python scripts/huggingface/download_hf.py --repo_id=FastVideo/FastHunyuan --local_dir=data/FastHunyuan --repo_type=model
# CLI inference # CLI inference
bash scripts/inference/inference_hunyuan.sh bash scripts/inference/inference_hunyuan.sh
``` ```
You can also inference FastHunyuan in the [official Hunyuan github](https://github.com/Tencent/HunyuanVideo).
You can also inference FastHunyuan in the [official Hunyuan github](https://github.com/Tencent/HunyuanVideo).
+1 -1
View File
@@ -6,4 +6,4 @@
# Download the model weight # Download the model weight
python scripts/huggingface/download_hf.py --repo_id=FastVideo/FastMochi-diffusers --local_dir=data/FastMochi-diffusers --repo_type=model python scripts/huggingface/download_hf.py --repo_id=FastVideo/FastMochi-diffusers --local_dir=data/FastMochi-diffusers --repo_type=model
# CLI inference # CLI inference
bash scripts/inference/inference_mochi_sp.sh bash scripts/inference/inference_mochi_sp.sh
+4
View File
@@ -3,12 +3,16 @@
# HunyuanVideo # HunyuanVideo
## Inference HunyuanVideo with Sliding Tile Attention ## Inference HunyuanVideo with Sliding Tile Attention
First, download the model: First, download the model:
```bash ```bash
python scripts/huggingface/download_hf.py --repo_id=FastVideo/hunyuan --local_dir=data/hunyuan --repo_type=model python scripts/huggingface/download_hf.py --repo_id=FastVideo/hunyuan --local_dir=data/hunyuan --repo_type=model
``` ```
We provide two examples in the following script to run inference with STA + [TeaCache](https://github.com/ali-vilab/TeaCache) and STA only. We provide two examples in the following script to run inference with STA + [TeaCache](https://github.com/ali-vilab/TeaCache) and STA only.
```bash ```bash
sh scripts/inference/inference_hunyuan_STA.sh sh scripts/inference/inference_hunyuan_STA.sh
``` ```
## Video Demos using STA + Teacache ## Video Demos using STA + Teacache
Visit our [demo website](https://fast-video.github.io/) to explore our complete collection of examples. We shorten a single video generation process from 945s to 317s on H100. Visit our [demo website](https://fast-video.github.io/) to explore our complete collection of examples. We shorten a single video generation process from 945s to 317s on H100.
+5 -2
View File
@@ -1,13 +1,16 @@
(stepvideo)= (stepvideo)=
# StepVideo # StepVideo
## Inference StepVideo with Sliding Tile Attention ## Inference StepVideo with Sliding Tile Attention
First, download the model: First, download the model:
``` ```
python scripts/huggingface/download_hf.py --repo_id=stepfun-ai/stepvideo-t2v --local_dir=data/stepvideo-t2v --repo_type=model python scripts/huggingface/download_hf.py --repo_id=stepfun-ai/stepvideo-t2v --local_dir=data/stepvideo-t2v --repo_type=model
``` ```
Use the following scripts to run inference for StepVideo. When using STA for inference, the generated videos will have dimensions of 204×768×768 (currently, this is the only supported shape). Use the following scripts to run inference for StepVideo. When using STA for inference, the generated videos will have dimensions of 204×768×768 (currently, this is the only supported shape).
```bash ```bash
sh scripts/inference/inference_stepvideo_STA.sh # Inference stepvideo with STA sh scripts/inference/inference_stepvideo_STA.sh # Inference stepvideo with STA
sh scripts/inference/inference_stepvideo.sh # Inference original stepvideo sh scripts/inference/inference_stepvideo.sh # Inference original stepvideo
``` ```
+2 -2
View File
@@ -1,11 +1,11 @@
(sta-demo)= (sta-demo)=
# Demo # Demo
There is a demo for 2D STA with window size (6,6) operating on a (10, 10) image. There is a demo for 2D STA with window size (6,6) operating on a (10, 10) image.
<div style="text-align: center;"> <div style="text-align: center;">
<video controls width="800"> <video controls width="800">
<source src="https://github.com/user-attachments/assets/f3b6dd79-7b43-4b60-a0fa-3d6495ec5747" type="video/mp4"> <source src="https://github.com/user-attachments/assets/f3b6dd79-7b43-4b60-a0fa-3d6495ec5747" type="video/mp4">
Your browser does not support the video tag. Your browser does not support the video tag.
</video> </video>
</div> </div>
@@ -13,11 +13,13 @@ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave
sudo apt update sudo apt update
sudo apt install clang-11 sudo apt install clang-11
``` ```
Install STA: Install STA:
```bash ```bash
export CUDA_HOME=/usr/local/cuda-12.4 export CUDA_HOME=/usr/local/cuda-12.4
export PATH=${CUDA_HOME}/bin:${PATH} export PATH=${CUDA_HOME}/bin:${PATH}
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
git submodule update --init --recursive git submodule update --init --recursive
python setup.py install python setup.py install
``` ```
+2 -1
View File
@@ -1,6 +1,7 @@
(sta-test)= (sta-test)=
# Test # Test
```bash ```bash
python test/test_sta.py python test/test_sta.py
``` ```
+1 -1
View File
@@ -14,4 +14,4 @@ out = sliding_tile_attention(q, k, v, window_size, text_length)
# If your attention does not contain text token (StepVideo) # If your attention does not contain text token (StepVideo)
out = sliding_tile_attention(q, k, v, window_size, 0, False) out = sliding_tile_attention(q, k, v, window_size, 0, False)
``` ```