Tencent-Hunyuan/Distillation

Model

10

stars

9

commits

2

linked in READMEs

Jun 19, 2024

updated

hunyuan-dit

README

HunyuanDiT Distillation Acceleration

Language: English | 中文

We provide a distillation version of HunyuanDiT for your inference acceleration.

Based on progressive distillation method, we accelerate Hunyuan-Dit two times without any performance drop. With the use of distillation model, It achieves the effect of halving the time consumption based on any inference mode.

The following table shows the requirements for running the distillation model and the acceleration performance of our distillation model (batch size = 1). We evaluate the accelaration on various GPU (like H800,A100, 3090, 4090) as well as different inference mode.

GPUCUDA versionmodelinference modeinference stepsGPU Peak Memoryinference time
H80012.1HunyuanDiTPyTorch10013G28s
H80012.1HunyuanDiTTensorRT10012G10s
H80012.1HunyuanDiTDistill+PyTorch5013G14s
H80012.1HunyuanDiTDistill+TensorRT5012G5s
A10011.7HunyuanDiTPyTorch10013GB54s
A10011.7HunyuanDiTTensorRT10011GB20s
A10011.7HunyuanDiTDistill+PyTorch5013GB25s
A10011.7HunyuanDiTDistill+TensorRT5011GB10s
309011.8HunyuanDiTPyTorch10014G98s
309011.8HunyuanDiTTensorRT10014G40s
309011.8HunyuanDiTDistill+PyTorch5014G49s
309011.8HunyuanDiTDistill+TensorRT5014G20s
409011.8HunyuanDiTPyTorch10014G54s
409011.8HunyuanDiTTensorRT10014G20s
409011.8HunyuanDiTDistill+PyTorch5014G27s
409011.8HunyuanDiTDistill+TensorRT5014G10s

Basically, the requirements for running the models is the same as the original model.

Instructions

The dependencies and installation are basically the same as the original model.

Then download the model using the following commands:

cd HunyuanDiT
# Use the huggingface-cli tool to download the model.
huggingface-cli download Tencent-Hunyuan/Distillation ./pytorch_model_distill.pt --local-dir ./ckpts/t2i/model

Inference

Using Gradio

Make sure you have activated the conda environment before running the following command.

# By default, we start a Chinese UI.
python app/hydit_app.py  --load-key distill 

# Using Flash Attention for acceleration.
python app/hydit_app.py --infer-mode fa --load-key distill   

# You can disable the enhancement model if the GPU memory is insufficient.
# The enhancement will be unavailable until you restart the app without the `--no-enhance` flag. 
python app/hydit_app.py --no-enhance ---load-key distill  

# Start with English UI
python app/hydit_app.py --lang en --load-key distill  

Using Command Line

We provide several commands to quick start:

# Prompt Enhancement + Text-to-Image. Torch mode
python sample_t2i.py --prompt "渔舟唱晚" --load-key distill  --infer-steps 50

# Only Text-to-Image. Torch mode
python sample_t2i.py --prompt "渔舟唱晚" --no-enhance --load-key distill  --infer-steps 50

# Only Text-to-Image. Flash Attention mode
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚" --load-key distill --infer-steps 50

# Generate an image with other image sizes.
python sample_t2i.py --prompt "渔舟唱晚" --image-size 1280 768 --load-key distill  --infer-steps 50

More example prompts can be found in example_prompts.txt

Contributors

Zhiminli

8 commits

xianbao

1 commits

Tencent-Hunyuan/Distillation

Model

10

stars

9

commits

2

linked in READMEs

Jun 19, 2024

updated

hunyuan-dit

README

HunyuanDiT Distillation Acceleration

Language: English | 中文

We provide a distillation version of HunyuanDiT for your inference acceleration.

Based on progressive distillation method, we accelerate Hunyuan-Dit two times without any performance drop. With the use of distillation model, It achieves the effect of halving the time consumption based on any inference mode.

The following table shows the requirements for running the distillation model and the acceleration performance of our distillation model (batch size = 1). We evaluate the accelaration on various GPU (like H800,A100, 3090, 4090) as well as different inference mode.

GPUCUDA versionmodelinference modeinference stepsGPU Peak Memoryinference time
H80012.1HunyuanDiTPyTorch10013G28s
H80012.1HunyuanDiTTensorRT10012G10s
H80012.1HunyuanDiTDistill+PyTorch5013G14s
H80012.1HunyuanDiTDistill+TensorRT5012G5s
A10011.7HunyuanDiTPyTorch10013GB54s
A10011.7HunyuanDiTTensorRT10011GB20s
A10011.7HunyuanDiTDistill+PyTorch5013GB25s
A10011.7HunyuanDiTDistill+TensorRT5011GB10s
309011.8HunyuanDiTPyTorch10014G98s
309011.8HunyuanDiTTensorRT10014G40s
309011.8HunyuanDiTDistill+PyTorch5014G49s
309011.8HunyuanDiTDistill+TensorRT5014G20s
409011.8HunyuanDiTPyTorch10014G54s
409011.8HunyuanDiTTensorRT10014G20s
409011.8HunyuanDiTDistill+PyTorch5014G27s
409011.8HunyuanDiTDistill+TensorRT5014G10s

Basically, the requirements for running the models is the same as the original model.

Instructions

The dependencies and installation are basically the same as the original model.

Then download the model using the following commands:

cd HunyuanDiT
# Use the huggingface-cli tool to download the model.
huggingface-cli download Tencent-Hunyuan/Distillation ./pytorch_model_distill.pt --local-dir ./ckpts/t2i/model

Inference

Using Gradio

Make sure you have activated the conda environment before running the following command.

# By default, we start a Chinese UI.
python app/hydit_app.py  --load-key distill 

# Using Flash Attention for acceleration.
python app/hydit_app.py --infer-mode fa --load-key distill   

# You can disable the enhancement model if the GPU memory is insufficient.
# The enhancement will be unavailable until you restart the app without the `--no-enhance` flag. 
python app/hydit_app.py --no-enhance ---load-key distill  

# Start with English UI
python app/hydit_app.py --lang en --load-key distill  

Using Command Line

We provide several commands to quick start:

# Prompt Enhancement + Text-to-Image. Torch mode
python sample_t2i.py --prompt "渔舟唱晚" --load-key distill  --infer-steps 50

# Only Text-to-Image. Torch mode
python sample_t2i.py --prompt "渔舟唱晚" --no-enhance --load-key distill  --infer-steps 50

# Only Text-to-Image. Flash Attention mode
python sample_t2i.py --infer-mode fa --prompt "渔舟唱晚" --load-key distill --infer-steps 50

# Generate an image with other image sizes.
python sample_t2i.py --prompt "渔舟唱晚" --image-size 1280 768 --load-key distill  --infer-steps 50

More example prompts can be found in example_prompts.txt

Contributors

Zhiminli

8 commits

xianbao

1 commits