Unit 8 · AI infrastructure · Lesson 9 of 10
Quantization, kernels and quality tradeoffs
Step 1: Learn the ideas
- Integer and low-bit floating formats: int8, int4, fp8 (concept level)
- Scale and zero point; symmetric versus asymmetric quantization
- Granularity: per-tensor, per-channel, per-group
- Post-training quantization and calibration data
- Weight-only methods: GPTQ and AWQ
- Activation outliers: LLM.int8() and SmoothQuant
- KV-cache quantization
- Kernels: dequantize-on-the-fly versus low-precision tensor-core GEMM
- Quality evaluation beyond perplexity
- When quantization does not speed things up
Why it matters
Quantization is a standard cost lever in serving: fewer bits per weight, activation or cached token means less memory to hold and less data to move. Whether it speeds anything up depends on which resource is the bottleneck and whether fast kernels exist for the format on your hardware, and it can quietly reduce quality. Interviewers listen for whether you name what is quantized, how it was calibrated, and when it will not help.
Core ideas
Mapping. Affine quantization stores q = round(x / scale) + zero_point, clamped to the integer range, and reconstructs x̂ = scale × (q − zero_point); symmetric schemes fix the zero point at 0. One scale can cover a whole tensor, one output channel, or a small group of consecutive weights; finer granularity lowers error but stores more scales. Low-bit floating formats such as fp8 keep an exponent, which suits wide value ranges, but still need scaling factors.
Weight-only quantization (for example 4- or 8-bit weights with 16-bit activations) shrinks the model and the bytes read per decode step. Kernels dequantize weights in registers and multiply in 16-bit, so arithmetic is unchanged or slightly higher. It helps bandwidth-bound regimes such as small-batch decoding and does little for compute-bound prefill or large batches.
Weight-and-activation quantization (8-bit integers or fp8 for both operands) can use low-precision tensor-core paths with higher peak throughput, which helps compute-bound work, but only on hardware and kernels that support the format.
Outliers and calibration. LLM activations contain a few channels with very large magnitudes, so a single per-tensor scale wastes most of the integer range on them. LLM.int8() keeps outlier dimensions in 16-bit and quantizes the rest; SmoothQuant rescales channels offline so activations become easier to quantize and the weights absorb the difficulty. Post-training methods use a small calibration set: GPTQ quantizes weights layer by layer and adjusts the remaining weights to compensate using approximate second-order information; AWQ uses activation statistics to protect the weight channels that matter most through per-channel scaling.
KV-cache quantization cuts bytes per cached token, raising concurrency and lowering decode bandwidth, with its own accuracy risks at long contexts.
When quantization does not speed things up: compute-bound phases with weight-only formats; formats without an optimized kernel on your GPU, which fall back to dequantizing and multiplying in 16-bit; small models where launch overhead dominates; batch sizes where dequantization costs more than the bandwidth saved; and stacks whose bottleneck is scheduling, sampling or the CPU.
Common misconceptions
- "4-bit weights make inference four times faster." The ceiling is set by bytes saved in bandwidth-bound phases and by kernel quality; compute-bound phases may not speed up at all.
- "If perplexity barely moves, quality is preserved." Perplexity can hide losses on reasoning, long-context or domain-specific tasks; evaluate on the tasks you care about.
- "int8 means integer arithmetic throughout." Weight-only int8 dequantizes and computes in 16-bit; only weight-and-activation paths use integer tensor cores.
- "Calibration data does not matter." Scales and compensation are fitted to calibration activations, so a mismatched set skews them.
How to approach it
Measure two regimes, decode at batch size 1 and a large batch or long prefill, for a 16-bit model and a quantized version on the same engine and GPU, and add a small task-quality comparison. In interviews, start from the bottleneck (bandwidth versus compute), then the format and kernel path, then the quality evaluation.
Suggested order
- 1Write affine quantize and dequantize functions and measure reconstruction error for per-tensor, per-channel and per-group scales on a real weight matrix.
- 2Read LLM.int8() for the activation-outlier analysis, then SmoothQuant for the rescaling approach.
- 3Read GPTQ and AWQ and contrast how each chooses quantized weights and what calibration data it needs.
- 4Read vLLM’s quantization documentation to see which methods are supported on which hardware.
- 5Do the quantization benchmark project at small and large batch sizes, with a small task-quality check.
Step 2: Check off what you can do
Tap each one you can genuinely do or explain. Each earns 10 XP.
Step 3: Go deeper
SmoothQuant: Accurate and Efficient Post-Training Quantization for Large Language ModelsStart here
arXivThe activation-outlier problem and the offline rescaling that enables 8-bit weights and activations.
Open(opens in a new tab)Link responded, 5 Oct 2026GPTQ: Accurate Post-Training Quantization for Generative Pre-trained TransformersStart here
arXivLayer-wise post-training weight quantization with error compensation from a calibration set.
Open(opens in a new tab)Link responded, 5 Oct 2026AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration
arXivActivation-aware protection of salient weight channels and the kernels needed for real decoding speedups.
Open(opens in a new tab)Link responded, 5 Oct 2026LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale
arXivAnalysis of emergent outlier features and mixed-precision decomposition.
Open(opens in a new tab)Link responded, 5 Oct 2026vLLM documentation
vLLM projectSection: Quantization
Which quantization methods and formats a serving engine supports on which hardware, for practical experiments.
Open(opens in a new tab)Link responded, 5 Oct 2026
Step 4: Practice
First quantize one weight matrix yourself at several granularities and plot reconstruction error. Then compare a 16-bit model with a pre-quantized or self-quantized version of the same model on one engine: decode latency at batch size 1, throughput at a large batch, prefill time for a long prompt, and accuracy on a small task set you choose. Predict each result from the bandwidth-versus-compute argument before running, and record engine and kernel versions.
- Measure when quantization helps: latency, throughput and qualityOpen(opens in a new tab)Not attemptedSelf-directed (serving engine with quantization support)
- Estimate the KV cache for a model you choose and check it against measured memoryOpen(opens in a new tab)Not attemptedSelf-directed (Hugging Face Transformers or vLLM)
Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).
Step 5: Test yourself
Answer each one out loud or on paper before you finish the lesson.
- Question 1What do the scale and zero point represent, and when is symmetric quantization enough?
- Question 2Why does finer granularity reduce error, and what does it cost?
- Question 3Why does weight-only quantization help small-batch decoding more than prefill?
- Question 4What does GPTQ do with the error introduced by quantizing one weight?
- Question 5Name three situations in which quantization brings no speedup.
You’re done when you can
- Explain weight-only versus weight-and-activation quantization in terms of memory, bandwidth, compute path and kernel support.
- Explain the activation-outlier problem and two ways to handle it.
- Predict, for a stated workload, whether quantization will reduce latency or raise throughput, and check the prediction.
- Design an evaluation for a quantized model that covers task quality and serving performance.


