QUANT·LAB7-part interactive series
Interactive deep-dive

Sixteen bits go in.
One and a half come out.
The model still talks.

A 671-billion-parameter model that needs 720 GB of memory gets squeezed into 131 GB — and still writes working code. This series takes that apart: the arithmetic, the file format, the calibration statistics, and the exact instructions a GPU runs when it multiplies by a 4-bit number.

The whole story in one picture
one row of weights · 4 encodings
originalreconstructederrorgrid level

Start here: quantization isn't about compute

The intuitive story — "fewer bits means faster math" — is mostly wrong for LLM inference. Generating a token is not compute-limited. It's limited by how fast weights can be dragged out of memory.

To produce one token at batch size 1, the model must read every weight exactly once and do exactly two floating-point operations per weight. That ratio is fixed by the math of a matrix–vector product.

// arithmetic intensity of decoding one token, batch 1
FLOPs = 2 × P            // P = parameter count
Bytes = P × bits / 8

FP16 : 2P / 2P    = 1.0 FLOP per byte
INT4 : 2P / 0.5P  = 4.0 FLOP per byte

// an H100 sustains ~990 TFLOP/s on ~3.35 TB/s of HBM
// its ridge point is ~295 FLOP per byte
→ decoding sits ~300× into memory-bound territory

The GPU spends almost all of a decode step waiting on HBM. Halve the bytes per weight and you roughly double the token rate — without making the arithmetic any cheaper. The FLOPs were never the bottleneck.

The one-line mental model. tokens/second ≈ memory bandwidth ÷ model size in bytes. Quantization shrinks the denominator. That's the whole trick.
Memory & throughput calculator
roofline estimate · batch 1
Weights
vs BF16
Est. tok/s
Fits?
Vendor spec bandwidth; real throughput lands at 60–85% of the roofline.

There's a second win. A 70B model at BF16 is 140 GB — it doesn't fit on one GPU, so you pay for tensor-parallel communication. At 4.5 bpw it's ~39 GB and fits on a single card. You didn't just make it faster; you removed an entire class of interconnect cost. That's why quantization research is obsessed with the region between 2 and 5 bits — that's where the capacity cliffs are.

The seven chapters

CHAPTER 01
Bits, the grid, and block scaling
What a float actually stores, the affine quantization equation, and why one outlier ruins a whole tensor. Two live widgets: a float bit inspector and a quantizer you can break.
CHAPTER 02
Shaping the grid — NF4 and GGUF k-quants
Quantile quantization, double quantization, and a byte-by-byte map of a 144-byte Q4_K superblock. Plus the full format table.
CHAPTER 03
Importance matrices and codebooks
Why minimising weight error is the wrong objective, and why scalar rounding stops working below 3 bits. Includes an animated vector-quantization demo.
CHAPTER 04
Unsloth Dynamic — the case study
How DeepSeek-R1 went 720GB → 131GB, why uniform 1.58-bit scores 0%, real Gemma 3 benchmark charts, and a bit-allocation sandbox.
CHAPTER 05
Down to the metal
The GPU never multiplies by a 4-bit number. Dataflow animation, nibble unpacking, why block size is 32, and the KV-cache knock-on effect.
CHAPTER 06
GPTQ, AWQ, QAT, BitNet, QLoRA
What changes when you can afford gradients — including how QLoRA fine-tunes on top of a frozen 4-bit base.
CHAPTER 07
Which one should you download?
A decision table, rules of thumb, and the exact llama.cpp commands to reproduce any of this yourself.