Home

Awesome

BitPack

BitPack is a practical tool that can efficiently save quantized neural network models with mixed bitwidth.

Installation

git clone https://github.com/Zhen-Dong/BitPack.git
cd BitPack

Usage

<p align="center"> <img src="illustration.png" width="560"> <br /> <br /> </p>

Quick Start

BitPack is handy to use on various quantization frameworks. Here we show a demo that applying BitPack to save mixed-precision model generated by HAWQ.

export CUDA_VISIBLE_DEVICES=0
python pack.py --input-int-file quantized_checkpoint.pth.tar --force-pack-fp
python unpack.py --input-packed-file packed_quantized_checkpoint.pth.tar --original-int-file quantized_checkpoint.pth.tar

To get a better sense of how BitPack works, we provide a simple test that compares the original tensor, the packed tensor, and the unpacked tensor in details.

cd bitpack
python bitpack_utils.py

Results of BitPack on ResNet50

Original PrecisionQuantizationOriginal Size(MB)Packed Size(MB)Compression Ratio
Floating PointMixed-Precision(4bit/8bit)10213.87.4x
8-bitMixed-Precision(2bit/8bit)267.93.3x

Special Notes

License

THIS SOFTWARE WAS DEPOSITED IN THE BAIR OPEN RESEARCH COMMONS REPOSITORY ON FEB 1, 2023.

BitPack is released under the MIT license.