Skip to main content
HGQ-logo

Notice

HGQ 2 is now available! Please check out https://github.com/calad0i/HGQ2 for more details.

High Granularity Quantization

License Apache 2.0 Documentation PyPI version ArXiv

HGQ is an gradient-based automatic bitwidth optimization and quantization-aware training algorithm for neural networks to be deployed on FPGAs, By laveraging gradients, it allows for bitwidth optimization at arbitrary granularity, up to per-weight and per-activation level.

HGQ-overview

Compare to the other heterogeneous quantization approach, like the QKeras counterpart, HGQ provides the following advantages:

  • High Granularity: HGQ supports per-weight and per-activation bitwidth optimization, or any other lower granularity.
  • Automatic Quantization: By setting a resource regularization term, HGQ could automatically optimize the bitwidth of all parameters during training. Pruning is performed naturally when a bitwidth is reduced to 0.
  • Bit-accurate conversion to hls4ml: You get exactly what you get from Keras models from hls4ml models. HGQ provides a bit-accurate conversion interface, proxy models, for bit-accurate conversion to hls4ml models.
    • still subject to machine float precision limitation.
  • Accurate Resource Estimation: BOPs estimated by HGQ is roughly #LUTs + 55#DSPs for actual (post place & route) FPGA resource consumption. This metric is available during training, and one can estimate the resource consumption of the final model in a very early stage.

Depending on the specific application, HGQ could achieve up to 20x resource reduction compared to the AutoQkeras approach, while maintaining the same accuracy. For some more challenging tasks, where the model is already under-fitted, HGQ could still improve the performance under the same on-board resource consumption. For more details, please refer to our paper here.

Installation

You will need python>=3.10 and tensorflow>=2.13 to run this framework. You can install it via pip:

pip install hgq

Usage

Please refer to the documentation for more details.

Metadata

Release files for HGQ 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for HGQ 0.2.6
File Size Uploaded
hgq-0.2.6.tar.gz 97.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for HGQ 0.2.6
File Interpreter ABI Platform
hgq-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 147.3 kB

Release files / hgq-0.2.6.tar.gz

Download URL hgq-0.2.6.tar.gz
Size 97.8 kB
Tags Source
SHA-256 checksum
How to use checksums
13d3074f634fdcb73ae43e179ef49f3aa44bd9d84ef622685d0446404fcd973b
BLAKE2b-256 checksum
How to use checksums
8e0081f5e5f4bc0689a826908d1e40d112bb15e475790d02e37310fbfa8a12a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / hgq-0.2.6-py3-none-any.whl

Download URL hgq-0.2.6-py3-none-any.whl
Size 49.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56260b16a8ead7d9bcfd75ff0b128fc58224cc047ba6c701e6fd54a81cdb0af9
BLAKE2b-256 checksum
How to use checksums
346b82de1b7db922a694e386457315c0210f13b9892f5c4941a95b0676d7a2b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page