SysDesignAtlas

Quantization & Numeric Formats

Why FP32 was always overkill, what BF16, FP8 and INT4 actually change, and why halving the bits nearly halves your latency as well as your memory.

CoreMedium12 min readaiquantizationprecisionmemory
Confidence

#Why precision is an infrastructure decision

Quantization means storing each of the model's numbers in fewer bits — 8 instead of 16, or even 4 — accepting a little imprecision in exchange for a much smaller model. The names below are just bit widths: FP32 is 32 bits per number, BF16 is 16, INT4 is 4.

Why that's an infrastructure decision rather than a research one comes straight from inference arithmetic: the time to produce a token is the bytes of weights you must read divided by memory bandwidth. Halve the bytes, halve the time.

   70B model, 3 TB/s memory bandwidth, single GPU:

     FP32  280 GB  → doesn't fit; needs 4 GPUs
     BF16  140 GB  → needs 2 GPUs;   47 ms/token if it fit on one
     FP8    70 GB  → fits one 80 GB GPU (barely);  23 ms/token
     INT4   35 GB  → fits comfortably;             12 ms/token

   → Quantization changes how many GPUs you need, how fast you
     decode, and how much KV cache fits. Three wins from one knob.

That third win is easy to miss. Smaller weights leave more memory for KV cache, which raises concurrency, which raises the batch size, which raises arithmetic intensity, which raises throughput. The effects compound.

#The formats

   FP32   [S][ 8 exponent ][      23 mantissa      ]   4 bytes
   FP16   [S][5 exp][  10 mantissa  ]                  2 bytes
   BF16   [S][ 8 exponent ][7 mant]                    2 bytes
   FP8-E4M3 [S][4ex][3m]                               1 byte
   FP8-E5M2 [S][ 5ex ][2]                              1 byte
   INT8   [        8-bit integer      ]                1 byte
   INT4   [ 4-bit ]                                    0.5 byte

A floating-point number is stored in three parts: a sign (S), an exponent that sets how big or small the number can be (its range), and a mantissa that holds the significant digits (its precision). More exponent bits reach bigger and tinier numbers; more mantissa bits make the steps between representable values finer. Integer formats (INT8, INT4) have neither — they store whole numbers, plus a separate scale factor that maps them back to real values (e.g. stored 7 × scale 0.02 = 0.14).

FormatBytesRangePrecisionWhere used
FP324HugeHighLegacy; optimizer states
BF162Same as FP32Low (7-bit mantissa)Default for training
FP162NarrowBetter than BF16Older training; overflow-prone
FP8 (E4M3)1ModerateCoarseModern inference; some training
INT81Fixed-point, needs scaleCoarseMature inference quantization
INT40.5Very coarse, needs group scalesVery coarseMemory-constrained inference

#What actually gets quantized

Three separate things, with different sensitivities:

Weights static, quantize offline, biggest memory win KV cache grows with every token — FP8 here doubles concurrency Activations dynamic, outlier-prone, hardest to quantize Compute separate question: what precision do the tensor cores use?
Weights quantize easily. Activations don't. KV cache is in between and is often the best target.

Weight-only quantization is the common starting point: store weights at INT4, convert them back to BF16 on the fly inside the GPU code (the kernel) that does the multiply, and compute in BF16. You get the full memory and bandwidth win — which is what decode is limited by — without needing low-precision arithmetic to be accurate. For decode this is nearly ideal.

Weight-and-activation quantization also quantizes the activations — the intermediate values computed as each input flows through the network, which are different for every request. Then the matrix multiplies themselves run at low precision, which speeds up compute-bound work too, i.e. prefill and training. Harder, because activations have outliers.

#The outlier problem

Quantizing means mapping a range of floats onto a small set of levels. If one value in a tensor is 100× larger than the rest, the scale must accommodate it, and everything else collapses into a few levels.

   Typical activation values:  [-2.1, 0.4, 1.8, -0.9, 143.0, 0.2, ...]
                                                     ↑ outlier

   INT8 scale must cover ±143  →  step size ≈ 1.1
   → the values near ±1 quantize to 0, ±1, or ±2
   → almost all information destroyed

Transformer activations reliably develop these outliers. A small number of dimensions (positions in the activation vector, called channels) carry very large values, and it's the same few channels on almost every token. This is why naive INT8 activation quantization badly damages large models while working fine on small ones.

Three families of fix:

  • Mixed precision (LLM.int8()). Detect outlier dimensions and keep them in FP16; quantize the rest to INT8. Accurate, but slow, because the GPU must run two kinds of multiply and stitch the results together.
  • Smoothing (SmoothQuant). Move the difficulty from activations to weights by scaling channels: divide the activation channel by s and multiply the matching weight column by s. The product is unchanged — (x ÷ s) × (w × s) = x × w — but the activation's outlier shrinks, and weights are much easier to quantize.
  • Rotation (QuaRot, SpinQuant). Multiply by a rotation matrix before quantizing. It smears one huge value across many dimensions as moderate values, and the weights are rotated the opposite way so the result is unchanged. Removes outliers rather than working around them.

#Calibration-based methods

For aggressive weight quantization (INT4 and below), the good methods use a small calibration dataset — a few hundred samples — to decide how to round.

