FoundationsChecking saved investigationReading browser-local route memory before showing a continuation.

Foundation Lab

Quantization: Compressing Models to Integers

How you run 70B models on consumer GPUs: 4-bit quantization fits in 24GB VRAM

Concept 63 of 100EfficiencyPhase 6
#63QuantizationEfficiency
key equationw_q = \text{round}\left(\frac{w - w_{min}}{\Delta}\right)

Selected Foundation Object

Keep the equation fixed; move through the evidence.

Concept 63 of 100QuantizationEfficiency / Phase 6: Modern efficiency & inference
Current question

Neural nets are surprisingly robust to quantization—most precision is wasted

w_q = \text{round}\left(\frac{w - w_{min}}{\Delta}\right)
PredictionCommit before the demo.

Ask what should change when the equation is manipulated, then let the visualization test that expectation.

EvidenceCompare local witness and source.

Use the runnable panel, the key equation, and canonical papers as separate forms of evidence for the same object.

InvariantName what survives notation changes.

The useful learning product is the reusable mechanism you can carry into another model, paper, or engineering tradeoff.

Next moveContinue in the newer notebook.

This atlas page keeps the working demo; the domain notebook carries the fuller Intuition -> Math -> Code -> Demo sequence.

Why It Matters for Modern Models

  • How you run 70B models on consumer GPUs: 4-bit quantization fits in 24GB VRAM
  • GPTQ/AWQ/GGML are standard for deploying open-weight LLMs
  • INT8 inference is ~2× faster than FP16 on modern GPUs (tensor cores)

What Tutorials Skip

What is still poorly explained in textbooks and papers:

  • Neural nets are surprisingly robust to quantization—most precision is wasted
  • Outliers are the enemy: a few large activations force bad scaling for everything else
  • Quantization-aware training (QAT) is better than post-training quantization (PTQ), but expensive

Interactive Visualization

Core Math (Optional Deep Dive)

If you want intuition first, start with the key equation and the visualization. Come back here for the full walkthrough.

Key Equation
wq=round(wwminΔ)w_q = \text{round}\left(\frac{w - w_{min}}{\Delta}\right)

Map FP32 weights to INT8 (or INT4):

Uniform quantization:

wq=round(wwminΔ),Δ=wmaxwmin2b1w_q = \text{round}\left(\frac{w - w_{min}}{\Delta}\right), \quad \Delta = \frac{w_{max} - w_{min}}{2^b - 1}

Dequantization:

w^=wqΔ+wmin\hat{w} = w_q \cdot \Delta + w_{min}

Per-channel scaling (better quality):

Wq=round(W/s),si=max(Wi,:)/127W_q = \text{round}(W / s), \quad s_i = \max(|W_{i,:}|) / 127

Memory: FP32 → INT8 = 4× reduction. INT4 = 8× reduction.

Canonical Papers

GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers

Frantar et al.2023ICLR
Read paper →

LLM.int8(): 8-bit Matrix Multiplication for Transformers at Scale

Dettmers et al.2022NeurIPS
Read paper →

Connections

Next Moves

Choose the next question to carry this object forward.