Guide

A 70B model in BF16 is roughly 140 GB of weights alone (70e9 × 2 bytes). That is multiple high-end GPUs before you store a single KV entry. Cut weights to 4 bits and the same parameters fit in about 35 GB, often one GPU, with room for KV. Decode, being memory-bound, also gets faster: fewer bytes to stream from HBM per token.

The cost is numerical error. Done carelessly, you tank reasoning and long-context quality. Done carefully, loss is small enough that product prefers the cheaper token.

Why quantize

From inference arithmetic:

  • Memory capacity: smaller weights mean fewer GPUs, a larger KV budget, a higher batch.
  • Memory bandwidth (decode): weight-only INT4 or FP8 means less HBM traffic per token.
  • Compute (prefill / large batch): INT8 and FP8 Tensor Core paths can raise throughput, but only if kernels use those units.

Concepts in this section

StepConceptWhat it answers
1Formats and scalesWhich grids exist, and how do scales work?
2Weight-only vs activationsW4A16 for decode, or FP8 for Tensor Cores?
3Activation outliersWhy does naive INT8 fail on LLMs?
4GPTQ and AWQHow do you build an INT4 checkpoint?
5KV cache quantizationHow do you shrink the live cache?

Practical defaults

  • Hopper / Blackwell serving: FP8 weights, and often activations and KV, when the engine and hardware support it cleanly.
  • Memory-constrained or edge: INT4 weight-only (AWQ/GPTQ) or GGUF-style quants for on-device.
  • Always validate on your traffic. Prefer per-channel or group scales over per-tensor for INT schemes.
  • Treat "4-bit on Hugging Face hub" as untrusted until you know the method, group size and evals.

Checklist when you compress a model:

  1. Pick a format family from hardware.
  2. Compress with a known recipe. Record calibration set and seed.
  3. Confirm the runtime kernel matches the file (Marlin, Cutlass FP8, and similar).
  4. Recompute memory budgets. Freed HBM should become KV, not idle bytes.
  5. Eval: perplexity smoke test, then task suite, then long-context and reasoning. Keep a BF16 teacher.
  6. Load test TTFT, TPOT and quality under concurrency. Numerics can change early stopping.

Trade-off

One big FP8 model vs two INT4 models on one GPU. FP8 usually preserves quality better and simplifies ops. Two INT4 replicas can raise QPS if quality holds. Prefer FP8 until memory forces packing.

Common mistakes

  • Shipping on WikiText perplexity while production is tool-calling JSON.
  • Quantizing then unpacking to FP16 in the runtime. Disk shrank. The server did not get faster.
  • Mixing dtypes across tensor-parallel ranks. Quantize, then shard on the engine's supported path.

Key takeaways

  • Quantization cuts bytes to fit models and to speed memory-bound decode.
  • Compute-bound wins need real low-precision kernels.
  • W4A16 helps bandwidth. W8A8 and FP8 help Tensor Cores.
  • GPTQ and AWQ are the INT4 workhorses. Eval long-context and reasoning, not only perplexity.
  • Default to FP8 on modern NVIDIA servers. INT4 when memory or edge demands it.

Further learning

A Visual Guide to Quantization (Maarten Grootendorst)Exploring memory-efficient techniques for LLMsnewsletter.maartengrootendorst.com

AWQ · GPTQ

E07 | Fast LLM Serving with vLLM and PagedAttentionMLSys Singapore