Post-training quantization (PTQ) lowers a trained model’s numeric precision to reduce memory use and potentially speed inference. Unlike quantization-aware training (QAT), PTQ is applied after training. Lower precision introduces quantization error, so deployment choices balance model size and speed against accuracy. section 6.2
Common 8-bit approaches map values to integers in different ways:
- Zero-point quantization scales values using the input range and accounts for asymmetric distributions. section 6.2
- Absmax quantization scales values relative to the tensor’s largest absolute value. section 6.2
A practical check compares original and quantized weights, then evaluates model behavior. Weight distributions reveal differences, while generation and perplexity offer ways to assess effects; a sample output alone is not a reliable quality judgment. section 6.2.1
import torch
def absmax_quantize(X):
scale = 127 / torch.max(torch.abs(X))
X_quant = (scale * X).round()
X_dequant = X_quant / scale
return X_quant.to(torch.int8), X_dequant
Absmax function that returns INT8 values and their dequantized approximation. section 6.2.1

