HGQ2: High Granularity Quantization 2
A quantization-aware training framework built on Keras 3 that optimizes neural-network bit-widths by gradient, down to a per-weight and per-activation level, for real-time deep learning on FPGAs and other edge devices.
HGQ2 optimizes bit-widths for quantized neural networks using gradients rather than manual tuning, at any granularity up to per-weight and per-activation, and reports an EBOPs resource estimate that tracks actual FPGA usage, either an upper bound on LUTs through da4ml or LUT-plus-DSP through hls4ml. Models trained with it convert to RTL such that the RTL output matches the Keras model's output, subject to floating-point precision limits.
It runs on TensorFlow, JAX or PyTorch, with JAX and TensorFlow benefiting from XLA compilation; training is reported to be 1.2 to 5 times faster than the previous HGQ implementation. It supports multiple ways of parameterizing fixed-point quantizers plus an alpha-quality minifloat quantizer with surrogate-gradient support, and adds support for more layer types, including EinsumDense with batch normalization and MultiHeadAttention with bit-accurate softmax and scaled dot-product attention.
It installs with pip, with optional da4ml (0.6 or newer) or hls4ml (1.2 or newer) for deployment to FPGA targets.