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 principle is as follows:
- Calculate the balance factor for each channel of the input activations of operators to be quantized.
- Divide activations by the balance factor, and multiply the weights by the balance factor, so that the calculation results of the to-be-quantized operators are mathematically equivalent before and after balancing.
Parent topic: PTQ Algorithms