AWQ › The AWQ Algorithm
Language AI HandbookAll chapters AWQ › The AWQ AlgorithmOne section · Sections in this chapter3 / 11 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
AWQ determines optimal per-channel scaling factors by analyzing activation statistics from a small calibration dataset. Unlike GPTQ, which requires solving optimization problems involving Hessian matrices, AWQ relies on straightforward statistical measurements that can be computed efficiently in a single forward pass per calibration sample. The algorithm proceeds through four stages: activation collection, scale computation, weight transformation, and standard quantization.
Think of the overall algorithm as a three-phase engineering process. First, you diagnose the problem by measuring which channels carry the most signal. Second, you design a correction by computing scaling factors that shift quantization resolution toward those necessary channels. Third, you apply the correction by transforming the weights and absorbing the inverse transformation into the preceding layer. Each phase is simple on its own; the insight is in combining them.
Activation Statistics Collection
The first step is running a calibration set through the model and recording activation statistics. This calibration set need not be large; typically a few hundred to a few thousand examples suffice to obtain stable estimates of activation magnitudes. For general-purpose language models, any diverse text corpus gives reliable statistics. For domain-specific models, calibration data from the target domain produces better results.
For each linear layer in the model, we record the average absolute magnitude of each input channel across the calibration examples. Formally, for a layer receiving inputs where indexes the calibration sample and indexes the input channel:
where:
- : the average activation magnitude for input channel , serving as our proxy for channel importance during quantization
- : the total number of calibration samples used to estimate statistics
- : the activation value at channel for the -th calibration sample
- : the absolute magnitude, capturing signal strength regardless of sign (since both positive and negative activations amplify weight errors equally)
Taking the absolute value ensures we capture activation strength regardless of sign. A channel that alternates between large positive and large negative values is just as influential as one that is consistently large positive. Averaging across samples smooths out noise from individual examples and reveals the underlying pattern of which channels consistently carry strong signals across diverse inputs.
The averaging operation is important because any single input might happen to have unusual activation patterns. A question about chemistry might activate different channels than a question about sports. By averaging across many diverse examples, we obtain a stable estimate of each channel's typical importance under the model's actual usage distribution.
Computing Optimal Scaling Factors
Given activation statistics, AWQ computes per-channel scaling factors that balance two competing objectives. The first objective is to protect salient weights: channels with large activations should receive larger scaling factors, expanding the weights to occupy more of the quantization range and thus receive finer resolution. The second objective is to avoid harming other weights: extreme scaling factors can hurt non-salient weights by compressing their share of the quantization range too aggressively, potentially causing larger errors than the uniform quantization they started with.
Finding the right balance requires a formula that increases with activation magnitude but does not grow too aggressively for the highest-activation channels. If the scaling factor is proportional to the raw activation magnitude and one channel has activations ten times larger than the average, that channel would receive a scaling factor ten times larger, which could severely compress the remaining channels. AWQ addresses this by normalizing activation magnitudes and raising them to a fractional power:
where:
- : the calculated scaling factor for input channel , which will multiply the weights in column of the weight matrix
- : the average activation magnitude for channel , computed over the calibration set
- : the maximum average activation magnitude across all input channels , serving as the normalization reference
- : a hyperparameter in the range controlling scaling aggressiveness, balancing the protection of salient weights against potential distortion of others
The normalization by ensures that scaling factors lie in the range . The channel with the largest average activation receives a scaling factor of exactly 1 (unchanged). Every other channel receives a scaling factor strictly less than 1, meaning their weights get compressed relative to the most important channel rather than expanded. This design ensures the overall quantization range does not grow, which would hurt all channels.
The exponent gives a smooth tradeoff between the two objectives. When , the formula yields for all channels, and AWQ reduces to standard quantization without any activation-aware adjustment. When , scaling factors are directly proportional to relative activation magnitudes. This gives maximum differentiation between channels. In practice, values between 0.25 and 0.75 work well across different layer types, with the original AWQ paper using per-layer grid search to find optimal values.

