Deploying frontier autoregressive Large Language Models (LLMs) across cloud GPU clusters and edge workstations requires overcoming a severe hardware bottleneck: while single-batch autoregressive token decoding executes minimal floating-point arithmetic per weight, it must stream the entire model parameter tensor from High-Bandwidth Memory (HBM) or unified LPDDR DRAM into on-chip SRAM registers for every single generated token. Storing a 175-billion-parameter Transformer in 16-bit half precision (FP16 or BF16, consuming $2\text{ bytes/parameter}$) requires $326\text{ GiB}$ to $350\text{ GB}$ of memory solely for static weights—exceeding the capacity of four 80 GB datacenter accelerators before accounting for dynamic Key-Value (KV) cache allocations (arXiv:2210.17323, arXiv:2211.10438). Similarly, standard 16-bit full fine-tuning of a 65-billion-parameter LLaMA checkpoint consumes more than $780\text{ GB}$ of GPU memory across weights, gradients, and Adam optimizer states (arXiv:2305.14314).
Post-Training Quantization (PTQ) resolves this memory wall by discretizing high-precision floating-point tensors (FP32, BF16, FP16) into low-bitwidth integer (INT8, INT4, INT3, INT2), quantile (NF4), or microscaling floating-point (FP8 E4M3/E5M2, MXFP4, NVFP4) representations without full-model retraining. However, compressing Transformer weights, activations, and KV caches below 8 bits exposes four fundamental mathematical and computer-architecture challenges documented across primary systems research (arXiv:2208.07339, arXiv:2210.17323, arXiv:2211.10438, arXiv:2306.00978, arXiv:2405.16406):
- The Memory-Bandwidth Roofline of Autoregressive Decoding (
W4A16vs.W8A8): On an NVIDIA RTX 4090 GPU delivering $165\text{ TFLOPS}$ of peak FP16 compute and $1\text{ TB/s}$ of GDDR6X memory bandwidth, any kernel with an arithmetic intensity below the hardware ridge point of $165\text{ FLOPs/Byte}$ is strictly memory-bound (arXiv:2306.00978). During batch-size-1 autoregressive generation, FP16 linear projections operate at an arithmetic intensity of approximately $1\text{ FLOP/Byte}$—causing the GPU to spend $310\text{ ms}$ generating $20$ tokens while requiring only $10\text{ ms}$ to prefill a $200$-token prompt. Compressing weights to 4 bits (W4A16) slashes weight memory traffic by $4\times$, elevating arithmetic intensity to $4\text{ FLOPs/Byte}$ and unlocking a $4\times$ theoretical latency ceiling. - Emergent High-Magnitude Activation Outliers Above 6.7B Parameters: As demonstrated in LLM.int8() (
arXiv:2208.07339), when autoregressive Transformers scale from $6.0\text{B}$ to $6.7\text{B}$ parameters, a sudden phase shift occurs: extreme activation outliers with magnitudes up to $20\times$ to $100\times$ larger than normal activations ($\alpha \ge 6.0$, reaching magnitudes $>60\text{--}70$) spread from $65\%$ to $100\%$ of Transformer layers and $75\%$ of sequence tokens. Although roughly $150,000$ outliers appear per $2048$-token sequence in a $6.7\text{B}\text{--}13\text{B}$ model, they are systematically concentrated inside at most $6$ to $7$ hidden feature dimensions ($\approx 0.1\%$ of channels). Zeroing out those $\le 7$ outlier channels destroys model coherence, slashing top-1 attention softmax probability from $\sim 40\%$ to $\sim 20\%$ and exploding validation perplexity by $600\%\text{--}1000\%$. - Naive Round-to-Nearest (RTN) Collapse at 3-Bit and 2-Bit Regimes: While direct Round-to-Nearest (RTN) quantization remains usable at 8 bits with vector-wise decomposition, RTN degrades severely at 4 bits (dropping OPT-175B WikiText-2 perplexity by $+2.20$ points from $8.34$ to $10.54$, worse than a $10\times$ smaller FP16 OPT-13B model at $10.13$) and suffers catastrophic collapse at 3 bits and 2 bits, exploding OPT-175B perplexity to $7,300$ (
7.3e3) at 3-bit and $7,622\text{--}193,210$ across OPT models at 2-bit (arXiv:2210.17323,arXiv:2306.00978). - Hardware Tensor Core Granularity and Dequantization Overhead: Mainstream GPU Tensor Cores (
INT8,FP8,FP4MMA instructions) only permit scaling factors along the outer dimensions of a matrix multiplication—the token dimension $T$ of activations $\mathbf{X} \in \mathbb{R}^{T \times C_i}$ and the output channel dimension $C_o$ of weights $\mathbf{W} \in \mathbb{R}^{C_i \times C_o}$—forbidding inner-dimension ($C_i$) per-channel activation rescaling inside the hardware GEMM loop (arXiv:2211.10438). Meanwhile, weight-onlyW4A16formats require fused on-the-fly register dequantization and SIMD-aligned bit-interleaving (arXiv:2306.00978) so unpacking instructions do not negate memory-bandwidth gains.
Clean Signal Quantization Curve Illustrating Continuous Analog Amplitude Discretization onto Fixed Integer Quantization Levels and Step-Size Rounding Error
This architectural deep dive examines the mathematical formulations, second-order Hessian updates, activation-aware channel scaling transformations, quantile and super-block data layouts, orthonormal Stiefel-manifold rotations, hardware floating-point encodings, and empirical perplexity/throughput benchmarks across the foundational LLM quantization stack in 2026.
Executive Summary: Verified Mathematical & Empirical Benchmarks Across GPTQ, AWQ, SmoothQuant, LLM.int8(), QLoRA NF4, GGUF K-Quants, SpinQuant & FP8
- GPTQ Second-Order Hessian Quantization (
arXiv:2210.17323): By enforcing a shared fixed column quantization order across all rows, batching lazy updates in blocks of $B = 128$ columns, and precomputing inverse Hessian rows via a dampened Cholesky decomposition $\mathbf{H}^{-1} \leftarrow \text{Cholesky}((2\mathbf{X}\mathbf{X}^\top + \lambda\mathbf{I})^{-1})^\top$, GPTQ reduces Optimal Brain Quantization (OBQ) complexity from $O(d_{\text{row}} \cdot d_{\text{col}}^3)$ to $O(\max\{d_{\text{row}} \cdot d_{\text{col}}^2, d_{\text{col}}^3\})$. It quantizes OPT-175B in 4.2 GPU hours and BLOOM-176B in 3.8 GPU hours on a single 80 GB A100, losing just 0.03 WikiText-2 PPL at 4-bit (8.37vs.8.34FP16) and 0.11 PPL at 3-bit g128 (8.45), while fitting OPT-175B (~63 GB weights + 9 GB KV cache) onto 1× A100 GPU (down from 5× GPUs) with a 3.24× speedup on A100 (230 ms → 71 ms/token) and 4.53× speedup on A6000 (589 ms → 130 ms/tokenacross 2 GPUs instead of 8). - AWQ Salient Channel Scaling & TinyChat (
arXiv:2306.00978, MLSys 2024 Best Paper): AWQ proves that protecting just 0.1%–1% of weight channels selected by activation magnitude (rather than weight $L_2$-norm) slashes OPT-6.7B INT3-g128 perplexity from23.54(RTN) down to11.39(vs.22.37for weight-norm selection). Using hardware-friendly per-channel scaling $\mathbf{s} = \mathbf{s}_{\mathbf{X}}^\alpha$ ($\alpha \in [0, 1]$), AWQ outperforms GPTQ across LLaMA-2 (7B/13B/70B INT3-g128 PPL of 6.24 / 5.32 / 3.74 vs. GPTQ 6.43 / 5.48 / 3.88), CodeLlama-7B MBPP (40.64 pass@1 vs. 31.97 GPTQ and 38.53 FP16), and VILA/OpenFlamingo multimodal models while requiring 10× fewer calibration sequences (16 vs. 192). Paired with TinyChat SIMD weight packing, W4A16 AWQ delivers 3.2–3.3× average speedups (up to 3.9× on RTX 4090 and 3.5× on Jetson Orin). - LLM.int8() Decomposition (
arXiv:2208.07339) vs. SmoothQuant W8A8 Migration (arXiv:2211.10438): LLM.int8() isolates the $\approx 0.1\%$ outlier feature dimensions ($\alpha \ge 6.0$) into FP16 matrix multiplication while executing 99.9% of values in vector-wise INT8, matching FP32 C4 perplexity on 13B (12.45vs.19.08naive INT8). SmoothQuant eliminates mixed-precision runtime overhead by migrating outlier scale variance offline via $\mathbf{Y} = (\mathbf{X}\text{diag}(\mathbf{s})^{-1}) \cdot (\text{diag}(\mathbf{s})\mathbf{W})$ with $\mathbf{s}_j = \max(|\mathbf{X}_j|)^\alpha / \max(|\mathbf{W}_j|)^{1-\alpha}$, achieving lossless W8A8 INT8 GEMM execution with up to 1.56× speedup and 2× memory reduction up to MT-NLG 530B on a single 8× A100 node (73.1%zero-shot accuracy, cutting memory from1,040 GB to 527 GB). - QLoRA NF4, GGUF K-Quants, SpinQuant & FP8/FP4 Hardware Formats: QLoRA (
arXiv:2305.14314) combines information-theoretically optimal 4-bit NormalFloat (NF4) quantiles (`27.41` Pile PPL vs. `31.07` E2M1 FP4 and `34.34` INT4) with Double Quantization (cutting block-64 scale overhead from0.5 to 0.127 bits/param) to fine-tune LLaMA-65B in<48 GB(Guanaco-65B reaches 99.3% of ChatGPT on Vicuna). GGUF K-Quants hierarchically pack 256-weight super-blocks (Q4_Kat 4.5 bpw,Q5_Kat 5.5 bpw,Q6_Kat 6.5625 bpw). SpinQuant (arXiv:2405.16406) optimizes orthonormal Stiefel-manifold rotations via Cayley SGD, driving activation kurtosis from $\kappa > 200$ to $\kappa \approx 3$ and achieving 64.0% accuracy (5.9 Wiki PPL) at W4A4KV4 on LLaMA-2 7B (surpassing LLM-QAT by +19.1 points). Finally, hardware FP8 (E4M3 max 448 / E5M2 max 57,344) (arXiv:2209.05433) and microscaling MXFP4 / NVFP4 power native low-bit Tensor Cores on Hopper, Ada, Blackwell, and MI300X accelerators.
1. Mathematical Foundations of Neural Quantization & the Memory-Bandwidth Roofline
At its core, neural network quantization is a lossy discretization mapping from a high-cardinality floating-point domain (FP32, BF16, or FP16) onto a small finite grid of $2^N$ representable integer or low-bit codes ($256$ levels for 8-bit [-128, 127] or [-127, 127], and only $16$ levels for 4-bit [-8, 7] or [0, 15]). Understanding why different post-training quantization algorithms diverge in accuracy and throughput requires examining both the affine/symmetric projection equations and the hardware Roofline model governing Transformer execution.
1. Affine (Asymmetric Zero-Point) vs. Symmetric (Absmax) Uniform Quantization
As formalized across the Hugging Face Transformers Quantization Specification (huggingface.co/docs/transformers/en/quantization/concept_guide), LLM.int8() (arXiv:2208.07339), and SpinQuant (arXiv:2405.16406), uniform integer quantization operates in two primary modes:
- Affine (Asymmetric / Zero-Point) Quantization: Maps the exact empirical interval $[\text{val}{\min}, \text{val}{\max}]$ of a real-valued tensor $\mathbf{X} \in \mathbb{R}^{b \times h}$ onto the target integer range $[q_{\min}, q_{\max}]$ (such as $[-128, 127]$ for signed
INT8or $[0, 2^N - 1]$ for unsignedUINT4). Two scalar parameters define the affine grid—the step size scale $S \in \mathbb{R}^+$ and the integer zero-point offset $Z \in \mathbb{Z}$ representing the exact real value $0.0$: $$S = \frac{\text{val}{\max} - \text{val}{\min}}{q_{\max} - q_{\min}}, \qquad Z = q_{\min} - \text{round}\left(\frac{\text{val}{\min}}{S}\right)$$ $$q = \text{clip}\left(\text{round}\left(\frac{x}{S}\right) + Z,\; q{\min},\; q_{\max}\right), \qquad \hat{x} = S \cdot (q - Z)$$ For example, when mapping aBF16tensor spanning $[-1.8, 2.4]$ onto signedINT8$[-128, 127]$, the step scale is $S = \frac{2.4 - (-1.8)}{127 - (-128)} = \frac{4.2}{255} \approx 0.01647$, and the real origin $0.0$ lands on the integer zero-point $Z = -19$. An input value $x = 0.5$ quantizes to $q = \text{round}(0.5 / 0.01647 - 19) = 11$ and dequantizes to $\hat{x} = 0.01647 \times (11 - (-19)) \approx 0.494$, incurring a rounding error of $|x - \hat{x}| \approx 0.006$. While asymmetric quantization maximizes bit utilization for skewed distributions (such as post-ReLU or post-GELU activations, or single-sided outlier channels), multiplying two zero-point quantized integers $(A_{i8} + zp_a)(B_{i8} + zp_b)$ expands into four cross-terms (arXiv:2208.07339, Equation 5): $$C_{i32} = A_{i8} B_{i8} + A_{i8} zp_{b} + B_{i8} zp_{a} + zp_{a} zp_{b}$$ adding substantial integer accumulation overhead unless one operand is symmetric ($zp = 0$) or dedicated hardware instructions (such as x86pmaddubsw) are available. - Symmetric (Absmax) Quantization: Constrains the representable interval to be symmetric around zero $[-\max(|\mathbf{X}|), +\max(|\mathbf{X}|)]$ and fixes the zero point strictly at $Z = 0$: $$\Delta = \frac{\max(|\mathbf{X}|)}{2^{N-1} - 1}, \qquad \mathbf{X}^{\text{INT}N} = \text{round}\left(\frac{\mathbf{X}}{\Delta}\right), \qquad \hat{\mathbf{X}} = \Delta \cdot \mathbf{X}^{\text{INT}N}$$ Equivalently, using the inverse scale constant $c^{\text{FP32}} = \frac{2^{N-1} - 1}{\|\mathbf{X}\|_\infty}$ (e.g., $127 / \text{absmax}(\mathbf{X})$ for
INT8inarXiv:2208.07339andarXiv:2305.14314), quantization reduces to $\mathbf{X}^{\text{Int8}} = \text{round}(c^{\text{FP32}} \cdot \mathbf{X})$ and dequantization is simply $\mathbf{X}^{\text{Int8}} / c^{\text{FP32}}$.
2. Quantization Granularity & Metadata Bit-Overhead Calculus
When a single scaling factor $\Delta$ covers an entire weight or activation matrix (per-tensor quantization), a single large outlier stretches $\max(|\mathbf{X}|)$ across all rows and columns, collapsing the effective number of quantization bins for normal values. Specifically, as proved in SmoothQuant (arXiv:2211.10438, Section 3), if channel $i$ has maximum magnitude $m_i$ while the whole tensor has maximum magnitude $m = \max_k m_k$, the number of effective quantization levels available to channel $i$ under $N$-bit per-tensor quantization shrinks to: $$L_{\text{eff}}(i) = 2^N \cdot \frac{m_i}{m}$$ When emergent activation outliers reach $m / m_i \approx 100\times$, even an 8-bit ($2^8 = 256$ levels) per-tensor quantizer is reduced to only $2\text{ to }3$ effective discrete levels for non-outlier channels, destroying information (arXiv:2211.10438). To isolate outliers and bound dynamic range, production quantizers partition tensors at finer granularities:
- Per-Tensor Quantization: 1 scale parameter per matrix ($\approx 0\text{ bits/parameter}$ metadata overhead). Fastest hardware execution (
SmoothQuant-O2/O3), but requires prior outlier smoothing or rotation. - Per-Token / Per-Channel (Vector-Wise) Quantization: In a linear layer $\mathbf{Y} = \mathbf{X}\mathbf{W}$ where $\mathbf{X} \in \mathbb{R}^{T \times C_i}$ and $\mathbf{W} \in \mathbb{R}^{C_i \times C_o}$, assigning a row-wise scale vector $\boldsymbol{\Delta}{\mathbf{X}} \in \mathbb{R}^T$ (one scale per token) and a column-wise scale vector $\boldsymbol{\Delta}{\mathbf{W}} \in \mathbb{R}^{C_o}$ (one scale per output channel) allows the integer matrix multiplication to run at full Tensor Core speed and dequantize the output via an outer-product diagonal rescaling in the kernel epilogue (
arXiv:2208.07339Eq. 7;arXiv:2211.10438Eq. 2): $$\mathbf{Y} = \text{diag}\left(\boldsymbol{\Delta}{\mathbf{X}}^{\text{FP16}}\right) \cdot \left(\bar{\mathbf{X}}^{\text{INT8}} \cdot \bar{\mathbf{W}}^{\text{INT8}}\right) \cdot \text{diag}\left(\boldsymbol{\Delta}{\mathbf{W}}^{\text{FP16}}\right)$$ Crucially, hardware Tensor Core MMA pipelines cannot apply distinct scaling factors along the shared inner summation axis $C_i$ during the dot product without breaking the MMA instruction stream. - Per-Group / Block-Wise Quantization ($g \in \{32, 64, 128\}$): For weight-only quantization (
W4A16,W3A16,W2A16), where weights are dequantized in registers before multiplying with FP16 activations, each contiguous sub-vector of $g$ weights along the input channel dimension shares an independent scale (and optional zero point). Storing anFP16(16-bit) scale and a $b$-bit zero point per group of size $g$ adds $\frac{16 + b}{g}$ bits per weight: * At $g = 1024$, scale metadata adds only $\approx 0.02\text{ extra bits/weight}$ (arXiv:2210.17323). * At $g = 128$ (the industry standard in GPTQ and AWQ), anFP16scale + 4-bit zero-point adds $\frac{20}{128} \approx \mathbf{0.156\text{ extra bits/weight}}$ (4.156 bpwfor INT4-g128;3.156 bpwfor INT3-g128). * At $g = 64$ with anFP32scale (as in naive 4-bit block quantization), metadata adds $\frac{32}{64} = \mathbf{0.50\text{ extra bits/weight}}$—motivating QLoRA's Double Quantization (arXiv:2305.14314) and GGUF's K-Quant hierarchical super-blocks (256weights divided into 8 or 16 sub-blocks with 6-bit quantized scales).
3. Prefill vs. Decode Roofline Physics: Why W4A16 Accelerates Edge Decoding While W8A8/FP8 Accelerates Datacenter Serving
In "AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration" (arXiv:2306.00978v5, Section 4.1 & Figure 3), Lin et al. profile LLaMA-7B at batch size 1 on an NVIDIA RTX 4090 GPU (165 TFLOPS peak FP16 compute, 1 TB/s memory bandwidth, ridge point $= 165\text{ FLOPs/Byte}$):
- Context (Prefill) Stage vs. Generation (Decode) Stage: Summarizing a $200$-token input prompt takes only $10\text{ ms}$ (compute-bound matrix-matrix multiplication,
GEMM), whereas generating just $20$ output tokens takes $310\text{ ms}$ ($15.5\text{ ms/token}$, memory-bandwidth-bound matrix-vector multiplication,GEMV). - Arithmetic Intensity of Weight-Only Quantization (
W4A16): At batch size 1, loading a 16-bit weight ($2\text{ bytes}$) to perform 1 multiply-accumulate ($2\text{ FLOPs}$) yields an arithmetic intensity of $\approx 1\text{ FLOP/Byte}$—capping RTX 4090 throughput at $\sim 1\text{ TFLOPS}$ ($<0.7\%$ of peak compute). Because weight access dominates activation access by orders of magnitude at low batch sizes, compressing weights from 16-bit to 4-bit (W4A16) cuts weight memory bytes by $4\times$, raising arithmetic intensity from $1\text{ FLOP/Byte}$ to $4\text{ FLOPs/Byte}$ and lifting the Roofline throughput ceiling to $4\text{ TFLOPS}$. - When
W8A8/W4A4(Weight + Activation Quantization) Wins: In high-concurrency cloud serving with large batch sizes (e.g., batch size $512$, sequence length $2048$, where the KV cache alone reaches $3\text{ TB}$—$3\times$ larger than the model weights,arXiv:2211.10438Appendix A) or long-context prefill, arithmetic intensity exceeds the GPU ridge point and execution becomes compute-bound. Here, dequantizing 4-bit weights into FP16 adds instruction overhead without accelerating the math pipeline; instead, quantizing both weights and activations (W8A8 INT8,W8A8 FP8, orW4A4KV4) allows the hardware to execute native low-precision Tensor Core matrix multiplications at $2\times$ to $4\times$ higher TFLOPS while simultaneously halving or quartering KV-cache memory bandwidth.
2. Hessian-Guided One-Shot Compression (GPTQ): Optimal Brain Quantization, Lazy Batch Updates, and Cholesky Reformulation
Before GPTQ (arXiv:2210.17323, ICLR 2023), post-training quantization methods fell into an untenable divide: accurate adaptive-rounding or reconstruction algorithms such as AdaRound (arXiv:2004.10568), BRECQ (arXiv:2102.05426), ZeroQuant-LKD (arXiv:2206.01861), and Optimal Brain Quantization (OBQ) (arXiv:2208.11580) required hours of gradient updates or cubic matrix inversions even on $25\text{M}\text{--}1.3\text{B}$ models (ZeroQuant-LKD required 3 GPU hours for a $1.3\text{B}$ model, linearly extrapolating to hundreds of hours at $175\text{B}$), leaving giant LLMs dependent on naive Round-to-Nearest (RTN).
In "GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers" (Frantar, Ashkboos, Hoefler, & Alistarh, ICLR 2023, arXiv:2210.17323), IST Austria and ETH Zurich introduced a second-order one-shot weight quantizer capable of compressing OPT-175B ($326\text{ GiB}$ in FP16) and BLOOM-176B down to 3 or 4 bits in roughly 4 GPU hours on a single 80 GB NVIDIA A100.
1. From Optimal Brain Quantization (OBQ) to Fixed-Order Column Updates
For each linear layer $\ell$ with full-precision weight matrix $\mathbf{W} \in \mathbb{R}^{d_{\text{row}} \times d_{\text{col}}}$ and calibration input activation matrix $\mathbf{X} \in \mathbb{R}^{d_{\text{col}} \times m}$ (collected from a small sample of $m$ tokens running through the already partially quantized network), layer-wise post-training quantization seeks a quantized weight matrix $\widehat{\mathbf{W}}$ minimizing the squared output reconstruction error (arXiv:2210.17323, Equation 1): $$\underset{\widehat{\mathbf{W}}}{\text{argmin}}\; \left\|\mathbf{W}\mathbf{X} - \widehat{\mathbf{W}}\mathbf{X}\right\|_2^2$$
Because this objective decomposes into the sum of independent quadratic squared errors across each row $\mathbf{w}$ of $\mathbf{W}$, the second-order Hessian matrix with respect to any subset $F$ of remaining unquantized full-precision weights is identical for every row and depends solely on the layer calibration inputs: $$\mathbf{H}_F = 2\mathbf{X}_F \mathbf{X}_F^\top$$
In Optimal Brain Quantization (OBQ) (arXiv:2208.11580), each row is quantized one scalar weight at a time in greedy order—always selecting the weight $w_q$ that incurs the smallest second-order reconstruction error and updating all remaining unquantized weights in $F$ by a compensatory vector $\boldsymbol{\delta}F$ using the inverse Hessian $\mathbf{H}_F^{-1}$ (arXiv:2210.17323, Equations 2–3): $$w_q = \underset{w_q}{\text{argmin}}\; \frac{\left(\text{quant}(w_q) - w_q\right)^2}{\left[\mathbf{H}_F^{-1}\right]{qq}}, \qquad \boldsymbol{\delta}F = -\frac{w_q - \text{quant}(w_q)}{\left[\mathbf{H}_F^{-1}\right]{qq}} \cdot \left(\mathbf{H}F^{-1}\right){:,q}$$ $$\mathbf{H}{-q}^{-1} = \left(\mathbf{H}^{-1} - \frac{1}{\left[\mathbf{H}^{-1}\right]{qq}} \mathbf{H}{:,q}^{-1} \mathbf{H}{q,:}^{-1}\right){-q}$$ where the last equation removes the $q$-th row and column from the inverse Hessian via one step of Gaussian elimination. Because OBQ picks a different greedy quantization ordering for every individual row of $\mathbf{W}$, it must maintain and update $d{\text{row}}$ separate inverse matrices $\mathbf{H}F^{-1}$, incurring a prohibitive $O(d{\text{row}} \cdot d_{\text{col}}^3)$ runtime that takes $\approx 1\text{ hour}$ even on a $25\text{M}$-parameter ResNet-50.
GPTQ's Three Algorithmic Breakthroughs (arXiv:2210.17323, Section 4):
- Step 1 — The Arbitrary Order Insight ($O(\max\{d_{\text{row}} \cdot d_{\text{col}}^2, d_{\text{col}}^3\})$ Scaling): Frantar et al. observe that on large, heavily parameterized layers, quantizing weights in a fixed column order across all rows yields virtually identical final squared error to row-specific greedy ordering—because although greedy ordering avoids large individual errors early on, it defers outliers to the very end of the process when almost no unquantized weights remain to compensate for them! By quantizing all rows of $\mathbf{W}$ in the exact same column order, the set of unquantized indices $F$ and the inverse Hessian $\mathbf{H}F^{-1}$ are shared across all $d{\text{row}}$ rows. Consequently, the Gaussian elimination update of $\mathbf{H}F^{-1}$ is performed only $d{\text{col}}$ times (once per column) instead of $d_{\text{row}} \cdot d_{\text{col}}$ times, slashing theoretical complexity by a factor of $\min\{d_{\text{row}}, d_{\text{col}}\}$ (several orders of magnitude for hidden dimensions $d \in [4096, 12288]$). (Note: An optional heuristic known as Activation Order /
act_order/GPTQ-R, evaluated inarXiv:2306.00978Table 4, sorts the shared column order in descending order of the Hessian diagonal $\mathbf{H}_{qq}$ so the highest-activation columns are quantized first while maximum compensation capacity remains.) - Step 2 — Lazy Batch-Updates ($B = 128$ Column Blocking): Updating the entire $d_{\text{row}} \times d_{\text{col}}$ weight matrix after every single column is severely memory-bandwidth bound on GPUs (performing only a few FLOPs per matrix element read/written). Because the rounding decision for column $j$ depends only on updates applied to column $j$ itself, GPTQ partitions columns into contiguous blocks of size $B = 128$ ($Q = \{i, i+1, \dots, i+B-1\}$). Inside the current block, weight updates are restricted strictly to the $B$ active columns and the $B \times B$ sub-block of $\mathbf{H}^{-1}$; only after all $B = 128$ columns are quantized does GPTQ execute a high-throughput tall-skinny matrix-matrix multiplication (
GEMM) to update all remaining columns $(i+B):d_{\text{col}}$ (arXiv:2210.17323, Equations 4–5): $$\boldsymbol{\delta}F = -\left(\mathbf{w}_Q - \text{quant}(\mathbf{w}_Q)\right) \left(\left[\mathbf{H}_F^{-1}\right]{QQ}\right)^{-1} \left(\mathbf{H}F^{-1}\right){:,Q}$$ $$\mathbf{H}{-Q}^{-1} = \left(\mathbf{H}^{-1} - \mathbf{H}{:,Q}^{-1} \left(\left[\mathbf{H}^{-1}\right]{QQ}\right)^{-1} \mathbf{H}{Q,:}^{-1}\right)_{-Q}$$ Lazy batching delivers an additional order-of-magnitude wall-clock speedup on modern GPUs without altering a single rounding decision. - Step 3 — Cholesky Decomposition Reformulation & Diagonal Dampening: At multi-billion-parameter scale, repeated application of the block Gaussian elimination inverse update accumulates floating-point roundoff errors, causing $\mathbf{H}F^{-1}$ to lose positive-definiteness and driving remaining weight updates in explosive, arbitrary directions. GPTQ eliminates iterative inverse updates entirely by recognizing that sequentially eliminating rows and columns of a symmetric positive-definite matrix $\mathbf{H}^{-1}$ is mathematically equivalent to computing the upper-triangular Cholesky factor $\mathbf{L}^\top = \text{Cholesky}\left((2\mathbf{X}\mathbf{X}^\top + \lambda \mathbf{I})^{-1}\right)^\top$ upfront (with diagonal dampening $\lambda = 0.01 \cdot \frac{1}{d{\text{col}}}\sum_j \mathbf{H}{jj}$, i.e., $1\%$ of the average diagonal value). Specifically, the $q$-th row of $\mathbf{L}^\top$ equals the required compensation row of $\mathbf{H}{F_q}^{-1}$ scaled by $([\mathbf{H}{F_q}^{-1}]{qq})^{-1/2}$.
Complete GPTQ Layer Quantization Algorithm (arXiv:2210.17323, Algorithm 1): Given weight matrix $\mathbf{W} \in \mathbb{R}^{d_{\text{row}} \times d_{\text{col}}}$, damped inverse Hessian $\mathbf{H}^{-1} = (2\mathbf{X}\mathbf{X}^\top + \lambda\mathbf{I})^{-1}$, and block size $B = 128$:
- Precompute the upper-triangular Cholesky factor: $\mathbf{H}^{-1} \leftarrow \text{Cholesky}(\mathbf{H}^{-1})^\top$.
- For each block offset $i = 0, B, 2B, \dots$: * For each column $j = i, \dots, i + B - 1$ inside the block: * Quantize column: $\mathbf{Q}{:,j} \leftarrow \text{quant}(\mathbf{W}{:,j})$ * Scale normalized column error by Cholesky diagonal: $\mathbf{E}{:,j-i} \leftarrow (\mathbf{W}{:,j} - \mathbf{Q}{:,j}) / [\mathbf{H}^{-1}]{jj}$ * Update remaining columns inside the active block: $\mathbf{W}{:,j:(i+B)} \leftarrow \mathbf{W}{:,j:(i+B)} - \mathbf{E}{:,j-i} \cdot \mathbf{H}{j,j:(i+B)}^{-1}$ * Apply lazy batch update to all trailing columns outside the block: $\mathbf{W}{:,(i+B):} \leftarrow \mathbf{W}{:,(i+B):} - \mathbf{E} \cdot \mathbf{H}_{i:(i+B),(i+B):}^{-1}$
2. Empirical GPTQ Benchmarks Across OPT-175B and BLOOM-176B
Using $128$ random $2048$-token segments from the C4 corpus on a single 80 GB NVIDIA A100 GPU (loading one 6-layer Transformer block at a time and forwarding the quantized block outputs as inputs to the next block), GPTQ achieves the following verified runtimes and accuracy benchmarks (arXiv:2210.17323, Tables 2–7):
| Model & Method | Bit-Width / Group | OPT-13B Wiki2 PPL ↓ | OPT-30B Wiki2 PPL ↓ | OPT-175B Wiki2 PPL ↓ | OPT-175B PTB / C4 PPL ↓ | OPT-175B LAMBADA ↑ | BLOOM-176B Wiki2 / LAMB. |
|---|---|---|---|---|---|---|---|
| FP16 Baseline | 16-bit |
10.13 |
9.56 |
8.34 |
12.01 / 10.13 |
75.59% |
8.11 / 67.40% |
| Round-to-Nearest (RTN) | 4-bit (row-wise) |
11.32 |
10.98 |
10.54 |
14.22 / 11.61 |
71.34% |
8.37 / 66.70% |
| GPTQ | 4-bit (row-wise) |
10.31 |
9.63 |
8.37 |
12.26 / 10.28 |
76.80% |
8.21 / 67.71% |
| Round-to-Nearest (RTN) | 3-bit (row-wise) |
3.4e3 |
1.6e3 |
7.3e3 |
8.0e3 / 4.6e3 |
0.00% |
571.0 / 0.17% |
| GPTQ | 3-bit (row-wise) |
11.61 |
10.27 |
8.68 |
12.68 / 10.67 |
76.19% |
8.64 / 65.10% |
| GPTQ (Grouped) | 3-bit / g1024 (+0.02b) |
— |
— |
8.45 |
12.48 / 10.47 |
77.39% |
8.35 / 67.47% |
| GPTQ (Grouped) | 3-bit / g128 (+0.15b) |
— |
— |
8.45 |
12.37 / 10.36 |
76.42% |
8.26 / 67.86% |
| GPTQ (Extreme 2-Bit) | 2-bit / g128 → g32 |
— |
— |
9.58 → 8.94 |
— |
— |
9.55 → 8.83 |
- Single-GPU 175B Execution & End-to-End Speedups (
arXiv:2210.17323, Table 6): Quantized to 3 bits, OPT-175B occupies approximately $63\text{ GB}$ of memory (including full-precision FP16 input embeddings and output LM head), plus $\approx 9\text{ GB}$ for the complete 2048-token FP16 KV cache—fitting entirely inside a single 80 GB NVIDIA A100 GPU (compared to $5\times 80\text{ GB}$ A100s for FP16 or $3\times 80\text{ GB}$ A100s for 8-bitLLM.int8()). Using GPTQ's fused 3-bit quantized-matrix / FP16-vector (W3A16) dynamic dequantization kernel at batch size 1 (sequence length 128): - On NVIDIA A100 (80 GB): GPU count drops from $5 \to 1$, and average per-token latency falls from $230\text{ ms}$ to $71\text{ ms}$ ($3.24\times$ speedup).
- On NVIDIA A6000 (48 GB): Because the A6000 has lower memory bandwidth (
768 GB/sGDDR6 vs.2,039 GB/sHBM2e on A100-80GB), weight compression yields an even larger gain—GPU count drops from $8 \to 2$, and average per-token latency falls from $589\text{ ms}$ to $130\text{ ms}$ ($4.53\times$ speedup). - For large-batch compute-bound layers (e.g., OPT-175B FC2 with batch size $16 \times 1024$ tokens taking $76\text{ ms}$ on A100 or $365\text{ ms}$ on A6000), decompressing the 3-bit matrix prior to the
GEMMtakes $<1.5\text{ ms}$ on A100 and $<3\text{ ms}$ on A6000 (arXiv:2210.17323, Appendix A.2.2).
3. Activation-Aware Weight Quantization (AWQ) & TinyChat: Protecting 1% Salient Channels Without Mixed Precision
While GPTQ achieves strong perplexity on in-distribution text, its second-order Cholesky reconstruction can overfit the calibration set when calibration samples are scarce or come from a different domain, and it requires column reordering (GPTQ-R) to avoid accuracy drops on models such as LLaMA-7B and OPT-66B (arXiv:2306.00978v5, Section 2). In "AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration" (Lin, Tang, Tang, Yang, Chen, Wang, Xiao, Dang, Gan, & Han, MLSys 2024 Best Paper Award, arXiv:2306.00978v5), MIT HAN Lab and NVIDIA demonstrated a fundamental property of Transformer weight matrices: not all weights in an LLM are equally important, and weight saliency is governed by input activation magnitude rather than weight magnitude.
1. The 0.1%–1% Salient Weight Phenomenon: Activation Distribution vs. Weight Norm
In classical neural network pruning (arXiv:1506.02626), weight importance is measured by weight magnitude or $L_2$-norm $\|\mathbf{W}_{:,j}\|_2$. However, when Lin et al. (arXiv:2306.00978v5, Table 1) quantized OPT models (1.3B, 6.7B, 13B) to 3-bit grouped integers (INT3-g128) while keeping a tiny fraction ($0.1\%$, $1\%$, or $3\%$) of weight channels in FP16, they uncovered a striking dichotomy:
| Model (WikiText-2 PPL ↓) | FP16 Baseline | RTN (INT3-g128) | FP16% by Activation (0.1% / 1% / 3%) | FP16% by Weight Norm (0.1% / 1% / 3%) | FP16% Random (0.1% / 1% / 3%) |
|---|---|---|---|---|---|
OPT-1.3B |
14.62 |
119.00 |
25.03 / 16.91 / 16.68 |
108.71 / 98.55 / 98.08 |
119.76 / 109.38 / 61.49 |
OPT-6.7B |
10.86 |
23.54 |
11.58 / 11.39 / 11.36 |
23.41 / 22.37 / 22.45 |
23.54 / 24.23 / 24.22 |
OPT-13B |
10.13 |
46.04 |
10.51 / 10.43 / 10.42 |
46.07 / 48.96 / 54.49 |
44.87 / 42.00 / 39.71 |
Selecting the top $1\%$ of weight channels by weight $L_2$-norm yields zero improvement over random selection (22.37 vs. 24.23 on OPT-6.7B; 48.96 vs. 42.00 on OPT-13B). Conversely, selecting the top $0.1\%\text{--}1\%$ of weight channels corresponding to the largest average input activation magnitudes immediately restores perplexity from 119.00 → 16.91 on OPT-1.3B, 23.54 → 11.39 on OPT-6.7B, and 46.04 → 10.43 on OPT-13B (arXiv:2306.00978v5, Table 1)! Because input features with large activation magnitudes carry critical semantic and attention routing signals, quantization rounding errors on their corresponding weight channels are amplified directly by $x$ in the product $Q(w)x$.
2. Mathematical Derivation of Per-Channel Activation-Aware Scaling
Although keeping $0.1\%\text{--}1\%$ of channels in FP16 eliminates most quantization error, branching inside a GPU kernel to handle scattered mixed-precision FP16 and INT3/INT4 columns destroys memory coalescing and SIMD vectorization. AWQ protects salient channels without mixed precision by multiplying salient weight channels by a per-channel scaling factor $s > 1$ prior to quantization and inversely scaling the corresponding input activation channel by $1/s$ (arXiv:2306.00978v5, Section 3.2, Equations 1–3):
Consider a weight group $\mathbf{w}$ quantized with $N$ bits and absmax step scaler $\Delta = \frac{\max(|\mathbf{w}|)}{2^{N-1}}$: $$Q(\mathbf{w}) = \Delta \cdot \text{Round}\left(\frac{\mathbf{w}}{\Delta}\right)$$ For a salient weight element $w \in \mathbf{w}$, scaling $w$ by $s > 1$ and $x$ by $1/s$ preserves full-precision mathematical equivalence ($w \cdot x = (w \cdot s)(x / s)$), while its quantized counterpart becomes: $$Q(w \cdot s) \cdot \frac{x}{s} = \Delta' \cdot \text{Round}\left(\frac{w s}{\Delta'}\right) \cdot x \cdot \frac{1}{s}$$ where $\Delta'$ is the group quantization scaler after scaling $w$ by $s$. Comparing the quantization error before and after scaling: $$\text{Err}(Q(w)x) = \Delta \cdot \text{RoundErr}\left(\frac{w}{\Delta}\right) \cdot x, \qquad \text{Err}\left(Q(w \cdot s)\frac{x}{s}\right) = \Delta' \cdot \text{RoundErr}\left(\frac{ws}{\Delta'}\right) \cdot x \cdot \frac{1}{s}$$ Because $\text{Round}(\cdot)$ maps continuous floats to the nearest integer, the rounding error $\text{RoundErr}(\cdot)$ is approximately uniformly distributed on $[0, 0.5]$ with a constant expected value $\mathbb{E}[\text{RoundErr}(\cdot)] \approx 0.25$ regardless of $s$. Furthermore, because only $1\%$ of channels in a group of 128 weights are scaled up, scaling $w$ rarely changes the group maximum $\max(|\mathbf{w}|)$ for moderate $s$, so $\Delta' \approx \Delta$. The ratio of the new quantization error to the original error for the salient weight is therefore: $$\frac{\text{Err}{\text{scaled}}}{\text{Err}{\text{orig}}} = \frac{\Delta'}{\Delta} \cdot \frac{1}{s} \approx \frac{1}{s} \quad (s > 1)$$
Lin et al. (arXiv:2306.00978v5, Table 2) empirically verify this exact ratio on OPT-6.7B under INT3-g128 by scaling the top $1\%$ salient channels across $s \in \{1, 1.25, 1.5, 2, 4\}$:
- At $s = 1$ (RTN): $0\%$ of groups change $\Delta$ ($\Delta'/\Delta = 1.000$), error ratio $= 1.000$, WikiText-2 PPL $= \mathbf{23.54}$.
- At $s = 1.25$: only $2.8\%$ of groups change $\Delta$ (average $\Delta'/\Delta = 1.005$), salient error ratio drops to $0.804$, WikiText-2 PPL improves to $\mathbf{12.87}$.
- At $s = 1.5$: $4.4\%$ of groups change $\Delta$ (average $\Delta'/\Delta = 1.013$), salient error ratio drops to $0.676$, WikiText-2 PPL improves to $\mathbf{12.48}$.
- At $s = 2.0$ (Optimal Fixed Scale): $8.2\%$ of groups change $\Delta$ (average $\Delta'/\Delta = 1.038$), salient error ratio drops by nearly half to $0.519$, and WikiText-2 PPL reaches its fixed-scale minimum of $\mathbf{11.92}$.
- At $s = 4.0$ (Over-Scaling Penalty): Although salient channel error ratio drops to $0.303$, scaling by $4\times$ causes the scaled weight to exceed the original group maximum in $21.2\%$ of groups (inflating average $\Delta'/\Delta$ to $1.213$), which amplifies quantization error on the remaining $99\%$ non-salient channels and degrades WikiText-2 PPL back to $\mathbf{12.36}$.
To automatically balance salient channel protection against non-salient channel error without unstable gradient backpropagation through $\text{Round}(\cdot)$, AWQ formulates an activation-aware per-channel scale search space (arXiv:2306.00978v5, Equations 4–5): $$\mathbf{s}^* = \underset{\mathbf{s}}{\text{argmin}}\; \mathcal{L}(\mathbf{s}) = \left\|Q\left(\mathbf{W} \cdot \text{diag}(\mathbf{s})\right)\left(\text{diag}(\mathbf{s})^{-1} \cdot \mathbf{X}\right) - \mathbf{W}\mathbf{X}\right\|$$ $$\mathbf{s} = \mathbf{s}{\mathbf{X}}^\alpha, \qquad \alpha^* = \underset{\alpha \in [0, 1]}{\text{argmin}}\; \mathcal{L}\left(\mathbf{s}{\mathbf{X}}^\alpha\right)$$ where $\mathbf{s}_{\mathbf{X}} \in \mathbb{R}^{C_i}$ is the per-channel mean absolute activation magnitude collected over a tiny calibration set, and $\alpha \in [0, 1]$ is a single scalar exponent found via a fast 20-point grid search over $[0, 1]$ ($\alpha = 0$ corresponds to no scaling; $\alpha = 1$ corresponds to aggressive activation-proportional scaling), combined with MSE weight clipping. At inference time, $\text{diag}(\mathbf{s})^{-1}$ is fused offline directly into the preceding LayerNorm/RMSNorm or linear projection weights, adding zero runtime kernel overhead.
3. TinyChat SIMD Weight Packing & Comprehensive AWQ vs. GPTQ Benchmarks
To convert theoretical 4-bit memory reductions into real hardware speedups, TinyChat (arXiv:2306.00978v5, Section 4.2 & Figure 4) implements fused on-the-fly dequantization inside GEMM/GEMV kernels, fused QKV + RoPE + pre-allocated KV-cache attention kernels, and SIMD-aware weight bit-packing:
- 128-Bit ARM NEON 32-Weight Interleaving (Up to $1.2\times$ CPU Speedup): Dequantizing a 4-bit weight requires 1 bitwise shift, 1 bitwise
AND, and 1 fused multiply-add (FMA) scaling operation. Because a 128-bit ARM NEON SIMD register holds sixteen 8-bit lanes (or thirty-two 4-bit weights), conventional sequential packing $(w_0, w_1, \dots, w_{31})$ requires scalar unpacking. TinyChat reorders each group of 32 4-bit weights into an interleaved layout: $$w_0, w_{16}, w_1, w_{17}, w_2, w_{18}, \dots, w_{15}, w_{31}$$ so that all 32 weights are unpacked into two aligned 16-lane byte registers (w_0..w_15andw_16..w_31) using just 3 vectorized SIMD instructions (bitwiseANDand shift with a 128-bit mask). Generally, for $2^n$-bit SIMD registers, adjacent weights are offset by $\frac{1}{8} \times 2^n$ indices. - GPU 8-Weight Register Interleaving: On NVIDIA CUDA/PTX architectures, TinyChat packs every 8 4-bit weights into a 32-bit integer register ordered as $w_{\{0, 2, 4, 6, 1, 3, 5, 7\}}$ (
arXiv:2306.00978v5, Section 4.2), allowing fast vectorized lop3/bitwise extraction directly into FP16 half2 registers.
| Precision & Method | Llama-2 7B / 13B / 70B (Wiki2 PPL ↓) | LLaMA 7B / 13B / 30B / 65B (Wiki2 PPL ↓) | CodeLlama-7B MBPP (pass@1 / @10 ↑) | Llama-2 GSM8K 7B / 13B / 70B (↑) | OpenFlamingo-9B 32-Shot COCO (CIDEr ↑) |
|---|---|---|---|---|---|
FP16 Baseline |
5.47 / 4.88 / 3.32 |
5.68 / 5.09 / 4.10 / 3.53 |
38.53 / 49.77 |
13.87 / 26.16 / 56.41 |
81.70 (0-shot: 63.73) |
INT4-g128 RTN |
5.73 / 4.98 / 3.46 |
5.96 / 5.25 / 4.23 / 3.67 |
37.51 / 48.49 |
11.07 / 21.23 / 53.98 |
77.13 (-4.57 Δ) |
INT4-g128 GPTQ / GPTQ-R |
5.69 (5.63) / 4.98 / 3.42 |
6.22 (5.83) / 5.23 / 4.24 / 3.66 |
31.97 / 44.75 |
12.13 / 24.26 / 56.03 |
74.98 (-6.72 Δ) |
INT4-g128 AWQ |
5.60 / 4.97 / 3.41 |
5.78 / 5.19 / 4.21 / 3.62 |
40.64 / 49.25 |
13.57 / 25.25 / 56.40 |
80.53 (-1.17 Δ) |
INT3-g128 RTN |
6.66 / 5.52 / 3.98 |
7.01 / 5.88 / 4.88 / 4.24 |
— |
— |
64.79 (-16.91 Δ) |
INT3-g128 GPTQ / GPTQ-R |
6.43 (6.42) / 5.48 (5.41) / 3.88 (3.86) |
8.81 (6.53) / 5.66 / 4.88 / 4.17 |
— |
— |
64.77 (0-shot: 29.84) |
INT3-g128 AWQ |
6.24 / 5.32 / 3.74 |
6.35 / 5.52 / 4.61 / 3.95 |
— |
— |
74.47 (0-shot: 56.33) |
- Orthogonal Combination (
AWQ + GPTQat ExtremeINT2-g64, Table 9): Because AWQ modifies per-channel scales prior to quantization, it can be combined directly with GPTQ's Hessian compensation. Under extreme 2-bit quantization (INT2-g64), where RTN explodes to7,622–193,210PPL,AWQ + GPTQimproves WikiText-2 perplexity over standaloneGPTQacross every OPT scale:46.67 → 35.71(1.3B),28.15 → 25.70(2.7B),16.65 → 15.71(6.7B),16.74 → 13.25(13B), and11.75 → 11.38(30B). - Measured Hardware Throughput (
arXiv:2306.00978v5, Section 5.4 & Table 10): TinyChat acceleratesLlama-2,MPT, andFalconby $2.7\times\text{ to }3.9\times$ over Hugging Face FP16 on an RTX 4090 (boostingLlama-2-7Bfrom $52\text{ tokens/s}$ to $62\text{ tokens/s}$ via FP16 kernel fusion and a further $3.1\times$ to $\sim 192\text{ tokens/s}$ with 4-bit AWQ kernels), runsLlama-2-13Bat $33\text{ tokens/s}$ on an 8 GB laptop RTX 4070 (where even 7B FP16 OOMs), deploysLlama-2-70Bon a single 64 GB NVIDIA Jetson Orin, runs 7B models at $0.7\text{ tokens/s}$ on a Raspberry Pi 4B, and accelerates multimodalVILA-7Bfrom $81.6 \to 155.3\text{ tokens/s}$ on A100, $58.5 \to 168.1\text{ tokens/s}$ on RTX 4090, and $11.5 \to 35.6\text{ tokens/s}$ on Jetson Orin (andVILA-13Bfrom OOM to $99.0\text{ tokens/s}$ on RTX 4090).
4. Taming Emergent Activation Outliers: LLM.int8() Mixed-Precision Decomposition vs. SmoothQuant (W8A8) Migration
When moving from weight-only quantization (W4A16) to simultaneous weight-and-activation quantization (W8A8) to leverage hardware INT8 Tensor Cores (which deliver $2\times$ the peak TFLOPS of FP16), practitioners encounter the 6.7B Emergent Outlier Wall.
1. LLM.int8() (arXiv:2208.07339): Phase-Shift Physics at 6.7B Parameters and Mixed-Precision Decomposition
In "LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale" (Dettmers, Lewis, Belkada, & Zettlemoyer, NeurIPS 2022, arXiv:2208.07339), systematic analysis of hidden states $\mathbf{X}_l \in \mathbb{R}^{s \times h}$ across Transformer scales ($125\text{M}$ to $175\text{B}$) revealed four foundational laws of emergent outlier features (defined as hidden dimensions $h_i$ with magnitude $\alpha \ge 6.0$ occurring in $\ge 25\%$ of Transformer layers and $\ge 6\%$ of sequence positions):
- The 6.0B → 6.7B Parameter Phase Shift (or Smooth Exponential Perplexity Shift): Between $6.0\text{B}$ and $6.7\text{B}$ parameters, the percentage of Transformer layers impacted by $\ge 6.0$ magnitude outliers jumps abruptly from $65\%$ to $100\%$, while affected sequence dimensions surge from $35\%$ to $75\%$ (
arXiv:2208.07339, Figure 3a). Measured against C4 validation perplexity rather than parameter count, outlier emergence follows a smooth monotonic exponential growth curve as perplexity drops (arXiv:2208.07339, Figures 3b & 4b). - Extreme Concentration ($\approx 150,000$ Outliers in Just 6–7 Feature Columns): Because outliers reach magnitudes up to $20\times\text{--}100\times$ larger than regular activations (reaching magnitudes of $\sim 60\text{--}70$, where multiplying two vectors can even overflow
FP16's maximum representable value of $65,535$), per-tensor and per-token (row-wise) activation scales are stretched across the entire hidden row. Crucially, however, these outliers are strictly column-systematic: across a $2048$-token sequence in a $6.7\text{B}$ or $13\text{B}$ model, roughly $150,000$ outlier values occur, yet they are confined to at most $6$ or $7$ unique feature dimensions ($|O| \le 7$, or $\approx 0.1\%$ of all feature dimensions). - Catastrophic Attention Collapse Upon Outlier Removal: Setting those $\le 7$ outlier feature dimensions to zero before the attention projections reduces mean top-1 attention softmax probability from $\sim 40\%$ down to $\sim 20\%$ and increases validation perplexity by $600\%\text{ to }1000\%$ (
arXiv:2208.07339, Section 4.2), whereas zeroing out $7$ random non-outlier dimensions reduces top-1 probability by only $0.02\%\text{--}0.3\%$ and changes perplexity by $0.1\%$.
To prevent those $\le 7$ feature columns from ruining INT8 quantization bins, LLM.int8() dynamically partitions the input hidden state $\mathbf{X}{f16} \in \mathbb{R}^{s \times h}$ and weight matrix $\mathbf{W}{f16} \in \mathbb{R}^{h \times o}$ along the outlier column set $O = \{i \in \mathbb{Z} \mid 0 \le i \le h,\; \max_s |\mathbf{X}{f16}^{s,i}| \ge \alpha\}$ with threshold $\alpha = 6.0$ (arXiv:2208.07339, Equation 8): $$\mathbf{C}{f16} \approx \sum_{h \in O} \mathbf{X}{f16}^h \mathbf{W}{f16}^h + \mathbf{S}{f16} \cdot \sum{h \notin O} \mathbf{X}{i8}^h \mathbf{W}{i8}^h, \qquad \text{where } \mathbf{S}{f16} = \frac{1}{\mathbf{c}{x_{f16}} \otimes \mathbf{c}{w{f16}}}$$ Here, more than $99.9\%$ of matrix entries ($h \notin O$) are multiplied in 8-bit using vector-wise absmax scaling (per-token row constant $\mathbf{c}{x{f16}} \in \mathbb{R}^s$ and per-output-channel column constant $\mathbf{c}{w{f16}} \in \mathbb{R}^o$), while the $\approx 0.1\%$ outlier columns ($h \in O$) are isolated into an exact 16-bit matrix multiplication and accumulated back into the FP16 output. On C4 validation perplexity across $125\text{M} \to 13\text{B}$ models (arXiv:2208.07339, Table 1), naive Int8 absmax degrades at $13\text{B}$ to 19.08 (worse than $1.3\text{B}$ at 16.55!), whereas Absmax LLM.int8() matches 32-bit Float to the hundredth of a point (12.45 vs. 12.45 at 13B, and 13.24 vs. 13.30 at 6.7B), cutting BLOOM-176B memory by $1.96\times$.
2. SmoothQuant (arXiv:2211.10438): Offline Per-Channel Difficulty Migration for Hardware W8A8 GEMMs
While LLM.int8() halves GPU memory, its runtime dynamic column decomposition ($\alpha \ge 6.0$ thresholding, sub-matrix slicing, and dual FP16 + INT8 kernel dispatch) introduces significant latency overhead—making LLM.int8() slower than standard FP16 inference on OPT-13B (237.1 ms vs. 152.6 ms at sequence length 256) and OPT-30B (387.9 ms vs. 343.0 ms, arXiv:2211.10438 Table 11).
In "SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models" (Xiao, Lin, Seznec, Wu, Demouth, & Han, ICML 2023, arXiv:2211.10438), MIT and NVIDIA observed that while activations $\mathbf{X}$ have extreme channel-persistent outliers (up to $100\times$ larger than normal channels), weight distributions $\mathbf{W}$ are relatively flat and uniform. Because hardware INT8 GEMM kernels cannot perform per-channel ($C_i$) activation scaling at runtime, SmoothQuant divides the input activation $\mathbf{X} \in \mathbb{R}^{T \times C_i}$ by a per-channel smoothing factor $\mathbf{s} \in \mathbb{R}^{C_i}$ and multiplies the weight matrix $\mathbf{W} \in \mathbb{R}^{C_i \times C_o}$ by $\text{diag}(\mathbf{s})$ offline (arXiv:2211.10438, Equations 3–4): $$\mathbf{Y} = \left(\mathbf{X}\,\text{diag}(\mathbf{s})^{-1}\right) \cdot \left(\text{diag}(\mathbf{s})\,\mathbf{W}\right) = \hat{\mathbf{X}}\,\hat{\mathbf{W}}$$ $$\mathbf{s}_j = \frac{\max\left(|\mathbf{X}_j|\right)^\alpha}{\max\left(|\mathbf{W}_j|\right)^{1-\alpha}}, \qquad j = 1, 2, \dots, C_i$$ where $\max(|\mathbf{X}_j|)$ is estimated offline over $512$ calibration sentences from the Pile, and the migration strength $\alpha \in [0, 1]$ controls how much quantization difficulty is migrated from activations to weights:
- If $\alpha$ is too small ($<0.4$), activation outliers remain unsmoothed and
INT8activation quantization fails. - If $\alpha$ is too large ($>0.6$ on OPT), too much outlier magnitude is pushed into $\hat{\mathbf{W}}$ and
INT8weight quantization degrades. - At the sweet spot—$\alpha = 0.5$ for all
OPTandBLOOMmodels (where $\hat{\mathbf{X}}_j$ and $\hat{\mathbf{W}}_j$ share the exact same maximum magnitude $\sqrt{\max|\mathbf{X}_j|\max|\mathbf{W}_j|}$), $\alpha = 0.75$ forGLM-130B(which has $\sim 30\%$ outlier channels), $\alpha = 0.6\text{--}0.7$ forFalcon-7B/40B, and $\alpha = 0.8\text{--}0.9$ forLLaMA-1/2,Mistral-7B, andMixtral-8x7B(arXiv:2211.10438, Tables 6 & 7)—both $\hat{\mathbf{X}}$ and $\hat{\mathbf{W}}$ become smooth enough for pure per-tensor staticINT8(SmoothQuant-O3) quantization across all linear layers and attention batched matrix multiplications (BMMs), with $\text{diag}(\mathbf{s})^{-1}$ fused offline into preceding LayerNorm or linear layers!
| Quantization Method | Weight / Activation Scheme | OPT-175B 7-Task Avg ↑ / Wiki PPL ↓ | GLM-130B Avg Acc ↑ | Llama-2 7B / 13B / 70B Wiki PPL ↓ | Mixtral-8x7B / Mistral-7B Wiki PPL ↓ | OPT-30B Latency (Seq 256 / 512, BS=4) |
|---|---|---|---|---|---|---|
FP16 Baseline |
FP16 / FP16 | 66.9% / 10.99 |
73.8% |
5.474 / 4.950 / 3.320 |
3.842 / 5.253 |
343.0 ms / 659.9 ms |
Naive W8A8 |
Per-tensor / Per-tensor dyn. | 35.5% / 93,080 |
26.9% |
— |
— |
— |
ZeroQuant |
Group-wise / Per-token dyn. | 35.8% / 84,648 |
26.7% |
— |
— |
— |
Outlier Suppression |
Per-tensor / Per-tensor static | 36.0% / 96,151 |
63.5% |
— |
— |
— |
LLM.int8() |
Per-channel / Per-token + FP16 | 66.7% / 11.10 |
73.8% |
— |
— |
387.9 ms / 654.9 ms (slower) |
SmoothQuant-O1 |
Per-tensor / Per-token dyn. | 66.5% / 11.11 |
73.7% |
5.515 / 4.929 / 3.359 |
3.893 / 5.277 |
246.7 ms / 490.7 ms |
SmoothQuant-O2 |
Per-tensor / Per-tensor dyn. | 66.4% / 11.14 |
72.5% |
— |
— |
240.2 ms / 478.3 ms |
SmoothQuant-O3 |
Per-tensor / Per-tensor static | 66.8% / 11.17 |
72.8% |
— |
— |
227.6 ms / 458.4 ms (1.51×) |
Integrated into NVIDIA FasterTransformer, SmoothQuant-O3 delivers up to $1.56\times$ context speedup and $1.42\times$ decoding speedup (2488 ms → 1753 ms at BS=16, SeqLen=512 on OPT-30B while cutting memory from 69 GB to 44 GB, and preventing FP16 OOM at BS=16, SeqLen=1024 in 61 GB), serves OPT-66B on 1 A100 instead of 2 and OPT-175B on 4 A100s instead of 8, and scales to Megatron-Turing NLG 530B (MT-NLG 530B)—matching FP16 zero-shot accuracy (73.1% INT8 vs. 73.1% FP16 across LAMBADA 77.2%, HellaSwag 60.4%, PIQA 80.7%, and WinoGrande 74.1%) while cutting GPU count from $16 \to 8$ (1,040 GB → 527 GB at SeqLen 128; 1,095 GB → 570 GB and 1,707 ms → 1,689 ms at SeqLen 1024), fitting a $>500\text{B}$ model inside a single 8-GPU node (arXiv:2211.10438, Tables 9 & 10).
5. Information-Theoretic 4-Bit NormalFloat (NF4) & Double Quantization in QLoRA
While GPTQ, AWQ, and SmoothQuant target inference deployment, backpropagating gradients through a 4-bit quantized base model to fine-tune Low-Rank Adapters (LoRA, $\mathbf{Y} = \mathbf{X}\mathbf{W} + s\mathbf{X}\mathbf{L}_1\mathbf{L}_2$) required a data representation that minimizes quantization variance across bell-curved neural weights without expensive per-tensor empirical quantile sorting. In "QLoRA: Efficient Finetuning of Quantized LLMs" (Dettmers, Pagnoni, Holtzman, & Zettlemoyer, NeurIPS 2023, arXiv:2305.14314), the University of Washington introduced 4-bit NormalFloat (NF4), Double Quantization (DQ), and Paged Optimizers.
1. Mathematical Construction of the 4-Bit NormalFloat (NF4) Quantile Grid
Quantile Quantization (arXiv:2110.02861) is information-theoretically optimal for any distribution because it partitions the cumulative distribution function (CDF) into $2^k$ equal-probability intervals so that every quantization bin is assigned an identical expected number of tensor values. Whereas general quantile quantization requires slow approximate SRAM quantile estimation at runtime, neural network pretrained weights follow a fixed zero-centered normal distribution $\mathcal{N}(0, \sigma^2)$ up to a block standard-deviation scale factor.
By normalizing every block of $B = 64$ weights into $[-1, 1]$ via absmax rescaling, all weight blocks share the exact same theoretical standard normal quantiles up to a constant scale! QLoRA constructs the $2^k = 16$ discrete values $\{q_0, q_1, \dots, q_{15}\} \subset [-1, 1]$ of the $k$-bit NormalFloat (NF4) data type via three exact steps (arXiv:2305.14314, Section 3, Equation 4):
- Estimate the $2^k$ bin midpoints of the standard normal inverse cumulative distribution function (quantile function) $Q_X(\cdot) = \Phi^{-1}(\cdot)$ of $\mathcal{N}(0, 1)$: $$q_i = \frac{1}{2}\left(Q_X\left(\frac{i}{2^k + 1}\right) + Q_X\left(\frac{i + 1}{2^k + 1}\right)\right)$$
- Exact Zero-Point Asymmetric Partitioning: A purely symmetric $2^k$-bin normal quantile grid does not contain an exact
0.0representation, which is essential for quantizing zero-padding and sparse zero weights with zero error. To guarantee an exact discrete zero point0.0while using all $2^k = 16$ codes of a 4-bit datatype, NF4 computes quantiles separately across two asymmetric halves: $2^{k-1} = 8$ quantiles for the negative half $[-1, 0]$ and $2^{k-1} + 1 = 9$ quantiles for the positive half $[0, +1]$, normalizes both sets into $[-1, 1]$, and takes their union while removing one of the two duplicate0.0endpoints (arXiv:2305.14314, Section 3). - Normalize each input weight block $\mathbf{W}_b$ of size $B = 64$ into $[-1, 1]$ via its absmax constant $c_2^{\text{FP32}}$ and round each element to the nearest
NF4lookup-table value $q_i$.
2. Double Quantization (DQ) Memory Calculus & QLoRA forward/backward Formulation
Because NF4 uses a fine block size of $B = 64$ weights to prevent outlier distortion, storing a 32-bit floating-point scale constant $c_2^{\text{FP32}}$ per block adds: $$\frac{32\text{ bits}}{64\text{ parameters}} = \mathbf{0.50\text{ bits/parameter}}$$ of metadata overhead ($\approx 4\text{ GB}$ on a 65B model). Double Quantization (DQ) eliminates 74.6% of this scale overhead by centering the positive first-level constants $c_2^{\text{FP32}}$ around their mean and quantizing them into 8-bit floating point (FP8) $c_2^{\text{FP8}}$ using a second-level block size of $B_2 = 256$ and a second-level FP32 scale $c_1^{\text{FP32}}$ (arXiv:2305.14314, Section 3): $$\text{Overhead}_{\text{DQ}} = \frac{8}{64} + \frac{32}{64 \times 256} = 0.125 + 0.001953125 \approx \mathbf{0.127\text{ bits/parameter}}$$ reducing average scale storage by $0.373\text{ bits/parameter}$ (saving $\approx 3\text{ GB}$ on a 65B checkpoint and bringing total weight storage to $4.127\text{ bits/parameter}$).
During forward and backward passes ($\frac{\partial E}{\partial \mathbf{L}_i}$ via $\frac{\partial \mathbf{X}}{\partial \mathbf{W}}$), QLoRA dynamically double-dequantizes the frozen NF4 storage tensor into the BF16 compute dtype (arXiv:2305.14314, Equations 5–6): $$\mathbf{Y}^{\text{BF16}} = \mathbf{X}^{\text{BF16}}\,\text{doubleDequant}\left(c_1^{\text{FP32}},\; c_2^{\text{FP8}},\; \mathbf{W}^{\text{NF4}}\right) + \mathbf{X}^{\text{BF16}}\,\mathbf{L}_1^{\text{BF16}}\,\mathbf{L}_2^{\text{BF16}}$$ $$\text{doubleDequant}\left(c_1^{\text{FP32}},\; c_2^{\text{FP8}},\; \mathbf{W}^{\text{NF4}}\right) = \text{dequant}\left(\text{dequant}\left(c_1^{\text{FP32}},\; c_2^{\text{FP8}}\right),\; \mathbf{W}^{\text{NF4}}\right) = \mathbf{W}^{\text{BF16}}$$
| 4-Bit / 16-Bit Data Type | Effective Bits / Param (B=64) | Pile Common Crawl Mean PPL ↓ (125M–13B) | LLaMA 7B MMLU (Alpaca / FLAN v2) ↑ | LLaMA 13B MMLU (Alpaca / FLAN v2) ↑ | LLaMA 33B MMLU (Alpaca / FLAN v2) ↑ | LLaMA 65B MMLU (Alpaca / FLAN v2) ↑ | Mean 5-Shot MMLU ↑ |
|---|---|---|---|---|---|---|---|
BFloat16 LoRA Baseline |
16.000 bpw |
— |
38.4 / 45.6 |
47.2 / 50.6 |
57.7 / 60.5 |
61.8 / 62.5 |
53.0% |
Int4 (Uniform Integer) |
4.500 bpw |
34.34 |
— |
— |
— |
— |
— |
Float4 (E2M1) |
4.500 bpw |
31.07 |
37.2 / 44.0 |
47.3 / 50.0 |
55.9 / 58.5 |
61.3 / 63.3 |
52.2% (-0.8%) |
Float4 (E3M0) |
4.500 bpw |
29.48 |
— |
— |
— |
— |
— |
NFloat4 + DQ (QLoRA) |
4.127 bpw |
27.41 |
39.0 / 44.5 |
47.5 / 50.7 |
57.3 / 59.2 |
61.8 / 63.9 |
53.1% (+0.1%) |
Furthermore, Dettmers et al. (arXiv:2305.14314, Section 2) profile the exact training memory breakdown of a 7B LLaMA model at batch size 1: the 4-bit base model consumes $5,048\text{ MB}$, the LoRA adapter parameters ($0.2\%$ of weights) consume only $26\text{ MB}$, and LoRA activation input gradients consume $567\text{ MB}$ without gradient checkpointing or $18\text{ MB}$ with gradient checkpointing. Because LoRA parameters themselves use negligible memory, placing LoRA adapters on every linear layer of the Transformer block (rather than only $W_q, W_v$) is essential to match 16-bit full fine-tuning, enabling Guanaco-65B (41 GB footprint, trained in 24 hours on a single 48 GB GPU) to achieve $99.3\%$ of ChatGPT (1022 Elo vs. ChatGPT 966 Elo on GPT-4 Vicuna judge; 1023 Elo vs. 916 Elo on human raters) and Guanaco-33B (21 GB footprint, trained in $<12$ hours on a 24 GB consumer GPU) to achieve $97.8\%$ of ChatGPT (arXiv:2305.14314, Tables 1, 6, & 7).
6. Local CPU/Apple Silicon Edge Quantization: GGUF K-Quant Super-Blocks & Importance-Matrix (IQ) Vector Quants
For unified-memory Apple Silicon (M1/M2/M3/M4 Metal/MPS) and multi-core x86/ARM CPU inference via llama.cpp, GGML, Ollama, LM Studio, and Hugging Face kernels (ggml-org/ggml-quantization, huggingface.co/docs/transformers/en/quantization/gguf), models are distributed in the single-file GGUF (GGML Universal File) binary container (huggingface.co/docs/hub/en/gguf).
Unlike legacy first-generation GGML formats (Q4_0, Q4_1, Q5_0, Q5_1, Q8_0), which quantized independent 32-weight blocks with an uncompressed 16-bit scale per block (adding $16 / 32 = 0.5\text{ bpw}$ scale overhead, or $1.0\text{ bpw}$ when including a 16-bit block minimum), K-Quants (Q2_K, Q3_K, Q4_K, Q5_K, Q6_K, introduced in llama.cpp PR #1684) implement a two-level Hierarchical Super-Block Architecture (essentially applying Double Quantization inside cache-aligned C structs of $256$ weights).
1. Exact Bit-Layout and Bits-Per-Weight (bpw) Calculus of GGUF K-Quants & IQ Types
Every K-Quant super-block groups exactly $256$ consecutive weights into either $8$ sub-blocks of $32$ weights or $16$ sub-blocks of $16$ weights. Each sub-block's local scale (and optional local minimum) is quantized to 4, 6, or 8 bits, and all sub-block scales inside the 256-weight super-block are scaled by a shared FP16 super-block scale $d_{\text{super}}$ (and optional FP16 super-block minimum $m_{\text{super}}$). Using the official Hugging Face Hub GGUF Quantization Type Specification (huggingface.co/docs/hub/en/gguf#quantization-types), we can verify the exact bit-level formula and effective bits-per-weight (bpw) for every GGUF type:
| GGUF Type | Weight Bits | Super-Block / Sub-Block Geometry | Dequantization Formula & Sub-Block Scale Precision | Exact Bits Per Weight (bpw) | 8B Model Size (GiB) |
|---|---|---|---|---|---|
F16 / BF16 |
16-bit |
Unquantized IEEE 754 / BrainFloat | Exact 16-bit float (1S + 5E + 10M or 1S + 8E + 7M) |
16.0000 bpw |
14.90 GiB |
Q8_0 (Legacy) |
8-bit |
1 block of 32 weights |
w = q * block_scale(FP16) ($32\times 8 + 16 = 272\text{ bits}/32$) |
8.5000 bpw |
7.92 GiB |
Q6_K |
6-bit |
Super-block 256 (16 × 16 weights) |
w = q * block_scale(8-bit) + 1 FP16 super-scale ($1536 + 128 + 16 = 1680\text{b}$) |
6.5625 bpw |
6.11 GiB |
Q5_K |
5-bit |
Super-block 256 (8 × 32 weights) |
w = q * block_scale(6-bit) + block_min(6-bit) + 2 FP16 super-consts ($1408\text{b}$) |
5.5000 bpw |
5.12 GiB |
Q4_K |
4-bit |
Super-block 256 (8 × 32 weights) |
w = q * block_scale(6-bit) + block_min(6-bit) + 2 FP16 super-consts ($1152\text{b}$) |
4.5000 bpw |
4.19 GiB |
IQ4_XS |
4-bit |
Super-block 256 + Importance Matrix |
Non-linear lookup grid + super_block_scale & imatrix |
4.2500 bpw |
3.96 GiB |
Q3_K |
3-bit |
Super-block 256 (16 × 16 weights) |
w = q * block_scale(6-bit) + 1 FP16 super-scale ($768 + 96 + 16 = 880\text{b}$) |
3.4375 bpw |
3.20 GiB |
IQ3_XXS |
3-bit |
Super-block 256 + Importance Matrix |
Vector lattice codebook + super_block_scale & imatrix |
3.0600 bpw |
2.85 GiB |
Q2_K |
2-bit |
Super-block 256 (16 × 16 weights) |
w = q * block_scale(4-bit) + block_min(4-bit) + 2 FP16 super-consts ($672\text{b}$) |
2.6250 bpw |
2.44 GiB |
IQ2_XXS / IQ1_S |
2-bit / 1-bit |
Super-block 256 + Importance Matrix |
$E_8$-inspired vector codebook + super_block_scale & imatrix |
2.06 / 1.56 bpw |
1.92 / 1.45 GiB |
- Why K-Quant Mixture Variants (
Q4_K_M,Q5_K_M) Outperform Uniform Bit-Widths: In a GGUF mixture profile such asQ4_K_M, the majority of feed-forward and attention projection tensors useQ4_K($4.5\text{ bpw}$), while highly sensitive tensors—specifically the attention value projectionattn_v, output projectionattn_output, and MLPffn_downlayers (or a fraction of their layers)—are promoted toQ6_K($6.5625\text{ bpw}$). During runtime inference,llama.cppquantizes incomingFP32/FP16activations into the intermediateQ8_Kformat ($256$-weight blocks withw = q * block_scale) so that all 2-bit through 6-bit dot products execute as ultra-fast integer SIMD inner products (Q4_K × Q8_K).
7. Rotation-Based Incoherence & Vector Lattice Quantization: QuIP# ($E_8$ Lattice) and SpinQuant (Stiefel Manifold Cayley SGD)
Even with per-channel scaling (SmoothQuant and AWQ), compressing both weights and activations to 4 bits (W4A4)—or compressing weights, activations, and the KV cache all to 4 bits (W4A4KV4)—causes traditional PTQ and even quantization-aware training (LLM-QAT) to collapse (arXiv:2405.16406, Table 1: on LLaMA-2 7B at W4A4KV4, RTN drops to 37.1% accuracy / 2,382.5 Wiki PPL, GPTQ drops to 36.8% / 9,253.1 PPL, SmoothQuant drops to 39.0% / 698.7 PPL, and LLM-QAT drops to 44.9% / 14.9 PPL).
Two breakthrough papers in 2024–2025—QuIP# (Tseng, Chee, Sun, Kuleshov, & De Sa, ICML 2024, arXiv:2402.04396) and SpinQuant (Liu et al., Meta AI, ICLR 2025, arXiv:2405.16406)—solve extreme sub-4-bit and W4A4KV4 quantization via Orthogonal Matrix Rotation Incoherence.
1. Rotational Invariance & Kurtosis Reduction ($\kappa > 200 \to \kappa \approx 3$)
Consider an activation row vector $\mathbf{x} \in \mathbb{R}^{1 \times d}$ entering a linear layer $\mathbf{W} \in \mathbb{R}^{d \times d_{\text{out}}}$. For any orthonormal rotation matrix $\mathbf{R} \in \mathbb{R}^{d \times d}$ satisfying $\mathbf{R}^\top \mathbf{R} = \mathbf{R} \mathbf{R}^\top = \mathbf{I}$, inserting $\mathbf{R}\mathbf{R}^\top$ between $\mathbf{x}$ and $\mathbf{W}$ leaves the full-precision inner product mathematically identical: $$\mathbf{y} = \mathbf{x}\mathbf{W} = \left(\mathbf{x}\mathbf{R}\right)\left(\mathbf{R}^\top \mathbf{W}\right) = \tilde{\mathbf{x}}\widetilde{\mathbf{W}}$$ Geometrically, if channel $x_1$ has a massive outlier while $x_2, \dots, x_d$ are small, rotating the coordinate axes blends the outlier energy uniformly across all $d$ coordinates, transforming a spiky, heavy-tailed distribution into a smooth, ball-shaped sub-Gaussian distribution (arXiv:2402.04396, arXiv:2405.16406 Figure 6):
- Kurtosis Collapse (
arXiv:2405.16406, Section 2.1 & Figure 3a): InLLaMA-2 7B, the empirical kurtosis $\kappa$ (a fourth-moment measure of tail heaviness where a true Gaussian has $\kappa = 3$) of unrotated residual activations exceeds $\kappa > 200$ across many layers. Multiplying the residual stream by an orthogonal rotation matrix $\mathbf{R}$ collapses activation kurtosis across every single layer down to $\kappa \approx 3$! - QuIP# Randomized Hadamard Transform & $E_8$ Lattice Codebooks (
arXiv:2402.04396): A Hadamard matrix $\mathbf{H} \in \{-1/\sqrt{d}, +1/\sqrt{d}\}^{d \times d}$ rotates all axes by the maximal uniform angle ($45^\circ$ in 2D) and can be applied in $O(d \log d)$ additions/subtractions via the Fast Walsh-Hadamard Transform (FWHT). In QuIP# (arXiv:2402.04396), weights are rendered incoherent via randomized Hadamard transforms ($\mathbf{H}\mathbf{S}$, where $\mathbf{S}$ is a random diagonal sign matrix $\pm 1$) and then vector-quantized in 8-dimensional blocks using the $E_8$ lattice—which achieves the mathematically optimal 8-dimensional unit-ball sphere packing density—reaching5.6 / 5.0 / 3.4WikiText-2 PPL at 4-bit onLLaMA-2 7B / 13B / 70B(matching5.5 / 5.0 / 3.3FP16).
2. SpinQuant (arXiv:2405.16406): Why Random Rotations Vary by 13 Points & How Cayley SGD Optimizes the Stiefel Manifold
In "SpinQuant: LLM quantization with learned rotations" (arXiv:2405.16406v4, Section 2.2 & Figure 4), Meta AI discovered a critical flaw in random rotation methods (such as QuaRot, arXiv:2404.00456): across $100$ random orthogonal rotations of LLaMA-2 7B under W4A4, downstream 8-task zero-shot accuracy varies by up to $13\text{ percentage points}$ (and even across $100$ random Hadamard matrices $\mathbf{H}\mathbf{S}$, performance varies by $6\text{ percentage points}$; on LLaMA-3 70B at W4A4KV4 with RTN, QuaRot drops by $33.2$ points to 41.3% accuracy and 92.4 Wiki PPL!).
SpinQuant eliminates random rotation variance by defining four strategic rotation matrices across the Transformer block (arXiv:2405.16406v4, Section 3.1 & Figure 1):
- Mergeable Residual Rotation $\mathbf{R}1 \in \mathbb{R}^{D{\text{token}} \times D_{\text{token}}}$ and Head-Wise Attention Value/Output Rotation $\mathbf{R}2 \in \mathbb{R}^{D{\text{head}} \times D_{\text{head}}}$ (
SpinQuant_no_had): By folding the RMSNorm scale vector $\boldsymbol{\alpha}$ into the immediately following linear weights (Q/K/VandUp/Gateprojections), the entire Transformer residual stream becomes rotationally invariant. Rotating the embedding output by $\mathbf{R}_1$ and right-multiplying attention/MLP outputs by $\mathbf{R}_1^\top = \mathbf{R}_1^{-1}$—alongside rotating each attention head's value matrix $\mathbf{W}_v$ by $\mathbf{R}_2$ and output projection $\mathbf{W}_o$ by $\mathbf{R}_2^\top$—allows $\mathbf{R}_1$ and $\mathbf{R}_2$ to be completely absorbed offline into the model weights, requiring zero runtime forward-pass changes or custom kernels! - Online Fast Hadamard Rotations $\mathbf{R}_3, \mathbf{R}_4$ (
SpinQuant_had): For extreme 4-bit activation and 4-bit KV-cache quantization (W4A4KV4), SpinQuant inserts two lightweight online Fast Hadamard Transforms: $\mathbf{R}_3$ on the Query/Key heads prior to KV-cache quantization, and $\mathbf{R}_4$ inside the MLP intermediate activation before thedown_projlayer (adding only $\sim 8\%$ end-to-end latency overhead, vs. 4 online Hadamards per block in QuaRot).
To learn the optimal absorbed rotations $\{\mathbf{R}1, \mathbf{R}_2\}$ (which represent only $\sim 0.26\%$ of the frozen weight parameter count) while strictly preserving orthonormality ($\mathbf{R}^\top \mathbf{R} = \mathbf{I}$), SpinQuant optimizes directly over the Stiefel Manifold $\mathcal{M} = \{\mathbf{R} \mid \mathbf{R}^\top \mathbf{R} = \mathbf{I}\}$ using Cayley SGD for 100 iterations on 800 WikiText-2 calibration samples (taking just 13 to 30 minutes on 1B–13B models and 3.5 hours on 70B) with activations quantized and weights kept in FP16 (arXiv:2405.16406v4, Equations 2–4), followed by standard GPTQ on the rotated weights: $$\underset{\mathbf{R}_1, \mathbf{R}_2 \in \mathcal{M}}{\text{argmin}}\; \mathcal{L}_Q\left(\mathbf{R}_1, \mathbf{R}_2 \mid \mathbf{W}, \mathbf{X}\right)$$ $$\mathbf{R}' = \Delta\mathbf{R}(\mathbf{Y})\mathbf{R} := \left(\mathbf{I} - \frac{\alpha}{2}\mathbf{Y}\right)^{-1}\left(\mathbf{I} + \frac{\alpha}{2}\mathbf{Y}\right)\mathbf{R}$$ $$\mathbf{Y} = \hat{\mathbf{G}} - \hat{\mathbf{G}}^\top, \qquad \hat{\mathbf{G}} := \mathbf{G}\mathbf{R}^\top - \frac{1}{2}\mathbf{R}\mathbf{R}^\top \mathbf{G}\mathbf{R}^\top, \qquad \mathbf{G} := \nabla{\mathbf{R}}\mathcal{L}_Q$$ Because $\mathbf{Y}^\top = -\mathbf{Y}$ is skew-symmetric, its Cayley Transform $\Delta\mathbf{R}(\mathbf{Y}) = (\mathbf{I} - \frac{\alpha}{2}\mathbf{Y})^{-1}(\mathbf{I} + \frac{\alpha}{2}\mathbf{Y})$ is mathematically guaranteed to be orthonormal, keeping $\mathbf{R}'$ exactly on the Stiefel manifold at every gradient step!
| Precision (W-A-KV) & Method | LLaMA-2 7B (8-Task Avg ↑ / Wiki ↓) | LLaMA-2 13B (8-Task Avg ↑ / Wiki ↓) | LLaMA-2 70B (8-Task Avg ↑ / Wiki ↓) | LLaMA-3 8B (8-Task Avg ↑ / Wiki ↓) | Mistral-7B (8-Task Avg ↑ / Wiki ↓) |
|---|---|---|---|---|---|
16-16-16 Full Precision |
66.9% / 5.5 |
68.3% / 5.0 |
72.9% / 3.3 |
69.6% / 6.1 |
71.0% / 5.4 |
4-8-8 GPTQ |
64.8% / 20.2 |
65.3% / 5.9 |
71.6% / 4.3 |
64.6% / 7.2 |
51.7% / 8.6 |
4-8-8 SpinQuantno had |
65.8% / 5.8 |
68.1% / 5.1 |
72.2% / 3.7 |
68.6% / 6.7 |
69.4% / 5.7 (+17.7%) |
4-4-4 RTN |
37.1% / 2,382.5 |
35.5% / 7,428.8 |
35.0% / 2e5 |
43.1% / 3e2 |
41.4% / 4e2 |
4-4-4 SmoothQuant |
39.0% / 698.7 |
40.5% / 56.6 |
55.9% / 10.5 |
38.7% / 2e3 |
— |
4-4-4 LLM-QAT |
44.9% / 14.9 |
35.0% / 3,777.5 |
— |
43.2% / 52.5 |
— |
4-4-4 GPTQ |
36.8% / 9,253.1 |
35.2% / 5,237.1 |
35.6% / 1e6 |
40.5% / 2e2 |
41.3% / 2e2 |
4-4-4 SpinQuanthad |
64.0% / 5.9 |
66.9% / 5.3 |
71.2% / 3.8 |
65.5% / 7.3 |
68.6% / 5.8 |
On an Apple MacBook M1 Pro CPU (macOS 14.5), SpinQuant compresses LLaMA-3 8B from W16A16 (177.15 ms/token) to W4A8, accelerating decoding by $3.01\times$ to 58.88 ms/token with SpinQuant_no_had and 63.90 ms/token with SpinQuant_had (arXiv:2405.16406v4, Table 6).
8. Hardware Low-Bit Floating-Point Formats: FP8 (E4M3 vs. E5M2) and Microscaling FP4 (MXFP4 & NVFP4)
While integer formats (INT8, INT4) space representable values uniformly across a linear grid, floating-point formats allocate bits across a sign ($S$), biased exponent ($E$), and trailing significand/mantissa ($M$), sampling the real line non-linearly with dense resolution near zero and wide dynamic range at large magnitudes.
IEEE 754 Single-Precision 32-Bit Floating-Point Bit Layout Showing 1 Sign Bit, 8 Biased Exponent Bits, and 23 Mantissa Fraction Bits
1. The Joint NVIDIA / Arm / Intel FP8 Specification (arXiv:2209.05433): E4M3 vs. E5M2
In "FP8 Formats for Deep Learning" (Micikevicius et al., NVIDIA, Arm, & Intel, arXiv:2209.05433), hardware architects standardized a dual-encoding 8-bit floating-point binary interchange format supported natively in NVIDIA Ada (SM89), Hopper (H100/H200), and Blackwell (B200), AMD Instinct MI300X, and Intel Gaudi/XPU Tensor Cores:
E4M3(1 Sign, 4 Exponent, 3 Mantissa Bits — Weights & Forward Activations): Designed for maximum precision during inference and the forward pass of training. To maximize dynamic range with only 4 exponent bits (exponent bias $= 7$),E4M3deviates from IEEE 754 by eliminating Infinities (N/A) and reserving only a single mantissa bit-pattern (S.1111.111_2) forNaN! Reclaiming the biased exponent1111_2adds one extra power of two (extending dynamic range from 17 to 18 binades) and unlocks seven additional normal magnitudes (256, 288, 320, 352, 384, 416, 448), boosting maximum normal magnitude from $240$ up to $1.75 \times 2^8 = 448$ while preserving signed zeros (S.0000.000_2) so integer-based float sorting remains valid (arXiv:2209.05433, Section 3.1 & Table 1).E5M2(1 Sign, 5 Exponent, 2 Mantissa Bits — Backward Gradients): Follows strict IEEE 754 special-value conventions (exponent bias $= 15$, Infinities atS.11111.00_2, NaNs atS.11111.{01,10,11}_2), providing 32 binades of dynamic range (identical exponent width toFP16, with maximum normal value $1.75 \times 2^{15} = 57,344$ and minimum subnormal $2^{-16}$) required by heavy-tailed backward activation gradients.
IEEE 754 Relative Precision Step Curve Illustrating Non-Linear Logarithmic Spacing and Constant Relative Precision Across Floating-Point Binades
| Specification / Benchmark | FP8 E4M3 (Weights & Activations) |
FP8 E5M2 (Gradients / Wide Range) |
INT8 Fixed-Point PTQ |
FP16 / BF16 16-Bit Baseline |
|---|---|---|---|---|
| Bit Layout & Exponent Bias | 1S + 4E + 3M (Bias = 7, 18 binades) |
1S + 5E + 2M (Bias = 15, 32 binades) |
8-bit uniform integer [-127, 127] |
1S+5E+10M (FP16) / 1S+8E+7M (BF16) |
| Infinities & NaN Encoding | Infinities: N/A | NaN: S.1111.111₂ |
Inf: S.11111.00₂ | NaN: S.11111.{01,10,11}₂ |
Saturating integer clip | IEEE 754 standard Inf & NaN |
| Max Normal / Min Normal | 1.75 × 2⁸ = 448 / 2⁻⁶ |
1.75 × 2¹⁵ = 57,344 / 2⁻¹⁴ |
127 · Δ / 1 · Δ |
65,504 (FP16) / ~3.39 × 10³⁸ (BF16) |
| Max Subnormal / Min Subnormal | 0.875 × 2⁻⁶ / 2⁻⁹ |
0.75 × 2⁻¹⁴ / 2⁻¹⁶ |
N/A |
~5.96 × 10⁻⁸ (FP16 min subnorm) |
| BERT-Base / Large SQuAD v1.1 F1 ↑ | 88.09 / 90.94 (PTQ) |
Used for backward pass | 76.89 / 89.65 (PTQ drops -11.3 F1) |
88.19 / 90.87 |
| GPT-3 126M / 1.3B / 6.7B Wiki103 PPL ↓ | 19.43 / 10.29 / 8.41 (PTQ) |
Used for backward pass | 28.37 / 12.74 / 10.29 (PTQ degrades) |
19.01 / 10.19 / 8.51 |
| GPT-175B Training PPL ↓ (at 75% iter) | 6.68 (FP8 E4M3 forward + E5M2 backward training, zero hyperparameter changes) |
Cannot train in INT8 | 6.65 (BF16 baseline) |
|
As shown in Table 5 of arXiv:2209.05433, direct post-training quantization of 16-bit trained GPT-3 6.7B and BERT-Base into FP8 E4M3 (using per-channel weight scales and per-tensor activation scales) immediately preserves full-precision quality (8.41 vs. 8.51 WikiText-103 PPL on GPT-3 6.7B, and 88.09 vs. 88.19 SQuAD F1 on BERT-Base) without requiring SmoothQuant migration or mixed-precision decomposition, whereas fixed-point INT8 PTQ degrades to 10.29 PPL and 76.89 F1!
2. Block-Scaled Microscaling 4-Bit Floating Point: MXFP4 vs. NVFP4
As documented in the 2026 Hugging Face Quantization Concept Guide (huggingface.co/docs/transformers/en/quantization/concept_guide#fp4-with-block-scales), next-generation Blackwell and microscaling accelerators push native hardware floating-point execution down to 4-bit FP4 (E2M1: 1 sign bit, 2 exponent bits, 1 mantissa bit). Because a 4-bit E2M1 code can represent only 8 positive/negative magnitudes (0, 0.5, 1, 1.5, 2, 3, 4, 6), FP4 formats attach hardware-decoded block scales directly inside the tensor format:
MXFP4(OCP Microscaling FP4): Groups every $32$ values with an 8-bit power-of-two scale (E8M0) and no extra tensor scale ($4 + 8/32 = \mathbf{4.25\text{ bpw}}$). Applying a power-of-two scale requires only an integer exponent addition in hardware, though scales are restricted to powers of two.NVFP4(NVIDIA Block-16 FP4): Groups every $16$ values with a finer 8-bitFP8(E4M3) scale (which can land on fractional values between powers of two) plus oneFP32global scale per tensor to keep theFP8block scales inside representable bounds ($4 + 8/16 = \mathbf{4.50\text{ bpw}}$). In production engines,NVFP4executes aW4A4matmul during compute-bound prefill and switches dynamically to aW4A16matmul during memory-bound token decoding.
3. Production Reference Implementation: Unified Python Quantization & Roofline Evaluator
The following self-contained Python 3 reference script implements the exact mathematical primitives verified across arXiv:2210.17323 (GPTQ Cholesky Hessian step), arXiv:2306.00978 (AWQ salient channel scaling error reduction), arXiv:2211.10438 (SmoothQuant $\alpha$-migration), arXiv:2305.14314 (QLoRA NF4 quantile construction and Double Quantization bit-overhead), and huggingface.co/docs/hub/en/gguf (GGUF K-Quant super-block memory planner):
#!/usr/bin/env python3
"""Reference verification suite for LLM Post-Training Quantization (PTQ) in 2026.
Implements exact mathematical formulations from:
- GPTQ (Frantar et al., ICLR 2023, arXiv:2210.17323)
- AWQ (Lin et al., MLSys 2024 Best Paper, arXiv:2306.00978)
- SmoothQuant (Xiao et al., ICML 2023, arXiv:2211.10438)
- QLoRA NF4 & Double Quantization (Dettmers et al., NeurIPS 2023, arXiv:2305.14314)
- GGUF K-Quant Super-Blocks (Hugging Face / llama.cpp specification)
"""
from dataclasses import dataclass
from statistics import NormalDist
from typing import Dict, List, Tuple
import math
@dataclass(frozen=True)
class QuantMemoryProfile:
"""Immutable memory and bandwidth profile for a quantized LLM checkpoint."""
scheme: str
bits_per_weight: float
weight_memory_gib: float
decode_tok_per_sec_1tbps: float
def compute_nf4_codebook() -> Tuple[float, ...]:
"""Compute the 16 asymmetric zero-exact 4-bit NormalFloat (NF4) quantiles (arXiv:2305.14314, Eq. 4)."""
norm = NormalDist(mu=0.0, sigma=1.0)
# 2^(k-1) = 8 negative quantiles and 2^(k-1) + 1 = 9 positive quantiles for exact 0.0
neg_q = [
0.5 * (norm.inv_cdf((i + 1) / 17.0) + norm.inv_cdf((i + 2) / 17.0))
for i in range(7)
]
neg_min = abs(neg_q[0])
neg_norm = tuple(round(v / neg_min, 6) for v in neg_q) + (0.0,)
pos_q = [
0.5 * (norm.inv_cdf((i + 9) / 18.0) + norm.inv_cdf((i + 10) / 18.0))
for i in range(8)
]
pos_max = pos_q[-1]
pos_norm = tuple(round(v / pos_max, 6) for v in pos_q)
return neg_norm + pos_norm
def double_quant_bpw(
base_bits: int = 4,
block_size_1: int = 64,
scale_bits_1: int = 8,
block_size_2: int = 256,
scale_bits_2: int = 32,
) -> Tuple[float, float]:
"""Return (single_quant_bpw, double_quant_bpw) per arXiv:2305.14314 Sec. 3."""
single_overhead = scale_bits_2 / block_size_1 # 32 / 64 = 0.500 bpw
dq_overhead = (scale_bits_1 / block_size_1) + (
scale_bits_2 / (block_size_1 * block_size_2)
) # 8/64 + 32/(64*256) = 0.126953125 bpw
return (base_bits + single_overhead, base_bits + dq_overhead)
def smoothquant_scales(
max_abs_x: List[float],
max_abs_w: List[float],
alpha: float = 0.5,
) -> List[float]:
"""Compute per-channel SmoothQuant migration factors s_j = max(|X_j|)^alpha / max(|W_j|)^(1-alpha)."""
return [
(mx ** alpha) / (mw ** (1.0 - alpha))
for mx, mw in zip(max_abs_x, max_abs_w)
]
def profile_model_quantization(
num_params_billions: float = 70.0,
bandwidth_gbps: float = 1000.0,
) -> Dict[str, QuantMemoryProfile]:
"""Compare exact memory footprint and Roofline batch-1 decode ceiling across PTQ formats."""
schemes: Dict[str, float] = {
"BF16 / FP16": 16.0,
"SmoothQuant W8A8 / FP8 E4M3": 8.0,
"GGUF Q6_K (256-superblock)": 6.5625,
"GGUF Q5_K (256-superblock)": 5.5000,
"GGUF Q4_K / NVFP4": 4.5000,
"MXFP4 / GGUF IQ4_XS": 4.2500,
"GPTQ / AWQ INT4-g128": 4.15625,
"QLoRA NF4 + DoubleQuant": 4.126953125,
"GGUF Q3_K (256-superblock)": 3.4375,
"GPTQ / AWQ INT3-g128": 3.15625,
"GGUF Q2_K (256-superblock)": 2.6250,
}
total_params = num_params_billions * 1e9
profiles: Dict[str, QuantMemoryProfile] = {}
for name, bpw in schemes.items():
total_bytes = total_params * (bpw / 8.0)
gib = total_bytes / (1024.0 ** 3)
max_tok_s = (bandwidth_gbps * 1e9) / total_bytes
profiles[name] = QuantMemoryProfile(
scheme=name,
bits_per_weight=round(bpw, 4),
weight_memory_gib=round(gib, 2),
decode_tok_per_sec_1tbps=round(max_tok_s, 1),
)
return profiles
if __name__ == "__main__":
single_bpw, dq_bpw = double_quant_bpw()
print(f"QLoRA B=64 Single-Quant: {single_bpw:.3f} bpw | Double-Quant: {dq_bpw:.3f} bpw")
for k, prof in profile_model_quantization(70.0, 1000.0).items():
print(f"{k:30} | {prof.bits_per_weight:6.4f} bpw | {prof.weight_memory_gib:6.2f} GiB | {prof.decode_tok_per_sec_1tbps:5.1f} tok/s")9. Frequently Asked Questions (FAQ) on LLM Post-Training Quantization
What is the mathematical difference between GPTQ and AWQ for 4-bit and 3-bit weight-only LLM quantization? GPTQ (arXiv:2210.17323) is an approximate second-order reconstruction method derived from Optimal Brain Quantization (OBQ). It computes the layer inverse Hessian $\mathbf{H}^{-1} = (2\mathbf{X}\mathbf{X}^\top + \lambda\mathbf{I})^{-1}$ from 128 calibration sequences using a Cholesky decomposition, quantizes weights column by column in lazy batches of $B = 128$ columns, and actively modifies the remaining unquantized weights $\boldsymbol{\delta}F = -\frac{w_q - \text{quant}(w_q)}{[\mathbf{H}_F^{-1}]{qq}}(\mathbf{H}F^{-1}){:,q}$ to compensate for rounding error. Conversely, AWQ (arXiv:2306.00978, MLSys 2024 Best Paper) never modifies weight values via regression or Hessian updates; instead, it observes that protecting the 0.1%–1% most salient weight channels—identified strictly by average input activation magnitude $\mathbf{s}{\mathbf{X}}$ rather than weight norm—eliminates most quantization error. AWQ multiplies salient weight channels by a per-channel scale $\mathbf{s} = \mathbf{s}{\mathbf{X}}^\alpha$ ($\alpha \in [0, 1]$ found via a 20-step grid search) and fuses $\text{diag}(\mathbf{s})^{-1}$ into preceding layers. Because AWQ does not solve a layer regression problem on the calibration tokens, it requires $10\times$ fewer calibration samples (16 vs. 192 sequences) and suffers $4\times\text{--}8\times$ less perplexity degradation under domain shift (0.5–0.6 vs. 2.3–4.9 PPL on PubMed/Enron cross-calibration).
Why do emergent activation outliers break standard INT8 quantization above 6.7B parameters, and how do LLM.int8() and SmoothQuant resolve them differently? As shown by Dettmers et al. (arXiv:2208.07339), once autoregressive Transformers reach 6.7 billion parameters, systematic outlier activations with magnitudes $\alpha \ge 6.0$ (up to $20\times\text{--}100\times$ larger than normal activations) emerge across 100% of Transformer layers and 75% of sequence tokens, concentrated inside just 6 to 7 hidden feature dimensions ($\approx 0.1\%$ of channels). Under per-tensor or per-token INT8 quantization, those few large columns stretch the step size $\Delta$, reducing non-outlier channels to only $2\text{--}3$ effective quantization levels. LLM.int8() resolves this at runtime by dynamically slicing out the $\approx 0.1\%$ outlier feature dimensions ($\alpha \ge 6.0$) into a separate FP16 matrix multiplication while multiplying the other $99.9\%$ of dimensions in vector-wise INT8. SmoothQuant (arXiv:2211.10438) avoids runtime mixed-precision slicing overhead by dividing activation channels by $\mathbf{s}_j = \max(|\mathbf{X}_j|)^\alpha / \max(|\mathbf{W}_j|)^{1-\alpha}$ and multiplying weight channels by $\mathbf{s}_j$ offline, migrating outlier magnitude from activations into weights so that the entire layer executes as a single pure hardware W8A8 INT8 GEMM with up to $1.56\times$ lower latency.
When should production engineers deploy W4A16 (AWQ/GPTQ) versus W8A8 (SmoothQuant / FP8 E4M3)? The choice is dictated by the hardware Roofline arithmetic intensity (FLOPs per byte of memory traffic):
- Deploy
W4A16(AWQ,GPTQ, orGGUF Q4_K_M) for on-device inference, local workstations, and low-batch interactive generation ($B \in [1, 8]$). At batch size 1 on an RTX 4090 (165 TFLOPS,1 TB/sbandwidth, ridge point $= 165\text{ FLOPs/Byte}$), token generation is severely memory-bandwidth bound ($\approx 1\text{ FLOP/Byte}$ in FP16). Compressing weights to 4 bits cuts memory reads by $4\times$, raising arithmetic intensity to $4\text{ FLOPs/Byte}$ and delivering $3.2\times\text{ to }4.5\times$ real-world decoding speedups. - Deploy
W8A8(FP8 E4M3orSmoothQuant INT8) orW4A4KV4(SpinQuant/NVFP4) for high-concurrency datacenter serving ($B \ge 32$) and long-context prefill. In large-batch regimes, matrix multiplications are compute-bound and the KV cache can exceed model weight memory by $3\times$; quantizing both weights and activations unlocks nativeFP8/INT8/FP4Tensor Core math pipelines ($2\times\text{--}4\times$ higher TFLOPS) while halving or quartering KV-cache footprint.
Why does QLoRA use 4-bit NormalFloat (NF4) and Double Quantization instead of standard INT4 or FP4? Pretrained neural network weights follow a zero-centered normal distribution $\mathcal{N}(0, \sigma^2)$. Standard INT4 spaces its 16 bins uniformly, wasting bins in the sparse tails while under-sampling the dense peak near zero. NF4 (arXiv:2305.14314) places its 16 levels at exact equal-area quantiles of the standard normal distribution $\mathcal{N}(0, 1)$ (partitioned into 8 negative and 9 positive quantiles unified at an exact discrete 0.0), ensuring every bin holds an equal expected number of weights and reducing Pile mean perplexity across 125M–13B models from 34.34 (INT4) and 31.07 (Float4 E2M1) down to 27.41 (NF4 + DQ). Double Quantization then quantizes the first-level FP32 block-64 scales into FP8 over 256-scale super-blocks, cutting scale metadata from $0.50\text{ bpw}$ to $0.127\text{ bpw}$ and enabling 65B fine-tuning inside a single 48 GB GPU.
How do GGUF K-Quants (Q4_K, Q5_K, Q6_K) differ from legacy Q4_0 and Importance Matrix (IQ) formats? Legacy Q4_0 quantizes 32-weight blocks with a 16-bit FP16 scale per block ($4 + 16/32 = 4.5\text{ bpw}$) and no minimum offset. K-Quants (huggingface.co/docs/hub/en/gguf) organize weights into 256-weight super-blocks subdivided into 8 blocks of 32 weights (Q4_K at $4.5\text{ bpw}$, Q5_K at $5.5\text{ bpw}$) or 16 blocks of 16 weights (Q6_K at $6.5625\text{ bpw}$, Q3_K at $3.4375\text{ bpw}$, Q2_K at $2.625\text{ bpw}$), quantizing sub-block scales/mins to 6 bits (or 8/4 bits) under a shared FP16 super-block scale. Importance Matrix (IQ) formats (IQ4_XS at $4.25\text{ bpw}$, IQ3_XXS at $3.06\text{ bpw}$, IQ2_XXS at $2.06\text{ bpw}$) go further below 4 bits by combining calibration activation importance weights (imatrix) with non-linear lookup tables and vector lattice codebooks.
How does SpinQuant achieve near-lossless W4A4KV4 (4-bit weight, activation, and KV cache) quantization where GPTQ and SmoothQuant fail? At 4-bit activation precision (A4), per-channel scaling (SmoothQuant) cannot suppress activation outliers without over-stretching the 16-level weight grid, while random Hadamard rotations (QuaRot) suffer up to $13\text{--}33$ points of accuracy variance across random seeds. SpinQuant (arXiv:2405.16406, ICLR 2025) parameterizes mergeable residual rotation $\mathbf{R}_1$ and head-wise attention rotation $\mathbf{R}_2$ on the orthonormal Stiefel Manifold ($\mathbf{R}^\top \mathbf{R} = \mathbf{I}$) and optimizes them directly against the quantized task loss via Cayley SGD ($\mathbf{R}' = (\mathbf{I} - \frac{\alpha}{2}\mathbf{Y})^{-1}(\mathbf{I} + \frac{\alpha}{2}\mathbf{Y})\mathbf{R}$), supplemented by two online Fast Hadamard rotations ($\mathbf{R}_3, \mathbf{R}_4$). This collapses activation kurtosis from $\kappa > 200$ to a Gaussian $\kappa \approx 3$, achieving 64.0% zero-shot accuracy (5.9 WikiText-2 PPL) at W4A4KV4 on LLaMA-2 7B—within $2.9$ points of full precision (66.9%) and $+19.1$ points ahead of LLM-QAT.
10. Primary Sources & Technical References
- Frantar, E., Ashkboos, S., Hoefler, T., & Alistarh, D. (ICLR 2023). GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers. https://arxiv.org/abs/2210.17323
- Lin, J., Tang, J., Tang, H., Yang, S., Chen, W.-M., Wang, W.-C., Xiao, G., Dang, X., Gan, C., & Han, S. (MLSys 2024 Best Paper Award). AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration. https://arxiv.org/abs/2306.00978
- Xiao, G., Lin, J., Seznec, M., Wu, H., Demouth, J., & Han, S. (ICML 2023). SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language Models. https://arxiv.org/abs/2211.10438
- Dettmers, T., Lewis, M., Belkada, Y., & Zettlemoyer, L. (NeurIPS 2022). LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale. https://arxiv.org/abs/2208.07339
- Dettmers, T., Pagnoni, A., Holtzman, A., & Zettlemoyer, L. (NeurIPS 2023). QLoRA: Efficient Finetuning of Quantized LLMs (4-Bit NormalFloat NF4 & Double Quantization). https://arxiv.org/abs/2305.14314
- Micikevicius, P., Stosic, D., Burgess, N., Cornea, M., Dubey, P., Grisenthwaite, R., Ha, S., Heinecke, A., Judd, P., Kamalu, J., Mellempudi, N., Oberman, S., Shoeybi, M., Siu, M., & Wu, H. (NVIDIA, Arm, & Intel, 2022). FP8 Formats for Deep Learning (E4M3 and E5M2 Binary Interchange Specification). https://arxiv.org/abs/2209.05433
- Tseng, A., Chee, J., Sun, Q., Kuleshov, V., & De Sa, C. (ICML 2024). QuIP#: Even Better LLM Quantization with Hadamard Incoherence and Lattice Codebooks ($E_8$ Lattice). https://arxiv.org/abs/2402.04396
- Liu, Z., Zhao, C., Fedorov, I., Soran, B., Choudhary, D., Krishnamoorthi, R., Chandra, V., Tian, Y., & Blankevoort, T. (Meta AI, ICLR 2025). SpinQuant: LLM Quantization with Learned Rotations (Stiefel Manifold Cayley SGD). https://arxiv.org/abs/2405.16406
- Hugging Face Transformers Documentation (2026). Quantization Overview: On-Load vs. Pre-Quantized Checkpoints, BitsAndBytes, GPTQ, AWQ, TorchAO, and GGUF. https://huggingface.co/docs/transformers/en/quantization/overview
- Hugging Face Transformers Documentation (2026). Quantization Concepts: Affine vs. Symmetric Mapping, Granularity, Weight-Only vs. Weight-Activation, FP8 (E4M3/E5M2), and Block-Scaled FP4 (MXFP4 & NVFP4). https://huggingface.co/docs/transformers/en/quantization/concept_guide
- Hugging Face Hub Specification (2026). GGUF Binary Format & Complete K-Quant / Importance Matrix (
Q2_K–Q8_K,IQ1_S–IQ4_XS,MXFP4) Quantization Types Reference. https://huggingface.co/docs/hub/en/gguf - Hugging Face Transformers Documentation (2026). Loading & Serving Packed GGUF Quantized Checkpoints with GGML Kernels. https://huggingface.co/docs/transformers/en/quantization/gguf