Skip to content

Commit

Permalink
Fix (a2q+): clarifying code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
i-colbert committed Jan 24, 2024
1 parent c0aaadb commit 0893d22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/brevitas/quant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,12 @@ def accumulator_bit_width_impl(accumulator_bit_width):


class AccumulatorAwareZeroCenterWeightQuant(AccumulatorAwareWeightQuant):
"""Experimental improved accumulator-aware weight quantized based on: `A2Q+: Improving
Accumulator-Aware Weight Quantization`.
"""Experimental zero-centered accumulator-aware weight quantized based on:
`A2Q+: Improving Accumulator-Aware Weight Quantization`.
When compared to A2Q, A2Q+ changes the following:
(1) an added zero-centering constraint on the weights (i.e., `PreZeroCenterZeroPoint`)
(2) an improved l1-norm bound that is derived in the referenced paper
(1) added zero-centering constraint on the weights (i.e., `PreZeroCenterZeroPoint`)
(2) a more relaxed l1-norm bound that is derived in the referenced paper
"""
pre_scaling_impl = AccumulatorAwareZeroCenterParameterPreScaling
pre_zero_point_impl = PreZeroCenterZeroPoint
Expand Down
12 changes: 6 additions & 6 deletions src/brevitas/quant/scaled_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ class Int8AccumulatorAwareWeightQuant(AccumulatorAwareWeightQuant):

class Int8AccumulatorAwareZeroCenterWeightQuant(AccumulatorAwareZeroCenterWeightQuant):
"""
Experimental 8-bit narrow signed improved accumulator-aware integer weight quantizer with learned
per-channel scaling factors based on `A2Q+: Improving Accumulator-Aware Weight Quantization` by
I. Colbert, A. Pappalardo, J. Petri-Koenig, and Y. Umuroglu. The quantizer learns scaling factors
in the float domain and learns norm parameter g in the log domain with the round-to-zero rounding
function. The norm is clamped according the specified accumulator bit-width using zero-centered
weights. The zero-centering is done before rounding and clippnig.
Experimental 8-bit narrow signed zero-centered accumulator-aware integer weight quantizer with
learned per-channel scaling factors based on `A2Q+: Improving Accumulator-Aware Weight Quantization`
by I. Colbert, A. Pappalardo, J. Petri-Koenig, and Y. Umuroglu (https://arxiv.org/abs/2401.10432).
The quantizer learns scaling factors in the float domain and learns norm parameter g in the log domain
with the round-to-zero rounding function. The norm is clamped according the specified accumulator
bit-width using zero-centered weights. The zero-centering is done before rounding and clipping.
Examples:
>>> from brevitas.nn import QuantConv2d
Expand Down

0 comments on commit 0893d22

Please sign in to comment.