Chapter 33 of 40 · ~24 min read & lab+85 XP
Chapter 33 · Generative AI

LLM Quantization: Symmetric INT8, INT4, Activation Outliers, AWQ & FP8

How Quantization shrinks a 70B LLM from 140 GB down to 35 GB and speeds up memory-bound Decode by 2×–3.2×: symmetric quantization math, why 100× activation outliers break naive INT8, AWQ salient-channel scaling, and native Hopper/Blackwell FP8.

What Is It?

LLM Quantization compresses FP16 weights (and activations) into compact INT8, FP8, or INT4 formats—using outlier-aware methods like AWQ to protect the 1% most salient channels.

Why Is It Required?

LLM decode speed is bottlenecked by moving weights from GPU HBM; 4-bit quantization cuts VRAM by 4× and speeds up token generation 2×–3× on the exact same GPU.

Everyday Analogy: Rounding a 10-decimal recipe to clean quarter-cups so you can read and cook 3× faster—while keeping exact precision on the one spicy ingredient that matters most (AWQ).
Why ML Engineers & Data Scientists Actually Need This

Quantization is how you run a 70B frontier LLM on a single GPU (or an 8B model on your laptop!) at 2×–3.2× higher tokens/sec with <0.1% quality drop!

ML / AI Engineer

Choosing FP8 (W8A8) on H100/B200 clusters (2× Prefill + 2× Decode!) vs. AWQ / GGUF INT4 (W4A16) on smaller GPUs or edge laptops is a daily production deployment decision.

Data Scientist

Understanding that KV-Cache can also be quantized to FP8 (doubling max context length and concurrent users!) unlocks huge cost savings in long-context RAG.

Interview & Debug Edge

Top inference systems question: 'Why does W4A16 INT4 speed up Decode even when weights are dequantized back to FP16 for matmul, and how does AWQ protect salient channels?'

Step 0 · Test Your Gut Before Any Math!

Why does W4A16 (4-bit weights, 16-bit activations) speed up single-user LLM Decode by ~3× even though Tensor Cores still multiply in FP16?

What You Will Master in This Chapter
  • Compute symmetric quantization & dequantization q = round(w / s), ŵ = q · s and explain group-wise scaling (group_size = 128)
  • Explain why LLMs above ~6.7B parameters develop emergent 100× Activation Outlier channels that ruin naive per-tensor quantization
  • Contrast W4A16 Weight-Only Quantization (AWQ / GPTQ) with native hardware W8A8 FP8 (E4M3 on H100/B200)
  • Explain why Weight-Only INT4 accelerates memory-bandwidth-bound Decode (~3×) even though math still executes in FP16!
Plain-English Symbol Decoder · Click Any Symbol Before We Begin
1 / 3
q=round(w/s),  s=max⁡∣w∣2b−1−1q = \text{round}(w / s), \; s = \frac{\max|w|}{2^{b-1}-1}Say aloud:“symmetric quantization”
Plain-English Meaning
Maps floating-point weights to b-bit signed integers with scale factor s
Everyday Example
INT8: [-127, 127]; INT4: [-7, 7]
Story-First Intuition, Visual Diagrams & Interactive Walkthroughs

FP16 stores every LLM weight to 4 decimal places (0.7341) — like measuring the distance to the grocery store in millimeters! Quantization rounds weights onto a clean 4-bit or 8-bit ruler. The only catch: ~1% of channels carry 100× giant activation spikes (like one skyscraper on a flat street). AWQ simply zooms in on those 1% VIP channels using a mathematical scaling trick so the 99% normal weights AND the 1% skyscrapers stay razor-sharp!

1. Symmetric Quantization Grid & Group-Wise Scaling

Everyday Story First (Zero Math Yet!)

Switch between INT4 / INT8 / INT16 in the mini-lab below to see the exact quantization rounding error on w = 0.734!

