AWQ › Worked Example: Tracing AWQ Through a Two-Channel Layer
Language AI HandbookAll chapters AWQ › Worked Example: Tracing AWQ Through a Two-Channel LayerOne section · Sections in this chapter4 / 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
Let's trace the AWQ algorithm step by step through a minimal example to make the mathematics concrete. We will work with a tiny linear layer with just two input channels and show exactly how quantization error changes when we apply AWQ versus naive round-to-nearest quantization.
Setup. Consider a linear layer with a single-row weight matrix (one output, two inputs). Suppose the calibration dataset gives us average activation magnitudes for channel 0 and for channel 1.
Step 1: Identify salient channels. The maximum activation magnitude across channels is (channel 0). The normalized magnitudes are and .
Step 2: Compute scaling factors with . Applying the AWQ formula:
Channel 0 (the salient channel) gets scaling factor 1.0. Channel 1 (the non-salient channel) gets scaling factor 0.1.
Step 3: Transform weights. Multiply each weight by its channel's scaling factor:
After scaling, the transformed weights are . Notice that the max weight has dropped from 2.0 to 0.5 because we compressed the unimportant channel materially.
Step 4: Quantize the transformed weights. With a 3-bit symmetric quantizer (7 levels for simplicity), the quantization scale is:
Quantizing each transformed weight:
Step 5: Dequantize and undo channel scaling. The effective weights recovered after inverse scaling are:
Step 6: Compute weighted quantization error. The output-weighted errors are:
Comparison with RTN. Without AWQ, standard RTN quantizes the original weights with scale :
The RTN weighted errors are:
The comparison is stark. RTN spends most of its quantization effort on channel 1 (the large weight) but channel 1 multiplies near-zero activations, so that accuracy is wasted. Meanwhile, channel 0 (the small weight that multiplies large activations) suffers a relative error of 33% that gets amplified by the activation magnitude of 10, creating an output error of 1.67. AWQ nearly eliminates this output error by giving channel 0 all the precision it needs, accepting a larger relative error on channel 1 where it barely matters.
This example captures the needed logic of AWQ in numerical form: precision is a resource to be allocated intelligently, not distributed uniformly.