When , all scaling factors collapse to 1 (no adjustment), and AWQ reduces to standard quantization without any activation-aware optimization. When , scaling factors are directly proportional to relative activation magnitudes. This gives maximum differentiation between channels. In practice, values between 0.25 and 0.75 work well, with the original AWQ paper using grid search to find optimal values per layer.
The shape of these curves is significant. For low values of alpha, the curve is relatively flat, meaning even channels with quite low activation magnitudes receive nearly the same scaling as high-activation channels. This is a conservative setting that avoids hurting any channel but gives weaker protection for the salient ones. For higher alpha values, the curve bends more sharply, putting higher scaling factors on channels that truly dominate in activation magnitude while sharply reducing protection for mediocre channels.
Weight Transformation and Quantization
With scaling factors computed, AWQ transforms the weights before applying standard quantization. The transformation is straightforward: for each input channel , the corresponding column of the weight matrix is multiplied by the scaling factor :
where:
- : the transformed (scaled) weight that will be fed into the quantization process
- : the original weight parameter from the pretrained model
- : the scaling factor for channel , expanding the weight's magnitude to utilize more of the quantization range
This multiplication stretches the weights for high-activation channels (those with close to 1) while compressing those for low-activation channels (those with small ). The resulting weight distribution concentrates the most important weights in a larger portion of the quantization range, where they benefit from finer resolution.
After applying channel scaling, AWQ applies standard group-wise INT4 quantization to the scaled weights. Within each quantization group (typically spanning 128 consecutive weights), the quantizer determines the scale and zero point that minimize quantization error for the group:
where:
- : the integer-quantized weight stored in the 4-bit representation
- : the scaled weight being quantized
- : the quantization scale for the weight group, mapping from real values to integers
- : the zero point for asymmetric quantization, letting the integer grid to stand for asymmetric value ranges
- : rounding to the nearest integer, which introduces quantization error
The rounding operation is where information is lost, as continuous values are mapped to the nearest point on a discrete grid with only representable levels. However, because salient weights have been scaled up relative to the group range, they now occupy proportionally more of those 16 levels and thus suffer less relative error.
During inference, weights are dequantized on-the-fly before use:
The inverse channel scaling then recovers the effective weight in the original computation space:
The effective quantization error for the original weight is therefore:
where:
- : the effective quantization error in the original, unscaled weight space
- : the quantization step size for the group (approximately ), representing the minimum distinguishable difference in weight values
- : the channel scaling factor; larger values reduce the effective error for that channel proportionally
For salient channels where is large (close to 1 after normalization by the maximum), the effective error is the base quantization step. For non-salient channels where is small, the error is larger, but these errors are multiplied by small activation values during inference and therefore have less impact on the output. The output error for element from channel is approximately , which equals approximately .
The key insight of AWQ is now visible in the math. If is designed to be proportional to , then the output error contribution becomes approximately . AWQ redistributes quantization precision so that every channel contributes roughly equally to the total output error, rather than high-activation channels dominating the error.

Grid Search Optimization
While the formula-based scaling gives an excellent starting point, AWQ refines the scaling factors through a lightweight grid search over the exponent . The optimal value of varies across layers depending on their specific weight and activation distributions. Layers in earlier parts of a network may have very different activation profiles than layers in later parts, and a single global would be suboptimal for some.
For each layer, the grid search algorithm evaluates a small number of candidate values, typically five to ten evenly spaced values between 0 and 1. For each candidate, it computes the corresponding scaling factors, transforms and quantizes the layer's weights, and evaluates quantization error by running the calibration data through that layer and measuring the mean squared error between the original and quantized outputs:
where:
- : the mean squared output error for a given scaling exponent
- : the number of calibration samples
- : the original layer output for sample
- : the quantized layer output when using scaling factors derived from exponent
- : the squared Euclidean norm of the output error vector
The algorithm selects the that minimizes and uses the corresponding scaling factors for that layer. This per-layer optimization requires only a handful of forward passes through each layer, making the total additional cost negligible compared to the forward pass through the full model that happens anyway during activation collection.
This per-layer grid search adds minimal computational overhead since we're only searching over a handful of values, unlike GPTQ's expensive Hessian computations. The search space is tiny, requiring only a few forward passes through each layer to evaluate the candidates. The resulting layer-specific values allow AWQ to adapt to the heterogeneous structure of modern neural networks, where different layers may have very different activation and weight distributions. An attention query projection might benefit from more aggressive scaling than a feed-forward output projection, and the grid search discovers these differences automatically.