70B LLM Weight Footprint & Decode Speedup by Precision140 GB (2× H100) · 1.0× speedFP16 / BF16 (16-bit)70 GB (1× H100!) · ~1.9× speedFP8 / INT8 (8-bit)35 GB (1× 48GB GPU!) · ~3.2× speed ✓INT4 / AWQ (4-bit)
Quantization maps continuous FP16 weights onto compact INT8/INT4 grids: a 70B LLM shrinks from 140 GB (FP16) → 70 GB (FP8/INT8) → 35 GB (INT4/AWQ), speeding up memory-bound Decode by 2×–4×!

Why Group-Wise Quantization (group_size = 128) Is Essential

A single scale factor ss across an entire (4096×4096)(4096 \times 4096) matrix gets stretched by one large outlier, crushing normal weights to 0. Computing a fresh scale sgs_g for every tiny 128-weight group keeps quantization error tiny for only ~0.125 bits/weight of extra storage!

Animated Mini-Lab • 6.1

Symmetric Quantization Grid Lab (True Weight = 0.734)

Quant Int q
5
Dequantized
0.7143
Abs Error
0.0197

2. Emergent Activation Outliers & AWQ Salient Channels

Everyday Story First (Zero Math Yet!)

How does AWQ protect the 1% outlier-driven weight channels without slow mixed-precision hardware branching?

AWQ Insight: Protect the Top 1% Salient Channels Driven by Activation Outliers!100×!100×!AWQ scales salient weights UP by s (and activations DOWN by 1/s) → preserves INT4 precision with zero mixed-precision kernel slowdown!
LLM activations contain rare 100× outlier channels! AWQ (Activation-Aware Weight Quantization) protects the top 1% salient weight channels via per-channel scaling — keeping INT4 near-lossless!

The Elegant AWQ Mathematical Identity

y=W⋅x=(W⋅s)⋅(s−1⋅x)y = W \cdot x = (W \cdot s) \cdot (s^{-1} \cdot x) By multiplying the top 1% salient weight columns by s>1s > 1 before INT4 rounding (and folding s−1s^{-1} into the preceding RMSNorm layer!), AWQ slashes relative rounding error on critical channels while keeping 100% pure uniform INT4 kernels!

3. W4A16 (AWQ/GPTQ) vs. Native Hardware W8A8 FP8

Everyday Story First (Zero Math Yet!)

Choose W4A16 when VRAM & small-batch Decode dominate; choose FP8 (W8A8) on H100/Blackwell when you serve high-throughput batches!

Weight-Only INT4 (W4A16) vs. Native Hardware FP8 (W8A8 on H100/B200)W4A16 (AWQ / GPTQ)• 4× smaller VRAM (best for small-batch / edge)• Dequantizes to FP16 in SRAM for matmul• Huge Decode speedup; Prefill still FP16 speedW8A8 Native FP8 (E4M3)• 2× smaller VRAM + 2× Tensor Core TFLOPs!• Doubles BOTH Prefill AND high-batch Decode• Default serving format for frontier H100 APIs!
FP8 (E4M3 on NVIDIA H100/Blackwell) delivers native hardware Tensor Core matmuls (W8A8) — doubling BOTH Prefill FLOPs AND Decode memory bandwidth with <0.1% perplexity drift!

Production Precision Playbook

  • Edge / Single-GPU / Small Batch: INT4 AWQ / GGUF Q4_K_M (4× VRAM reduction, ~3× Decode speedup).
  • Cloud H100 / B200 High-Batch APIs: Native FP8 E4M3 (2× VRAM reduction + 2× Tensor Core FLOPs for both Prefill and large-batch Decode, plus FP8 KV-Cache!).
Walk Through With Me · Interactive Worked Example

Worked Example: Symmetric INT4 Quantization of a Weight Vector

Weights w = [0.80, -0.40, 0.15] in signed INT4 (max_int = 7).

11. Compute scale sStep 1 / 2

