Data Generation for Hardware-Friendly Post-Training Quantization

Lior Dikstein, Ariel Lapid, Arnon Netzer, Hai Victor Habi
10/29/2024
cs.LG

No official code found. Best implementation: SonySemiconductorSolutions/mct-model-optimization (450 stars, Apache-2.0, PyTorch, last commit 2026-04-23). 1 more below.

Abstract

Zero-shot quantization (ZSQ) using synthetic data is a key approach for post-training quantization (PTQ) under privacy and security constraints. However, existing data generation methods often struggle to effectively generate data suitable for hardware-friendly quantization, where all model layers are quantized. We analyze existing data generation methods based on batch normalization (BN) matching and identify several gaps between synthetic and real data: 1) Current generation algorithms do not optimize the entire synthetic dataset simultaneously; 2) Data augmentations applied during training are often overlooked; and 3) A distribution shift occurs in the final model layers due to the absence of BN in those layers. These gaps negatively impact ZSQ performance, particularly in hardware-friendly quantization scenarios. In this work, we propose Data Generation for Hardware-friendly quantization (DGH), a novel method that addresses these gaps. DGH jointly optimizes all generated images, regardless of the image set size or GPU memory constraints. To address data augmentation mismatches, DGH includes a preprocessing stage that mimics the augmentation process and enhances image quality by incorporating natural image priors. Finally, we propose a new distribution-stretching loss that aligns the support of the feature map distribution between real and synthetic data. This loss is applied to the model's output and can be adapted to various tasks. DGH demonstrates significant improvements in quantization performance across multiple tasks, achieving up to a 30% increase in accuracy for hardware-friendly ZSQ in both classification and object detection, often performing on par with real data.

View on arXivView PDF

Code Implementations(2)

PyTorchApache-2.0

Model Compression Toolkit (MCT) is an open source project for neural network model optimization under efficient, constrained hardware. This project provides researchers, developers, and engineers advanced quantization and compression tools for deploying state-of-the-art neural networks.

45080CSS, SCSSJun 21, 20216 months agoApache-2.0
deep-learningdeep-neural-networksedge-aimachine-learningnetwork-compression+8 more
ssi-research/DGHCommunity64%
Apache-2.0

This repository provides the Pytorch implementation of DGH as described in the paper "Data Generation for Hardware-Friendly Post-Training Quantization". DGH is a method for generating images designed to improve model performance in zero-shot quantization.

43PythonOct 21, 20241 years agoApache-2.0

Cite this paper

@article{dikstein2024data,
  title  = {Data Generation for Hardware-Friendly Post-Training Quantization},
  author = {Lior Dikstein and Ariel Lapid and Arnon Netzer and Hai Victor Habi},
  year   = {2024},
  eprint = {2410.22110},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.22110v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2410.22110.svg)](https://codeofpaper.com/paper/2410.22110)

Discussion