SynQ

February 7, 2025 · View on GitHub

This project is a PyTorch implementation of "SynQ: Accurate Zero-shot Quantization by Synthesis-aware Fine-tuning" (ICLR 2025). This paper proposes SynQ, an accurate Zero-shot Quantization (ZSQ) method.

Overall Architecture of SynQ

Prerequisites

Our implementation is based on PyTorch, TorchVision, and PyTorchCV libraries.

  • Python 3.9.12
  • PyTorch 1.13.1
  • PyTorchCV 0.0.67

We include requirements.txt, which contains all the packages used for the experiment. We also contain a working code for PyTorchCV library within src/pytorchcv to mitigate the dependency issue. We checked the dependency using a workstation with Intel Xeon Silver 4214 and RTX 3090, where its CUDA version is 11.6. Install the required packages with the following code:

pip install -r requirements.txt

Usage

For usage, first generate the synthetic dataset with the code under src/data_generate/. We include run_generate_cifar100.sh and run_generate_imagenet.sh, which generates the synthetic dataset using a ResNet-34 model pre-trained on CIFAR-100 and ImageNet datasets, respectively.

cd src/data_generate
# bash run_generate_cifar100.sh
bash run_generate_imagenet.sh

Second, fine-tune the quantized model by executing src/main_direct.py. We include run_imagenet.sh, for the 3bit Zero-shot Quantization (ZSQ) for ResNet-18 model pre-trained on the ImageNet dataset.

cd src/
bash run_imagenet.sh

To run with different settings, modify the config files under src/config/ or the arguments passed into src/data_generate/generate_data.py and src/main_direct.py.

Code Description

This repository is written based on the codes from ZeroQ (CVPR '20) [Github], HAST (CVPR '23) [Github], and a PyTorch implementation of Grad-CAM and Grad-CAM++ [Github].

Citation

You can download this bib file or copy the following information:

@inproceedings{KimKK25,
    title={SynQ: Accurate Zero-shot Quantization by Synthesis-aware Fine-tuning},
    author={Kim, Minjun and Kim, Jongjin and Kang, U},
    booktitle={The Thirteenth International Conference on Learning Representations},
    year={2025}
}