s=max⁡∣w∣/7=0.80/7≈0.1143s = \max|w| / 7 = 0.80 / 7 \approx \mathbf{0.1143}.

Teacher's Note: Maps the largest magnitude cleanly to ±7.
Pause & Check · Quick Intuition Pulse

On an NVIDIA H100 serving high-concurrency traffic, why is W8A8 FP8 often faster than W4A16 INT4 during long-prompt Prefill?

Try It YourselfStandard

Why does FP8 (E4M3) beat INT8 for quantizing Transformer activations on H100 GPUs?

“Wait, I'm Confused...” · Teacher Office Hours Q&A

The exact honest questions almost every beginner wonders — answered in plain English without hiding behind jargon.

PTQ (AWQ, GPTQ, FP8) quantizes an already-trained checkpoint in minutes using ~128 calibration samples. QAT simulates quantization rounding during training (e.g., 1.58-bit BitNet / INT4 QAT) for even tighter accuracy at ultra-low bit widths.

Interactive Visual Lab
Lab Challenge: Watch the 60 FPS Quantization Studio compare FP16 vs. FP8 vs. INT4 AWQ across VRAM, tokens/sec, and perplexity.
Interactive Animation • 6.1 Deep Lab

70B LLM Quantization Precision & Decode Speedup Studio

Watch a 70B model compress from FP16 → FP8 → INT4 AWQ while single-user Decode tokens/sec climbs 3.2×.

FP16 (16-bit)
Weight VRAM
140 GB
Decode Speed
24 tok/s
WikiText PPL
5.12 (base)
Baseline 2× H100 memory-bandwidth bound
0%
FP16 (16-bit)
Intuition Takeaway: Quantization slashes LLM VRAM and boosts memory-bound Decode by 2×–3.2× — AWQ protects 1% outlier channels for near-lossless INT4, while native FP8 doubles both Prefill FLOPs and Decode bandwidth on H100/B200.
Where This Powers Real ML, Deep Learning & Generative AI

Local LLMs (llama.cpp / Ollama GGUF Q4_K_M)

Runs 8B–70B models on Apple Silicon unified memory at interactive speeds.

Cloud H100/B200 FP8 Serving (vLLM / TensorRT-LLM)

Default production format for LLaMA 3 70B/405B and DeepSeek-V3 (natively trained in FP8!).

Production NumPy & PyTorch Code Patterns
import torch

# Activation-Aware Weight Quantization (AWQ) intuition: protect salient weight channels
torch.manual_seed(0)
W = torch.randn(8, 16) * 0.2
X = torch.randn(32, 16)
X[:, 3] *= 15.0  # Channel 3 has a massive activation outlier!

def quant_dequant_int4(mat: torch.Tensor) -> torch.Tensor:
    s = mat.abs().max() / 7.0
    return torch.round(mat / s).clamp(-7, 7) * s

# Naive INT4 vs AWQ channel-scaled INT4 (scale up salient W channels, divide X)
scale = (X.abs().mean(dim=0) / X.abs().mean()).pow(0.5)
err_naive = (X @ W.T - X @ quant_dequant_int4(W).T).pow(2).mean().sqrt().item()
err_awq = (X @ W.T - (X / scale) @ quant_dequant_int4(W * scale).T).pow(2).mean().sqrt().item()
print(f"Naive INT4 output RMSE: {err_naive:.4f} | AWQ-scaled RMSE: {err_awq:.4f}")
Common ML Interview Traps & Numerical Pitfalls
Trap #1: Assuming INT4 quantization always makes Prefill 4× faster.
Best Practice: W4A16 INT4 accelerates memory-bound Decode, NOT compute-bound Prefill!
Chapter Mastery Check (+85 XP)
Score: 0 / 1
1How does AWQ (Activation-Aware Weight Quantization) protect the top 1% salient weight channels during INT4 quantization?

Apply What You Learned — Solve Matching Coding Problems