DMQ Balancer Algorithm

This algorithm applies to PTQ.

The Diagonal Matrix Quantization (DMQ) Balancer algorithm balances activations before calculating the quantization factors, and migrates part of the quantization difficulties from activations to weights. As shown in the following figure, X indicates activations, and W indicates weights.

The balancing principles are as follows:

  1. Calculate the balancing factor for each channel of the input activations of operators to be quantized.
  2. Divide activations by the balancing factor and multiply weights by the balancing factor to ensure that the calculation results of the operators to be quantized remain mathematically equivalent before and after balancing.