Intuition The one core idea
A neural network stores each of its "weights" as a very precise decimal number, but most of that precision is wasted — so we can replace every weight with the nearest value on a small ruler of evenly spaced marks and save a huge amount of memory. This deep dive builds, from absolute zero, every symbol and picture you need before that sentence makes full sense: what a weight is, what "bits" and "precision" mean, what a number line with marks looks like, and why rounding onto those marks costs almost nothing if you place the marks cleverly.
This is a prerequisites page for the Quantization topic . We assume you have seen nothing . Every symbol used up in the parent note is earned here, in order.
w
A neural network is a giant pile of numbers. Each single number is called a weight , written w (plural: a whole grid of them called a matrix W ). A 7-billion-parameter model literally means: 7 billion of these numbers w .
Picture one weight as a single dot sitting somewhere on a number line.
WHY the topic needs this: quantization does one small thing to every weight — it slides each dot onto the nearest allowed mark. If you don't picture a weight as a point on a line, none of the rounding language later will land. The whole game is: billions of dots, snap each to a nearby mark .
Intuition Why weights cluster near zero
Trained weights are mostly tiny (like 0.03 or − 0.11 ), with a few large ones. Drawn as a histogram they form a bell shape hugging 0 — see Weight Distributions in Neural Nets . This shape is why quantization works: we don't need a huge ruler, just a small one centered on 0.
A bit is one yes/no switch: it holds a 0 or a 1 . With b bits you can spell out 2 b different patterns, so 2 b different numbers.
Count the marks a ruler can have:
bits b
patterns 2 b
name
4
16
INT4
8
256
INT8
16
65 536
FP16
Intuition Picture bits as marks on a ruler
More bits = more marks packed onto the same number line = finer steps between marks = a dot can land closer to where it really wants to be. Fewer bits = fewer marks = each dot must jump further to reach one = more error. That trade — marks vs error — is the entire subject.
WHY the topic needs this: "INT8" and "INT4" are just "how many marks on the ruler." INT8 has 256 marks, INT4 only 16. When the parent says INT4 "hurts," it means 16 marks is a coarse ruler and dots must jump far.
Recall Why does INT4 use so much less memory than FP16?
FP16 spends 16 bits per weight; INT4 spends 4. Same weights, one-quarter the bits, so roughly one-quarter the file size — a 4 × shrink. ::: 4 bits vs 16 bits per number.
FP ) and integer (INT )
A float (short for floating-point , e.g. FP16) stores a number with a fractional part, like 0.0374 . An integer (INT) stores only whole numbers, like − 7 , 0 , 85 . Quantization is the act of trading floats for integers.
Intuition Why swap floats for integers at all?
Integers are cheaper to store and cheaper to move through memory, and LLM inference spends most of its time moving numbers , not computing (see Inference Optimization & KV Cache ). Fewer bytes moved → faster. So we want to represent each float weight using an integer index into a ruler . See also Mixed-Precision Training (FP16, BF16) for where FP16 comes from.
We need a rule that turns a float into an integer and back. That rule needs two ingredients, defined next: the scale and the zero-point .
s
The scale s is a single float that answers: "how many real units is one step between two neighboring integer marks?" If s = 0.007 , then going from integer 14 to integer 15 moves you 0.007 along the real number line.
Read s off the picture directly: it is the gap between marks .
s at all
Integers alone can't say "0.6 ." But integer 85 times a scale s = 0.00709 = 0.6027 . So the pair (integer, scale) reconstructs a float. The scale is the dictionary that translates integer-language back into real-value-language.
WHY divide by s to quantize? To turn a real value x into "which mark," you ask "how many steps of size s fit inside x ?" — that is division: x / s . Then you round to the nearest whole step. This is exactly why the parent's formula opens with x / s .
^ means "approximate / reconstructed"
Whenever you see x ^ or W ^ , read the little hat as "the quantized-then-unquantized version" — what you get back after rounding. Comparing x to x ^ measures the damage.
round ( ⋅ )
round sends a number to the nearest whole integer: round ( 4.67 ) = 5 , round ( − 6.5 ) → − 7 (or − 6 ; ties are a convention). It is the operation that "snaps a dot to the nearest mark."
Intuition Where does quantization error come from?
A dot at x snaps to a mark. In the worst case it sits exactly halfway between two marks, so it must move half a step , i.e. up to s /2 . That leftover distance is the quantization error . Big steps (few bits) → big possible error. This is the picture behind the parent's "error ≈ half the step."
max error = 2 s , s INT4 = 2 4 ⋅ ... s INT8 — coarser, so larger error.
WHY error jumps when you drop bits: halving the bits does not halve the marks, it square-roots the count... no — it quarters them (256 → 16 ). Each dropped bit roughly doubles s , so the error roughly doubles per bit. That non-linear jump is exactly why the parent warns INT4 needs help (GPTQ, AWQ (Activation-aware Weight Quantization) ).
z
The zero-point z is an integer that says "which mark represents the real value 0." It lets us slide the whole ruler left/right so lopsided data (e.g. values from 0 to 6 , none negative) still uses all the marks.
Intuition Symmetric vs asymmetric — cover both cases
Symmetric (z = 0 ): ruler centered on 0, marks run − 8 … 7 . Perfect for weights , whose bell curve is centered on 0.
Asymmetric (z = 0 ): ruler shifted so its left edge sits at the data's minimum. Needed for one-sided data like activations after ReLU (all ≥ 0 ), otherwise half your marks (the negatives) would sit in empty space and be wasted.
z be an integer?"
Feels right: z is just a shift, why not allow z = 4.3 ? Truth: z names a mark , and marks are integers. Forcing z to be a whole number guarantees the real value 0 maps exactly onto a mark with zero error — which matters for padding zeros and ReLU outputs.
[ q m i n , q m a x ]
Clamping means: if a computed integer falls off the end of the ruler, pin it to the last mark. For signed INT8 the ends are q m i n = − 128 , q m a x = 127 ; for signed INT4 they are − 8 and 7 .
Intuition Why clamping exists
A rare huge weight (an outlier ) could compute q = 200 , but the INT8 ruler stops at 127 . Without clamping you get overflow garbage; with clamping the outlier just parks on the last mark. The ruler is finite , so its edges must be enforced. This is the parent's "forgetting to clamp" mistake.
Intuition Why more rulers help
A single wild outlier forces a big max ∣ w ∣ , hence a big s , hence coarse marks for everyone . Give each small group its own ruler and the outlier only ruins its own tiny neighborhood. More rulers = tighter fit = less error, at the cost of storing more s values (that's the "scale overhead" in the parent's memory math).
The parent's GPTQ section quietly assumes several more symbols. Building them fully belongs to a later deep dive and to Hessian and Second-Order Methods , but here is the minimum vocabulary so nothing is unnamed.
W , inputs X , and ∥ ⋅ ∥ 2
W — the layer's grid of weights.
X — a small batch of example inputs (the calibration set , ~128 samples) fed through the layer to see how it behaves.
∥ v ∥ 2 — the Euclidean length of a list of numbers v : v 1 2 + v 2 2 + ⋯ . It measures "how big is the difference," so ∥ W X − W ^ X ∥ 2 measures how much the layer's output changed after quantizing.
H and its inverse H − 1
H = 2 X X ⊤ is a matrix of second derivatives — it records how sensitive the output error is to nudging each weight, and how weights' effects overlap . Its inverse H − 1 is the recipe for "if I round weight A wrong, how do I nudge weights B, C, … to cancel that mistake." Full story: Hessian and Second-Order Methods .
X , not just W
Naive rounding looks only at each weight in isolation. GPTQ looks at outputs W X , so it must see inputs X . That is the whole reason a calibration set exists: to measure output error, not weight error. See also LoRA and QLoRA for how quantized weights combine with trainable adapters.
weight w as a dot on a line
bits give 2 to the b marks
zero point z shifts the ruler
fewer bits means bigger error INT4 hurts
granularity per group rulers
GPTQ needs inputs X and Hessian H
Self-test: cover the right side and answer each aloud before revealing.
A weight w is one single number inside the network; picture it as a dot on a number line.
b bits can represent how many distinct values?2 b — so INT8 gives 256, INT4 gives 16.
The difference between a float and an integer a float has a fractional part (0.037 ); an integer is whole (− 7 ). Quantization trades floats for integers.
What the scale s means physically the real-value gap between two neighboring integer marks — one "step" of the ruler.
Why we divide by s when quantizing to count how many steps of size s fit in x , i.e. which mark x is nearest to.
What the hat in x ^ means the reconstructed value s ( q − z ) you get back after rounding — an approximation of x .
The maximum quantization error about s /2 , because a dot is at most half a step from the nearest mark.
Why INT4 error is much larger than INT8 16 marks vs 256 → much bigger step s → dots jump farther.
What the zero-point z does names the integer mark that stands for real value 0, letting you shift the ruler for one-sided data.
Why z must be an integer marks are integers; forcing z whole makes real 0 map exactly onto a mark.
What clamping fixes outliers that compute an integer past the ruler's ends get pinned to q m i n or q m a x , preventing overflow.
Why per-group beats per-tensor a local outlier only stretches its own small ruler, not everyone's, so most weights keep fine steps.
Why GPTQ needs inputs X it minimizes output error ∥ W X − W ^ X ∥ 2 , so it must see how the layer responds to real inputs.