Simple Algorithm
Deep Learning · Emergence · 28 min

Quantization in Depth

Low-bit formats, outlier features, GPTQ and quantization-aware training.

Round every weight of OPT-175B to the nearest of sixteen levels and the model does worse than the full-precision OPT-13B, which is thirteen times smaller. Round the same weights one column at a time, letting the weights not yet rounded absorb each error, and the loss in perplexity shrinks to 0.03. Between those two outcomes lie the statistics of rounding error, the outlier features of large transformers, and a second-order idea first used in the early 1990s to prune networks.

What you’ll learn

  • Derive the Δ2/12\Delta^2/12 model of rounding error and the 6 dB-per-bit rule, and find the clipping range that balances rounding error against clipping error.
  • Derive the gradients of quantization-aware training, including the step-size gradient of learned step size quantization.
  • Explain why outlier features break 8-bit activation quantization in large transformers, and derive how LLM.int8(), SmoothQuant and random rotations avoid them.
  • Derive GPTQ's error-compensating update from the layer-wise quadratic objective, and explain AWQ's activation-aware scaling.
  • Weigh the evidence on how low weights can go: bit-level scaling laws, ternary models trained from scratch and precision-aware scaling laws.

The error of a uniform quantizer

DerivationBits, decibels and clipping
  1. E[e2]=1Δ∫−Δ/2Δ/2e2 de=Δ212\E[e^2]=\frac1\Delta\int_{-\Delta/2}^{\Delta/2}e^2\,de=\frac{\Delta^2}{12}

    The mean square of an error uniform on one cell:

  2. MSEround=α23⋅4b,SQNR=10log⁡10σx2MSE≈6.02 b+10log⁡103σx2α2  dB\text{MSE}_{\text{round}}=\frac{\alpha^2}{3\cdot4^{b}},\qquad\text{SQNR}=10\log_{10}\frac{\sigma_x^2}{\text{MSE}}\approx6.02\,b+10\log_{10}\frac{3\sigma_x^2}{\alpha^2}\ \ \text{dB}

    With 2b2^b cells across a clipping range [−α,α][-\alpha,\alpha], Δ=2α/2b\Delta=2\alpha/2^b. Each extra bit halves Δ\Delta and quarters the error, so the signal-to-quantization-noise ratio rises by 10log⁡104≈6.0210\log_{10}4\approx6.02 dB per bit:

  3. MSE(α)≈2c2e−α/c+α23⋅4b,d MSEdα=0 ⟹ α∗≈2.83c, 3.9c, 5.03c(b=2,3,4)\text{MSE}(\alpha)\approx2c^2e^{-\alpha/c}+\frac{\alpha^2}{3\cdot4^{b}},\qquad\frac{d\,\text{MSE}}{d\alpha}=0\ \Longrightarrow\ \alpha^*\approx2.83c,\ 3.9c,\ 5.03c\quad(b=2,3,4)

    Values beyond ±α\pm\alpha are clipped. For a Laplace density with scale cc each tail contributes ∫α∞(x−α)2e−x/c2cdx=c2e−α/c\int_\alpha^\infty(x-\alpha)^2\frac{e^{-x/c}}{2c}dx=c^2e^{-\alpha/c}, so the total trades a term that falls with α\alpha against one that grows (Banner et al., 2019):

  4. Clipping at the largest value, the natural default, is far from optimal. Among 10610^6 Laplace samples the largest is near cln⁡106≈13.8cc\ln10^6\approx13.8c; at 4 bits that range gives an MSE of 0.25c20.25c^2, against 0.046c20.046c^2 at α∗=5.03c\alpha^*=5.03c, five times less. The same calculation for a Gaussian puts the optimum near 1.71σ1.71\sigma, 2.15σ2.15\sigma and 2.56σ2.56\sigma at 2, 3 and 4 bits, and still only 3.9σ3.9\sigma at 8 bits.

Predict before you look

A 4-bit quantizer splits [−1,1][-1,1] into 16 equal cells and maps each value to its cell's midpoint. For xx uniform on [−1,1][-1,1], what is the mean squared error? Answer in units of 10−310^{-3}.

Show the answer

1.3 × 10⁻³

