Round-to-Nearest & Basic Weight Quantization
The simplest quantization method: round-to-nearest (RTN), per-channel vs per-tensor scaling, absmax and zeropoint calibration, and understanding when naive quantization works and when it fails.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Round-to-Nearest (RTN)
- Per-Tensor vs Per-Channel
- Absmax (Symmetric) Quantization
- Zero-Point (Asymmetric) Quantization
- When RTN Works
- When RTN Fails: The Outlier Problem
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Implement symmetric and asymmetric round-to-nearest quantization.
- Compute scale and zero-point from calibration data.
- Explain the quality degradation from per-tensor to per-channel to per-group granularity.
- Identify when RTN is sufficient (INT8 for large models) vs insufficient (INT4).
- Diagnose the activation outlier problem that breaks naive quantization.
Notation
- — quantized integer value
- — scale factor
- — zero-point offset
- — quantization range (e.g., for INT8)
Core Intuition
Round-to-nearest is the simplest approach: find a linear mapping from the weight range to the integer range, round each weight to its nearest integer level, and store the integer + scale factor. It works surprisingly well for INT8 on large models because (1) INT8 has 256 levels (fine-grained enough) and (2) individual rounding errors are independent and roughly cancel across a matrix-vector product.
Round-to-Nearest Quantization
Round-to-Nearest (RTN)
Quantize:
Dequantize:
Error per weight: .
Total error for a layer :
where is the number of weights per output neuron.
Per-Tensor vs Per-Channel
Per-tensor: One scale for the entire weight matrix.
Problem: If one row has weights in and another in , the first row gets quantized with 100x less precision than it needs.
Per-channel (per-output-channel): One scale per row of :
Each row uses its full quantization range independently.
Per-group: One scale per consecutive elements within a row:
Quality ranking: Per-group () > Per-group () > Per-channel > Per-tensor.
Storage overhead: Each scale is FP16 (2 bytes). Per-group with and INT4 weights: overhead = .
Absmax (Symmetric) Quantization
Symmetric: Zero-point , range centered at 0.
For INT8: .
Advantage: Simpler computation (no zero-point offset). Kernel implementation is faster.
Disadvantage: Wastes half the range if weights are all positive (e.g., after ReLU). The range is unused.
Best for: Weights (roughly symmetric around zero in well-trained models).
Zero-Point (Asymmetric) Quantization
Asymmetric: Use full range for the actual weight range :
Advantage: Uses all quantization levels — better precision for asymmetric distributions.
Disadvantage: Extra computation (subtract zero-point in dequantization). Slightly more complex kernels.
Best for: Activations (often non-negative after ReLU or asymmetrically distributed).
When RTN Works
INT8 per-channel on models above 1B parameters: Typically less than 0.5% accuracy loss.
Why it works:
- 256 levels is sufficient to represent most weight distributions.
- Per-channel scaling handles cross-channel variance.
- Large models have redundancy — small per-weight errors are absorbed.
- Rounding errors are approximately unbiased and independent.
Error scaling: For a matmul with input features, random quantization errors average out: (central limit theorem).
When RTN Fails: The Outlier Problem
INT4 RTN on any model: Significant quality degradation (5-20% accuracy loss).
Why it fails:
- Only 16 levels — too coarse for most weight distributions.
- Outlier weights force large scale → poor precision for majority of weights.
Activation outliers (Dettmers et al., 2022):
- In LLMs, certain channels develop activation magnitudes 100x larger than others.
- Per-tensor quantization of activations: outlier channels dominate the scale.
- Remaining channels get quantized to near-zero precision.
Example: If 99% of activations are in but one channel hits 100:
- Scale = .
- Values in only use levels — catastrophic precision loss.
Common Pitfalls
Pitfall 1. Applying per-tensor RTN to INT4. At 4 bits, per-tensor is far too coarse. Always use per-group () for INT4.
Pitfall 2. Using symmetric quantization for post-ReLU activations. All values are non-negative; symmetric wastes half the range. Use asymmetric.
Pitfall 3. Assuming RTN quality from INT8 papers transfers to INT4. The jump from 256 to 16 levels is qualitatively different — advanced methods (GPTQ, AWQ) become essential.
Summary
- RTN: Round each weight to nearest quantization level. Simplest method.
- Symmetric (absmax): Centered at zero; simpler; best for weights.
- Asymmetric (zeropoint): Uses full range; better for non-symmetric distributions.
- Granularity: Per-tensor → per-channel → per-group (increasing quality and overhead).
- Works well: INT8 per-channel on models above 1B.
- Fails: INT4 per-tensor; activations with outliers.
- Advanced methods (GPTQ, AWQ) are needed when RTN quality is insufficient.
Exercises
Exercise 1. Quantize the weight vector to INT4 symmetric. Compute the reconstruction error.
Exercise 2. Compare per-tensor vs per-channel INT8 quantization error for a weight matrix where row magnitudes vary by 10x.
Exercise 3. For INT4 with group size 128: compute total storage (weights + scales) for a 7B model with , and compare to FP16.
Exercise 4. Given activation values : show how one outlier destroys per-tensor INT8 quantization of the remaining values.
Exercise 5. Derive the expected MSE of RTN quantization for weights drawn from at bits with optimal symmetric range.