8000 GitHub - ugonfor/DGQ: [ICLR 2025] DGQ: Distribution-Aware Group Quantization for Text-to-Image Diffusion Models · GitHub
[go: up one dir, main page]

Skip to content
ugonforPublic

About

[ICLR 2025] DGQ: Distribution-Aware Group Quantization for Text-to-Image Diffusion Models

Resources

Stars

20 stars

Watchers

2 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

DGQ: Distribution-Aware Group Quantization
for Text-to-Image Diffusion Models

Hyogon Ryu   ·   NaHyeon Park   ·   Hyunjung Shim*
Korea Advanced Institute of Science and Technology (KAIST)
*Corresponding Author

DGQ

TL;DR: We propose a distribution-aware group quantization method to preserve both image quality and text-to-image alignment in T2I diffusion models.


Update

  • 2025.01.26: Release the code for Stable Diffusion v1.4 and SDXL-turbo.
  • 2025.01.24: DGQ has been accepted to ICLR2025! We are working on releasing the code.

Requirements

conda env create -f ./environment.yaml
conda activate DGQ
pip install -e .
cd diffusers
pip install -e .

All experiments are conducted on NVIDIA RTX A6000 (CUDA v12.2)

How to use

Calibration and inference

  1. For weight quantization, use the following commands to the quantize weight or download the prequantized weight checkpoints on here.
# check the configurations in the shell script and run
bash scripts/quantize_weight.sh <model_type: sd/sdxl> <w_bits: 4/8>
  1. For test weight only quantized model, use following commands.
DIFFUSERS_REWRITE=<model_type: sd/sdxl> python src/inference_qmodel.py --cali_ckpt <path/to/cali_ckpt.pth_weight_only> --wq <w_bits: 4/8>
  1. Now, there are the weight quantized checkpoint, activation quantization could be performed. Use following commands to quantize act. Then, activation quantizer's checkpoints will be saved.
# check the configurations in the shell script and run
bash scripts/quantize_act.sh <model_type: sd/sdxl> <w_bits: 4/8> <a_bits: 6/8> <path/to/cali_ckpt.pth_weight_only> <group size: 1/8/16>
  1. Before inference the fully(weight and act.) quantized model, you should merge the two quantized checkpoints to one file. Use following command.
# first, copy the <cali_ckpt.pth_weight_only> file to the same folder in activation checkpoint(<cali_ckpt_activation_w?a?g?.pth>).
# Then, run the command.
python results/merge.py <path/to/cali_ckpt.pth_weight_only> <path/to/cali_ckpt_activation_w?a?g?.pth> 
  1. Finally, you can run the fully quantized model.
DIFFUSERS_REWRITE=<model_type: sd/sdxl> python src/inference_qmodel.py --cali_ckpt <path/to/cali_ckpt_activation_w?a?g?.pth_merged> --wq <w_bits: 4/8> --use_aq --aq <a_bits: 6/8> \
<--use_group> <--prompt "prompts"> <--fp16> <--t2i_log_quant> <--t2i_real_time> <--t2i_start_peak> <--time_aware_aqtizer>

Acknoledgement

This project is mainly built upon diffusers, BK-SDM, TFMQ-DM and Q-Diffusion. Thank you for sharing your codes.

Bibtex

@article{ryu2025dgq,
  title={DGQ: Distribution-Aware Group Quantization for Text-to-Image Diffusion Models},
  author={Ryu, Hyogon and Park, NaHyeon and Shim, Hyunjung},
  journal={arXiv preprint arXiv:2501.04304},
  year={2025}
}

About

[ICLR 2025] DGQ: Distribution-Aware Group Quantization for Text-to-Image Diffusion Models

Resources

Stars

20 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0