Δ=2/16=1/8\Delta=2/16=1/8, and with uniform input the error is exactly uniform on each cell, so MSE=Δ2/12=1/768≈1.30×10−3\text{MSE}=\Delta^2/12=1/768\approx1.30\times10^{-3}. Against the signal's variance of 1/31/3 that is an SQNR of 10log⁡10256≈24.110\log_{10}256\approx24.1 dB, the 6.026.02 dB per bit of the formula. A symmetric integer grid with codes −7-7 to 77 has only 15 levels, a step of 1/71/7 and an MSE of about 1.70×10−31.70\times10^{-3}.

Training through the rounding

Quantization-aware training, introduced in Model Compression & Efficient Inference, rounds in the forward pass and uses the straight-through estimator (Bengio, Léonard & Courville, 2013) in the backward pass. That handles the weights; the quantizer's own parameters, its step size and range, need gradients too. Esser et al. (2020) made the step size ss of every layer a trainable parameter, learned step size quantization (LSQ), and derived its gradient with the same estimator.

DerivationThe step-size gradient
  1. v^=s⋅round⁡(clip⁡(v/s, −QN, QP))\hat v=s\cdot\operatorname{round}\big(\operatorname{clip}(v/s,\,-Q_N,\,Q_P)\big)

    Write the quantizer with integer bounds −QN-Q_N and QPQ_P; for signed bb-bit weights QN=2b−1Q_N=2^{b-1} and QP=2b−1−1Q_P=2^{b-1}-1:

  2. ∂v^∂s=round⁡(vs)+s⋅∂∂s(vs)=round⁡(vs)−vs(−QN<v/s<QP)\frac{\partial\hat v}{\partial s}=\operatorname{round}\Big(\frac vs\Big)+s\cdot\frac{\partial}{\partial s}\Big(\frac vs\Big)=\operatorname{round}\Big(\frac vs\Big)-\frac vs\qquad\big(-Q_N<v/s<Q_P\big)

    Inside the range, differentiate the product. Keep the value of the rounding but give it unit slope, as the straight-through estimator does:

  3. In the clipped regions v^=−sQN\hat v=-sQ_N or sQPsQ_P, so the derivative is −QN-Q_N or QPQ_P. The interior term is the signed distance from v/sv/s to its grid point, so values close to a rounding boundary push hardest on the step size. Approximations that cancel the rounding algebraically before differentiating get exactly zero there and ignore where vv sits between grid points.

  4. g=1NWQP(NW weights in the layer),s0=2 ⟨∣v∣⟩QPg=\frac1{\sqrt{N_WQ_P}}\quad(N_W\text{ weights in the layer}),\qquad s_0=\frac{2\,\langle\abs v\rangle}{\sqrt{Q_P}}

    Each step size sums gradient contributions from every value it scales, so LSQ multiplies its gradient by gg, chosen to keep the ratio of update size to parameter size comparable to the weights', and initializes it from the data. With every layer but the first and last (kept at 8 bits) at 3 bits for weights and activations, ResNets trained this way came within about a point of full precision on ImageNet (ResNet-18: 70.2% against 70.5%), and with distillation from a full-precision copy of the same network they matched it.

Check your understanding

With step s=0.1s=0.1 and QP=7Q_P=7, a weight v=0.26v=0.26 is quantized to v^=0.3\hat v=0.3. What is ∂v^/∂s\partial\hat v/\partial s under learned step size quantization?

  1. 0.40.4
  2. −0.4-0.4
  3. 00
  4. 77
Show the answer

A. 0.40.4

v/s=2.6v/s=2.6 rounds to 3, inside the range, so the gradient is 3−2.6=0.43-2.6=0.4. Holding the rounded code fixed would give 33, the true slope of v^=3s\hat v=3s; the straight-through term −v/s-v/s subtracts the part that the rounding would otherwise hide.

For large language models, full quantization-aware training is a training run, so it is used mainly for models designed to be low-precision from the start (step 5) or as a shorter phase after pretraining: LLM-QAT (Liu et al., 2023) trained LLaMA models of 7 to 30 billion parameters to 4-bit weights and KV caches with 8-bit activations, distilling each from its own full-precision version on text that model generated. Post-training methods carry the rest: they cannot adapt the network as a whole, but they can choose, weight by weight, how to round.

Outlier features