MethodIdea
Round-to-nearestThe naive baseline. Fine at INT8, poor at INT4
GPTQQuantize column by column, adjusting remaining weights to compensate for the error just introduced
AWQIdentify the ~1% of weight channels that matter most (by activation magnitude) and protect them with per-channel scaling
QATFine-tune with quantization simulated in the forward pass, so the model learns weights that survive it

Group-wise scales are the other essential ingredient: instead of one scale per tensor, use one per group of 64 or 128 weights. The scale metadata costs a few percent of the memory saved and dramatically improves accuracy, because an outlier now only stretches the scale for its own group of 128 weights, not for the whole tensor.

#FP4 and microscaling: group scales in hardware

The newest accelerators (NVIDIA Blackwell, 2025) build the group-scale idea into the tensor cores (the GPU's dedicated matrix-multiply units). Block-scaled FP4 stores each number in 4 bits — E2M1, meaning 2 exponent bits and 1 mantissa bit, only 16 possible values — and shares one scale across a small block:

   MXFP4 (OCP standard)   32 values per block
                          scale = a power of two (8 bits)
   NVFP4 (NVIDIA)         16 values per block
                          scale = FP8 (E4M3), plus one FP32 scale
                          per tensor

   NVFP4 cost:  (16 × 4 + 8) / 16  =  4.5 bits per value

Smaller blocks and a finer-grained scale make NVFP4 noticeably more accurate than MXFP4 at almost the same size. Because the hardware multiplies in FP4 directly, it speeds up compute-bound prefill as well — not only memory-bound decode, which is all that weight-only INT4 helps. Open-weight models now ship this way: OpenAI's gpt-oss (2025) stores its expert weights in MXFP4, which lets a ~120B-parameter model fit on one 80 GB GPU. Treat FP4 like INT4 for quality: measure on your task, and keep sensitive layers at higher precision.

#Quality: what you actually lose

Rough guidance, with the strong caveat that it varies by model and task:

PrecisionTypical quality impact
BF16Reference; indistinguishable from FP32
FP8Very small; commonly deployed with no measurable regression
INT8 (with SmoothQuant or similar)Small
INT4 (GPTQ/AWQ, group 128)Noticeable on hard reasoning; often fine for chat
INT3 and belowSubstantial degradation

#Deployment shape

A reasonable default for a serving deployment today:

  1. Weights at FP8 — near-zero quality cost, halves memory and decode latency versus BF16, hardware-supported on current accelerators.
  2. KV cache at FP8 — roughly doubles concurrency; tends to matter more than the weight saving once you're serving many users.
  3. Compute at FP8 for prefill where the hardware supports it, while keeping the running sums of each multiply (the accumulation) in BF16 so rounding errors don't pile up.
  4. INT4 or FP4 weights (NVFP4 where the hardware supports it) when you are memory-constrained and have measured that your task tolerates it.
  5. Keep sensitive layers higher precision — the embedding, the unembedding, and often the first and last transformer blocks. They're a small fraction of parameters and disproportionately sensitive.

#Check yourself

What three wins does quantization give?Show answer
Fewer GPUs to hold the model, faster decode (time ∝ bytes read), and more memory for KV cache — which raises concurrency, batch size and throughput.
Why did BF16 beat FP16 for training?Show answer
BF16 keeps FP32's 8-bit exponent (range) and gives up mantissa (precision). Gradients span many magnitudes; FP16 overflows or underflows and needs loss scaling, while noise from lost precision is harmless.
What gets quantized, and which is hardest?Show answer
Weights (static, easy, biggest win), KV cache (FP8 roughly doubles concurrency) and activations (dynamic and outlier-prone — the hard part).
What is the outlier problem, and its three fixes?Show answer
A few activation channels carry huge values, so one scale must cover them and the rest collapse into a few levels. Fixes: keep outliers in FP16 (LLM.int8()), migrate scale to weights (SmoothQuant), or rotate to spread them (QuaRot, SpinQuant).
What do GPTQ, AWQ and group scales do?Show answer
GPTQ compensates remaining weights for each column's rounding error; AWQ protects the ~1% of channels with large activations; one scale per 64–128 weights localises range. INT4 really costs ~4.25 bits per weight.
What are MXFP4 and NVFP4?Show answer
Block-scaled 4-bit floats handled in hardware: MXFP4 shares a power-of-two scale across 32 values; NVFP4 an FP8 scale across 16 (~4.5 bits per value), more accurate and fast for prefill too.
Why is perplexity a poor quantization check?Show answer
It's dominated by easy, confident tokens that noise doesn't affect, while multi-step reasoning, code and structured output degrade first. Evaluate on your task.
What is a sensible default serving configuration?Show answer
FP8 weights and FP8 KV cache, FP8 compute for prefill where supported, INT4/FP4 only when memory-bound and measured, and sensitive layers (embeddings, first and last blocks) kept at higher precision.

#What to carry forward

  • Halving bits nearly halves decode latency, because decode is bandwidth-bound. Memory, latency, and concurrency all improve together.
  • BF16 beat FP16 on range, not precision — networks need range far more.
  • Weights quantize easily; activations have outliers. Smoothing or rotation is how you handle them.
  • Group-wise scales are what make INT4 viable; the real cost is ~4.25 bits/weight, not 4.
  • Perplexity hides quantization damage. Evaluate on your task.
  • Largest model that fits after quantization beats smaller model at full precision.
00:00
/ 12m