TL;DR
AWQ compresses a large language model so its weights take 4 bits each instead of 16, which makes it small enough to run on an edge device. It finds that only a tiny fraction of weight channels matter most, and it picks them by the size of the activations they multiply, not by the size of the weights. It then scales those channels up before rounding, which makes their rounding error smaller in relative terms, and it does not need any training or backpropagation. The result keeps accuracy close to the full-precision model and runs several times faster on common GPUs.
Builds on: Quantization, Post-Training Quantization, Perplexity · Leads to: Model Compression, Language Model, mixed-precision formats in hardware
Why it mattered
Large language models are too big for most devices. A model like GPT-3, with 175 billion parameters, takes about 350 GB in 16-bit floats, which is 175 billion weights times 2 bytes each. Running a model locally has real benefits: lower cloud cost, offline use and better privacy. AWQ made 4-bit weight quantization practical for these models without retraining. Its authors released TinyChat, a runtime for 4-bit models, and the method was taken up by several inference stacks; the paper lists HuggingFace Transformers, NVIDIA TensorRT-LLM, vLLM and others among the adopters. The paper received a best paper award at its venue, MLSys 2024.
The problem
Quantization stores a number with fewer bits. Rounding each weight to a coarse grid saves memory, but the rounding error changes the model's outputs. There are three familiar ways to cope.
- Quantization-aware training adds the rounding to training, so the network adjusts. It is accurate but costs a full training run, which is too expensive for models this size.
- Post-training quantization rounds the weights after training, without retraining. It is cheap, but at 3 or 4 bits with plain rounding the accuracy falls sharply. In the paper's Table 3, plain round-to-nearest at 3 bits raises the perplexity of OPT-6.7B from 10.86 to 23.54.
- Keeping a few weights in 16 bits protects the most important ones, and it works. But a model with two number formats is hard to run fast, because the hardware wants one format for the whole layer.
The question AWQ asks is how to protect the important weights without keeping them in a second format, and without any backpropagation or training.
How it works
The method has two observations and one search. Here is one tiny instance, a group of two weights feeding one output, rounded to a toy grid with a step of 0.125.
- Find the important channel by activation size. Two input channels feed a neuron. Channel 1 has weight w_1 = 0.06 and typical activation x_1 = 10. Channel 2 has weight w_2 = 0.50 and activation x_2 = 0.1. By weight size, channel 2 looks important. By activation size, channel 1 is the one that carries large signals. Check: channel 1 multiplies a large input, so an error in its weight is multiplied by a large number.
- Round the weights. The group's largest weight is 0.50, so the step size is delta = 0.50 divided by 4 = 0.125. Rounding w_1 = 0.06 to the grid gives 0, since 0.06 is less than half a step. Check: the contribution of channel 1 to the output is now 0, while it should be 0.06 times 10 = 0.6. That is an error of 0.6.
- Scale the salient channel up. Multiply w_1 by s = 2 and divide its input by 2. The weight becomes 0.12, the activation becomes 5, and the product is still 0.6. Check: the output is mathematically unchanged, so the scaling costs nothing before rounding.
- Round the scaled weights. The largest weight is still 0.50, so the step is still 0.125. The scaled weight 0.12 rounds to 0.125. Check: the effective weight is 0.125 divided by 2, which is 0.0625, and the contribution is 0.0625 times 10 = 0.625. The error drops from 0.6 to 0.025.
- Search the scale for each layer. The paper does not use s = 2 by hand. It searches for a per-channel scale that minimizes the output error of the whole layer on a small calibration set, using the activation size to set the shape of the search. Check: the search needs only a small calibration set and a single number per layer, so it is cheap next to training.
- Pack and run. The inverse scale is folded into the previous operation, so the stored weights are plain 4-bit integers and the runtime needs no second format. The layer then runs its usual matrix multiplication on these weights.
flowchart LR A[Calibration inputs] --> B[Average activation size per channel] B --> C[Search scale s = s_X to the power alpha] C --> D[Scale weights up, inputs down] D --> E[Round weights to 4 bits per group] E --> F[Fold inverse scale into previous op]
The math
Quantization and where the error comes from
Quantizing a group of weights uses a step size set by the largest magnitude in the group:
Here Round snaps each weight to the nearest multiple of delta. The tiny example uses delta = 0.50 / 4 = 0.125, a toy grid with four steps per side rather than an exact 3-bit format, so the arithmetic stays short.
For a single weight w and input x, the output error is delta times the rounding error times x, where the rounding error is the part of w divided by delta that the grid cannot represent. The paper's key observation is that the rounding error is roughly uniform between 0 and 0.5 steps, so on average it is about 0.25 of a step.
Step 3 and step 4 in symbols: the scaling trick
Multiply a weight by s greater than 1 and divide its input by s. The product is unchanged, but the error becomes
The paper argues that the step size Delta' is almost the same as Delta, because scaling one element rarely changes the group maximum. So the ratio of new error to old error is approximately
When s is greater than 1 and delta does not grow, this ratio is less than 1, so the salient channel's relative error shrinks. In the tiny example the ratio is 1 divided by 2, halving the error in relative terms, and the rounding happened to fall in a better place as well.
Scaling is not free. If s is very large, the group maximum grows, delta grows, and the other weights in that group get coarser rounding. The paper's Table 2 shows this: for OPT-6.7B, the perplexity improves from 23.54 at s = 1 to 11.92 at s = 2, and gets worse again at s = 4 (12.36), where 21.2 percent of groups have their step size enlarged by the scale. The best scale balances the two.
Step 5 in symbols: the search
AWQ chooses a per-channel scale s to minimize the change in the layer's output on calibration inputs X:
Here W is the original weight matrix, Q is the quantizer, and X is the cached input features from a small calibration set. Because Q is not differentiable, ordinary gradient descent does not apply. The paper therefore restricts the search to a simple family, where the scale depends on the average activation size s_X of each channel:
Alpha is a single number between 0 and 1. Alpha equal to 0 means no scaling, and alpha equal to 1 is the most aggressive scaling in the family. The paper searches a grid of 20 values of alpha over [0, 1]. For the tiny example, s_X = [10, 0.1]; alpha = 0.5 gives s about [3.16, 0.32], which points in the same direction as the scale of 2 found by hand.
Results
- Perplexity on OPT-6.7B at 3 bits, group size 128. The full-precision model scores 10.86. Plain rounding scores 23.54. Keeping 1 percent of weights in 16 bits scores 11.39. AWQ scores 11.39 as well, without the mixed format. The fixed scale of 2 alone scores 11.92.
- OPT-1.3B at 3 bits. The full model scores 14.62, plain rounding scores 119.47, the 1 percent mixed format scores 16.91, and AWQ scores 16.32, better than the mixed format.
- Multimodal model. On OpenFlamingo-9B, 32-shot COCO CIDEr at INT4 starts at 81.70 in FP16. Plain RTN loses 4.57 points, GPTQ loses 6.72, and AWQ loses 1.17.
- Calibration robustness. With a mismatched calibration set, AWQ's perplexity rises by 0.5 to 0.6, while GPTQ's rises by 2.3 to 4.9. AWQ uses 16 sequences from the Pile, versus 192 for GPTQ.
- Speed. TinyChat gives an average 3.2 to 3.3 times speedup over the Hugging Face FP16 implementation across desktop, laptop and mobile GPUs. On an RTX 4090 it gives 2.7 to 3.9 times across Llama-2, MPT and Falcon. The paper states that Llama-2-70B can be deployed on a Jetson Orin with 64 GB of memory, but gives no throughput figure for that case.
Read the limits with care. The speed numbers come from specific GPUs, and the perplexity numbers mostly from WikiText-style language modeling, so other tasks may differ. The calibration set is small and drawn from pre-training data on purpose, so the scales do not overfit one domain, but the authors do not claim that AWQ is free of accuracy loss at every bit width; the 3-bit results degrade more than the 4-bit results. AWQ quantizes only the weights, so activations stay in 16 bits.
Reading guide
- Section 1, introduction. The motivation for on-device models and the 350 GB example. Needs Language Model and Quantization.
- Section 2, related work. Quantization-aware training versus post-training quantization, and the comparison with GPTQ (GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transfor...), which uses second-order error correction. Needs Post-Training Quantization.
- Section 3.1, salient weights. The experiment in Table 1, which compares choosing channels by weight size, by activation size, and at random. Needs Perplexity.
- Section 3.2, scaling. The error analysis with the delta and rounding terms, Table 2, and the search over alpha. Read it with the tiny example beside you.
- Section 4, TinyChat. Memory-bound generation, kernel fusion and weight packing. Needs the roofline idea of arithmetic intensity, which is the ratio of arithmetic to memory traffic.
- Section 5, experiments. The perplexity and task tables, with the calibration-set ablation that tests overfitting.
Check yourself
QuestionHow does AWQ decide which weight channels are salient, and why does the paper say weight size is the wrong guide?Show answer
It uses the size of the activations that each channel multiplies. Skipping the rounding of channels with large weights gave little improvement, similar to random choice, while protecting channels with large activations gave a large improvement. Those channels carry the big input signals, so their weight errors matter most.
QuestionIn the tiny example, the weight is 0.06, the activation is 10, and the step size is 0.125. What is the output error on this channel without scaling, and with a scale of s = 2?Show answer
Without scaling, 0.06 rounds to 0, so the contribution is 0 instead of 0.6, an error of 0.6. With s = 2, the weight becomes 0.12, which rounds to 0.125, and the effective weight is 0.125 divided by 2, which is 0.0625. The contribution is 0.625 instead of 0.6, an error of 0.025.
QuestionWhy does AWQ scale salient channels up instead of keeping them in 16-bit precision, as the mixed-precision baseline does?Show answer
Keeping a few weights in 16 bits gives a layer two number formats, which is hard to run quickly on hardware that wants one format. Scaling keeps every weight in the same 4-bit format, and the inverse scale is folded into the previous operation, so the runtime stays fast while the error on the salient channels falls.
QuestionA team calibrates AWQ on a small set of chat transcripts and then deploys the model for code generation. What risk does the paper's design try to avoid, and what should the team do?Show answer
The risk is overfitting to the calibration set, so that the model loses accuracy on inputs unlike it. AWQ reduces this by drawing its small calibration set from general pre-training text (the Pile) and by searching only a one-parameter family of scales, so it is less tied to one domain. The team should use a calibration set that is broad rather than only chat, and should measure accuracy on code tasks before deployment, since the paper's claims are measured on the tasks it reports.
Sources
- Lin, Tang, Tang, Yang, Chen, Wang, Xiao, Dang, Gan, Han. "AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration" (2023): https://arxiv.org/abs/2306.00978
- Frantar, Ashkboos, Hoefler, Alistarh. "GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers" (2022): https://arxiv.org/abs/2210.17323
- Xiao, Lin, Seznec, Wu, Demouth, Han. "SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models" (2022): https://arxiv.org/abs/2211.10438