Weights of trained networks are well behaved: roughly bell-shaped, with few extreme values. Activations of large transformers are not. Dettmers, Lewis, Belkada and Zettlemoyer (2022) found outlier features in OPT-style models: hidden dimensions with magnitudes up to 20 times larger than the rest, which first appear in about a quarter of the layers and, between 6 and 6.7 billion parameters, spread to all layers and to about 75% of token positions. At 6.7 billion parameters they counted about 150,000 outlier values per sequence, all in just six feature dimensions of the whole network. Zeroing those dimensions, about 0.1% of the features, degraded perplexity by 600–1000%; zeroing as many random ones changed it by about 0.1%. Measured against perplexity instead of size, the emergence is smooth rather than sudden. Where such coordinates come from, and why they help softmax attention do nothing, is the subject of Attention Sinks & Massive Activations.

Per-tensor 8-bit quantization of such activations fails beyond about 6.7 billion parameters: one scale must reach the outliers, so the ordinary values occupy only a few levels near zero. LLM.int8() combines two fixes. Vector-wise quantization gives each token and each output channel its own scale, which still factors out of the dot product. Mixed-precision decomposition splits the product by input dimension: any dimension where some value exceeds a threshold of 6.0 is multiplied in 16 bits, and the rest, more than 99.9% of the values, in 8 bits. With at most seven such dimensions in models up to 13 billion parameters, this halved the memory of the weights with no measurable degradation up to 175 billion parameters.

SmoothQuant (Xiao et al., 2023) starts from two observations: outliers sit in a few fixed input channels in every token, and per-channel activation scales would fix them (simulated per-channel INT8 kept OPT-175B at 71.4% average accuracy against 71.6% in FP16, where per-tensor and per-token scales fell to about 32%), but a scale per input channel cannot be pulled out of an integer dot product. So it moves the difficulty into the weights, which tolerate it, with an exact change of variables.

DerivationMigrating the difficulty
  1. WX=(Wdiag⁡(s))(diag⁡(s)−1X)=W^X^WX=\big(W\diag(\mathbf s)\big)\big(\diag(\mathbf s)^{-1}X\big)=\hat W\hat X

    For any positive vector s\mathbf s indexed by input channel jj, the layer's output is unchanged (here X∈Rdin×nX\in\R^{d_{\text{in}}\times n} holds one token per column):

  2. sj=(max⁡∣Xj,:∣)α(max⁡∣W:,j∣)1−αs_j=\frac{\big(\max\abs{X_{j,:}}\big)^{\alpha}}{\big(\max\abs{W_{:,j}}\big)^{1-\alpha}}

    Channel jj of the activations is divided by sjs_j and column jj of the weights multiplied by it. With migration strength α\alpha, measured on calibration data:

  3. max⁡∣X^j,:∣=max⁡∣W^:,j∣=max⁡∣Xj,:∣⋅max⁡∣W:,j∣\max\abs{\hat X_{j,:}}=\max\abs{\hat W_{:,j}}=\sqrt{\max\abs{X_{j,:}}\cdot\max\abs{W_{:,j}}}

    At α=12\alpha=\tfrac12 both factors end with the same channel maximum, the geometric mean of the two, so neither side keeps the outlier alone. α=1\alpha=1 moves everything into the weights, α=0\alpha=0 everything into the activations; α=0.5\alpha=0.5 worked for OPT and BLOOM and 0.750.75 for GLM-130B, whose outliers are more severe.

  4. The division by s\mathbf s is folded offline into the preceding normalization or linear layer, so inference pays nothing. Both operands are then quantized to INT8 with scales that factor out of the integer product; the paper used one scale per tensor for the weights and one per tensor or per token for the activations. The authors reported up to 1.56 times faster inference and half the memory, with negligible loss in accuracy.

Because HDHD is orthogonal, Wx=(W(HD)⊤)(HD x)W\mathbf x=\big(W(HD)^\top\big)(HD\,\mathbf x): the rotation can be folded into the neighboring weights without changing the function (in the residual stream this works because RMSNorm divides each vector by its root mean square, which a rotation leaves unchanged, once the norm's learned scale has been folded into the next weight matrix), yet every rotated vector loses its spikes. Take d=4096d=4096 with one coordinate of 60 and the rest of size 1: before the rotation an INT8 step must be 60/127≈0.4760/127\approx0.47; after it, the largest of the 4,096 coordinates is about 4 to 5 in a few random draws and the step about 0.0350.035. QuaRot (Ashkboos et al., 2024) applies such rotations to the residual stream, inside the feed-forward blocks and to keys and values, and quantized every weight, activation and cached key and value of LLaMA2-70B to 4 bits while losing at most 0.47 WikiText-2 perplexity and keeping 99% of its zero-shot accuracy. The same random Hadamard idea appears in 4-bit training recipes (Number Formats & Mixed Precision).

GPTQ: rounding with error compensation

DerivationThe optimal compensation for one rounded weight
  1. 12δ⊤Hδ=12Hqqδq2+δq HqFδF+12δF⊤HFFδF\tfrac12\boldsymbol\delta^\top H\boldsymbol\delta=\tfrac12H_{qq}\delta_q^2+\delta_q\,H_{qF}\boldsymbol\delta_F+\tfrac12\boldsymbol\delta_F^\top H_{FF}\boldsymbol\delta_F

    Round weight qq, fixing δq=quant⁡(wq)−wq\delta_q=\operatorname{quant}(w_q)-w_q, and let the not-yet-quantized weights FF move. Split the quadratic into blocks:

  2. δF∗=−HFF−1HFq δq,min⁡=12 δq2(Hqq−HqFHFF−1HFq)\boldsymbol\delta_F^*=-H_{FF}^{-1}H_{Fq}\,\delta_q,\qquad\min=\tfrac12\,\delta_q^2\big(H_{qq}-H_{qF}H_{FF}^{-1}H_{Fq}\big)

    Minimizing over δF\boldsymbol\delta_F is a least-squares problem, and the minimum is a Schur complement:

  3. δF=−wq−quant⁡(wq)[H−1]qq [H−1]F,q,ΔL=(quant⁡(wq)−wq)22 [H−1]qq\boldsymbol\delta_F=-\frac{w_q-\operatorname{quant}(w_q)}{[H^{-1}]_{qq}}\,[H^{-1}]_{F,q},\qquad\Delta\loss=\frac{\big(\operatorname{quant}(w_q)-w_q\big)^2}{2\,[H^{-1}]_{qq}}

    The block-inverse formulas [H−1]qq=(Hqq−HqFHFF−1HFq)−1[H^{-1}]_{qq}=\big(H_{qq}-H_{qF}H_{FF}^{-1}H_{Fq}\big)^{-1} and [H−1]Fq=−HFF−1HFq[H−1]qq[H^{-1}]_{Fq}=-H_{FF}^{-1}H_{Fq}[H^{-1}]_{qq} turn this into the update of Optimal Brain Quantization (Frantar, Singh & Alistarh, 2022), which GPTQ inherits; HH here is restricted to the weights not yet fixed:

  4. Without compensation the cost would be 12Hqqδq2\tfrac12H_{qq}\delta_q^2, never smaller, since [H−1]qqHqq≥1[H^{-1}]_{qq}H_{qq}\ge1 for positive definite HH; the gain is largest when inputs are strongly correlated. After fixing qq, its row and column are removed from H−1H^{-1} by one step of Gaussian elimination, H−1←H−1−H:,q−1Hq,:−1/[H−1]qqH^{-1}\leftarrow H^{-1}-H^{-1}_{:,q}H^{-1}_{q,:}/[H^{-1}]_{qq}, without inverting again. The same formulas with quant⁡(wq)=0\operatorname{quant}(w_q)=0 are Optimal Brain Surgeon's pruning rule, derived another way in Pruning, Sparsity & Lottery Tickets.

Predict before you look

A row has two weights w=(0.3, 0.5)\mathbf w=(0.3,\ 0.5) with H=(2112)H=\begin{pmatrix}2&1\\1&2\end{pmatrix} and a grid of step 0.250.25. Weight 1 is rounded to 0.250.25. What should weight 2 become?

Show the answer

0.525

H−1=13(2−1−12)H^{-1}=\tfrac13\begin{pmatrix}2&-1\\-1&2\end{pmatrix}, so δ2=δ1[H−1]11[H−1]21=−0.052/3⋅(−13)=+0.025\delta_2=\frac{\delta_1}{[H^{-1}]_{11}}[H^{-1}]_{21}=\frac{-0.05}{2/3}\cdot\big(-\tfrac13\big)=+0.025 and w2w_2 becomes 0.5250.525. The inputs are positively correlated, so weight 2 makes up for weight 1's loss. The output error drops from 12⋅2⋅0.052=0.0025\tfrac12\cdot2\cdot0.05^2=0.0025 to 0.052/(2⋅23)≈0.00190.05^2/(2\cdot\tfrac23)\approx0.0019, a quarter less; weight 2 is rounded next, from its new value.

OBQ picked the weight with the smallest ΔL\Delta\loss next, separately for every row, which costs O(drowdcol3)\order{d_{\text{row}}d_{\text{col}}^3} and limited it to models of up to about a hundred million parameters. GPTQ (Frantar, Ashkboos, Hoefler & Alistarh, 2023) made it scale with three changes:

  1. One order for all rows. Quantizing columns left to right in every row lost little against the greedy order on large layers. Since HH depends only on XX, every row then shares the same sequence of inverses, updated once per column: O(max⁡(drowdcol2, dcol3))\order{\max(d_{\text{row}}d_{\text{col}}^2,\,d_{\text{col}}^3)}.
  2. Lazy batch updates. Rank-one updates of a large matrix are memory-bound. GPTQ processes 128 columns at a time, updating only inside the block, then applies the accumulated corrections to all later columns in one matrix product.
  3. Cholesky form. Repeated eliminations accumulate errors that can make H−1H^{-1} indefinite in models of billions of parameters. The rows GPTQ needs are, up to scaling, the rows of the upper Cholesky factor of H−1H^{-1}, computed once after adding 1% of the mean diagonal to HH (dampening).

Calibrated on 128 random sequences of 2,048 tokens, GPTQ quantized OPT-175B and BLOOM-176B in about four GPU hours. At 3 bits OPT-175B fits on one 80 GB GPU, and a kernel that unpacks weights on the fly generated tokens 3.24 times faster than the 16-bit model spread over five GPUs.

python
import torch

def gptq(W, X, bits=4, damp=0.01):
    """W: (d_out, d_in) weights, X: (d_in, n) calibration inputs. Returns quantized weights."""
    W, d = W.clone(), W.shape[1]
    H = 2 * X @ X.T
    H += damp * H.diagonal().mean() * torch.eye(d)                 # dampening
    U = torch.linalg.cholesky(torch.linalg.inv(H), upper=True)   # H^-1 = U^T U
    qmax = 2 ** (bits - 1) - 1
    s = W.abs().amax(dim=1) / qmax                                # one scale per row
    Q = torch.zeros_like(W)
    for j in range(d):                                            # columns in a fixed order
        Q[:, j] = torch.clamp(torch.round(W[:, j] / s), -qmax, qmax) * s
        err = (W[:, j] - Q[:, j]) / U[j, j]
        W[:, j:] -= torch.outer(err, U[j, j:])                    # compensate later columns
    return Q

GPTQ without the blocking. Row jj of the upper Cholesky factor UU equals row jj of the inverse over the columns not yet quantized, divided by the square root of its diagonal entry, so each update matches the formula above. On random correlated inputs this gives exactly the result of applying the one-weight update column by column, and a smaller output error than rounding to nearest.

AWQ (Lin et al., 2024) takes the opposite approach: no reconstruction at all, only a better choice of what to protect. Keeping just 1% of weight channels in 16 bits, chosen by the size of their activations, brought OPT-6.7B under 3-bit quantization with groups of 128 from a perplexity of 23.54 (round to nearest) to 11.39, against 10.86 in FP16; choosing the 1% by weight magnitude barely helped. Since mixed precision is awkward for kernels, AWQ protects those channels by scaling instead. Multiply weight ww by s>1s>1 and its input by 1/s1/s: if the group's step Δ\Delta barely changes, the rounding error of Q(ws) x/sQ(ws)\,x/s is about 1/s1/s times that of Q(w) xQ(w)\,x. Too large an ss widens the step for the rest of the group, so AWQ searches s=sX α\mathbf s=\mathbf s_X^{\,\alpha}, with sX\mathbf s_X the average activation magnitude per channel and α∈[0,1]\alpha\in[0,1], to minimize the layer's output error. With no backpropagation and little dependence on the calibration set it generalized well, including to instruction-tuned and multimodal models. QLoRA's 4-bit NormalFloat, whose 16 levels follow the quantiles of a normal distribution, is the third common 4-bit scheme (Low-Rank Adaptation in Depth).

How low can weights go?

Bits are a budget. A 30-billion-parameter model in 8 bits and a 60-billion-parameter model in 4 bits occupy the same memory. Dettmers and Zettlemoyer (2023) ran more than 35,000 zero-shot experiments on models from 19 million to 176 billion parameters in four families, quantizing weights to 3 to 8 bits, and found 4-bit precision almost universally optimal for accuracy at a fixed total number of model bits. Few changes improved that trade-off at 4 bits, and none at 6 to 8: only small quantization blocks (64 to 128 weights was usually best) and the data type, with floating-point or quantile levels scaling better than integers.

Below 4 bits after training, error compensation and small groups go a long way. With groups of 8 weights, GPTQ reached ternary weights {−1,0,1}\{-1,0,1\} times a scale on OPT-175B while losing less than one point of WikiText-2 perplexity.

Low precision from the start. BitNet b1.58 (Ma et al., 2024) trains the weights of every linear layer of a LLaMA-style model as ternary (the embeddings stay in high precision), quantization-aware from the first step, with 8-bit activations and the absmean quantizer below. Pretrained on 100 billion tokens, it trailed a 16-bit baseline slightly at 1.3 billion parameters and matched it at 3 billion in perplexity (9.91 against 10.04) and zero-shot accuracy, by the authors' report. Three levels carry log⁡23≈1.58\log_23\approx1.58 bits, and matrix products become additions and subtractions. The paper is a preprint describing work in progress, and how the comparison holds up at larger scale and longer training is not yet settled.

W~=clip⁡(round⁡(Wγ+ϵ),−1,1),γ=1nm∑i,j∣Wij∣\tilde W=\operatorname{clip}\Big(\operatorname{round}\Big(\frac{W}{\gamma+\epsilon}\Big),-1,1\Big),\qquad\gamma=\frac1{nm}\sum_{i,j}\abs{W_{ij}}
BitNet b1.58's quantizer for an n×mn\times m weight matrix: divide by the mean absolute value, round, clip to three levels. It builds on the original BitNet (Wang et al., 2023), which keeps high-precision latent weights to accumulate the updates and passes gradients through the rounding with the straight-through estimator.

Precision meets scaling laws. Kumar et al. (2025) fitted scaling laws with precision as a variable on more than 465 pretraining runs, up to 1.7 billion parameters and 26 billion tokens. Two findings bear on compression. The loss added by post-training quantization grows with the number of tokens a model was trained on, to the point where, for a fixed post-training precision, more pretraining data can make the quantized model worse. And training in low precision acts like reducing the effective parameter count. Since models meant for wide deployment are trained far beyond 20 tokens per parameter (Neural Scaling Laws), the models most worth quantizing may be the hardest to quantize. The fits come from small models and await confirmation at scale.

Key takeaways

  • A uniform quantizer with step Δ\Delta adds error of variance about Δ2/12\Delta^2/12, so each bit is worth about 6 dB; the clipping range trades rounding against clipping error, and its optimum lies well inside the largest value (about 5c5c at 4 bits for Laplace data of scale cc).
  • Quantization-aware training uses the straight-through estimator for values and, in LSQ, the gradient round⁡(v/s)−v/s\operatorname{round}(v/s)-v/s for the step size, with which 3-bit ResNets, helped by distillation, matched full precision.
  • Beyond about 6.7 billion parameters a few outlier dimensions break per-tensor 8-bit activations. LLM.int8() keeps them in 16 bits, SmoothQuant moves the difficulty into the weights with sj=max⁡∣Xj,:∣α/max⁡∣W:,j∣1−αs_j=\max\abs{X_{j,:}}^{\alpha}/\max\abs{W_{:,j}}^{1-\alpha}, and random Hadamard rotations spread any spike over all coordinates.
  • GPTQ minimizes each layer's output error 12δ⊤Hδ\tfrac12\boldsymbol\delta^\top H\boldsymbol\delta with H=2XX⊤H=2XX^\top: rounding wqw_q and moving the remaining weights by −wq−quant⁡(wq)[H−1]qq[H−1]:,q-\frac{w_q-\operatorname{quant}(w_q)}{[H^{-1}]_{qq}}[H^{-1}]_{:,q} costs only δq2/(2[H−1]qq)\delta_q^2/(2[H^{-1}]_{qq}). One shared column order, lazy blocks and a Cholesky factor make it run on 175-billion-parameter models in hours; AWQ instead scales up the channels with large activations.
  • At a fixed memory budget, 4-bit weights are almost always the best post-training trade-off. Ternary weights need tiny groups or training from scratch (BitNet b1.58), and models trained on more tokens lose more when quantized afterwards.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

With the clipping range fixed, by what factor does the rounding MSE grow when a uniform quantizer goes from 6 bits to 4 bits, under the uniform-noise model?

  1. 2
  2. 4
  3. 16
  4. It is unchanged
Show the answer

C. 16

Two bits fewer quadruple the step Δ\Delta, and the MSE Δ2/12\Delta^2/12 grows by 42=164^2=16: 12 dB of SQNR, about 6 dB per bit.

Question 2

In SmoothQuant with migration strength α=12\alpha=\tfrac12, input channel jj has activation maximum max⁡∣Xj∣=64\max\abs{X_j}=64 and weight maximum max⁡∣W:,j∣=0.25\max\abs{W_{:,j}}=0.25. After smoothing, what are the two maxima?

  1. 1616 and 44
  2. 44 and 44
  3. 11 and 1616
  4. 6464 and 0.250.25, since smoothing is exact
Show the answer

B. 44 and 44

sj=641/2/0.251/2=8/0.5=16s_j=64^{1/2}/0.25^{1/2}=8/0.5=16. The activation maximum becomes 64/16=464/16=4 and the weight maximum 0.25×16=40.25\times16=4: both equal 64×0.25\sqrt{64\times0.25}, so the two sides share the difficulty equally.

Question 3

Why can GPTQ quantize every row of a weight matrix in the same column order, instead of choosing a greedy order per row as OBQ did?

  1. Because rows of a weight matrix are identical
  2. Because the layer-wise Hessian 2XX⊤2XX^\top depends only on the inputs, so all rows share it and its inverse is updated once per column; on large layers the greedy order gained little
  3. Because the order of quantization never affects the final error
  4. Because GPTQ quantizes all weights at once, without any order
Show the answer

B. Because the layer-wise Hessian 2XX⊤2XX^\top depends only on the inputs, so all rows share it and its inverse is updated once per column; on large layers the greedy order gained little

Each row's objective (w−w^)⊤XX⊤(w−w^)(\mathbf w-\hat{\mathbf w})^\top XX^\top(\mathbf w-\hat{\mathbf w}) has the same Hessian. With a shared order, the inverse over the remaining columns is the same for every row, which cuts the cost by a factor of min⁡(drow,dcol)\min(d_{\text{row}},d_{\text{col}}).

Question 4

AWQ protects about 1% of the weight channels of a layer. How does it choose them, and how does it protect them without storing them in 16 bits?

  1. By the largest weight magnitudes; it clips them less
  2. At random; it gives them their own quantization groups
  3. By the largest gradients; it skips quantizing them
  4. By the largest average activation magnitudes; it multiplies those weight channels by s>1s>1 and divides the matching activations by ss, which shrinks their relative rounding error
Show the answer

D. By the largest average activation magnitudes; it multiplies those weight channels by s>1s>1 and divides the matching activations by ss, which shrinks their relative rounding error

A weight's error is multiplied by its input, so channels with large activations matter most. Scaling a channel's weights up by ss while its group's step barely changes cuts its relative error by about ss, and the factor 1/s1/s is folded into the previous operation.

Further reading

  • M. Nagel, M. Fournarakis, R. A. Amjad, Y. Bondarenko, M. van Baalen & T. Blankevoort, "A white paper on neural network quantization," arXiv:2106.08295 (2021).
  • T. Dettmers, M. Lewis, Y. Belkada & L. Zettlemoyer, "LLM.int8(): 8-bit matrix multiplication for transformers at scale," NeurIPS (2022).
  • G. Xiao, J. Lin, M. Seznec, H. Wu, J. Demouth & S. Han, "SmoothQuant: Accurate and efficient post-training quantization for large language models," ICML (2023).
  • E. Frantar, S. Ashkboos, T. Hoefler & D. Alistarh, "GPTQ: Accurate post-training quantization for generative pre-trained transformers," ICLR (2023).
  • J. Lin et al., "AWQ: Activation-aware weight quantization for on-device LLM compression and acceleration," MLSys (2024).