Unit 1 of 12 · about 4 hours · explain, derive

Inference number formats and what gets quantized

Precision sets the memory floor for every later decision. A plan that confuses nominal bits with served bytes mispredicts capacity by gigabytes.

You'll be able to

  • Explain how INT8, INT4, FP8 and microscaled FP4 trade dynamic range against storage, and where each sits in a serving path.
  • Derive weight memory for a dense model under FP16, INT8 and INT4, and state which tensors the count covers.
  • Distinguish weight-only, weight-activation and KV quantization by what gets smaller, what gets faster and what still needs high precision.

Covers

Integer and floating-point inference formatsWeight-only, weight-activation and KV quantization
1

Read

In this order, only the parts listed

0 of 3 done

  1. Quantization: formats and where they helpHands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)

    Chapter 6, Model Compression: Quantization (printed pp. 206 to 213): Storing numbers with Table 6-1, How does quantization help in model serving with Table 6-2, and Weight-only versus weight-and-activation quantization strategies with the Marlin and Machete kernels

    Skip the hands-on quantization commands and the Qwen walkthrough here; they belong to the measurement unit. Table 6-2 lists the H100 SXM Tensor Core peaks with sparsity (dense rates are half), and its line that 4-bit weights double FLOPS again does not hold for weight-only formats, which compute in 16-bit.

  2. Number formats, range and granularityInference Engineering - Section 5.1, Quantization

    Section 5.1.1, Number Formats: the format table with first architecture, then Precision, Type and Scale factor, then Dynamic range and Granularity

  3. Day 13: number formats from scratch100 Days of LLM Inference - Days 13, 14 and 15

    Notebook day13/quantization-number-formats.ipynb: Part 1 Quantization Math (scale and zero point), Part 2 Memory Savings and Throughput Impact, Part 3 FP8, Part 4 NVFP4

2

Focus on

  • INT formats spread levels evenly while FP formats spend bits on exponent range. Activations with outliers therefore usually lose less in FP8 E4M3 than in INT8 under one per-tensor scale.
  • W4A16 means 4-bit weights with 16-bit activations. Weight-only quantization shrinks storage and weight traffic but still computes in high precision after dequantization.
  • Weight-activation quantization can raise compute throughput, but only where a kernel for the exact pair exists on your GPU. A format without kernel support is storage only.
  • KV quantization targets capacity and decode traffic, not prefill FLOPs. Without a quantized attention kernel the values are dequantized back before the dot product.
Common mistakes · 3
  • Reading H100 FP8 throughput as a portable speedup. FP8 Tensor Cores need compute capability 8.9 or higher (Ada, Hopper and later); on Ampere, vLLM runs FP8 checkpoints as weight-only Marlin, so the W8A8 speedup does not exist there.
  • Counting 4 bits per weight. Group scales, zero points and alignment push the served rate above nominal; NVFP4 lands near 4.5 effective bits per weight (an 8-bit scale per 16 values) before its per-tensor global scale.
  • Expecting KV quantization to cut prefill time. It cuts capacity and decode traffic; a latency win needs a quantized attention kernel alongside it.
3

Try it yourself

Closed-book, before checking anything

Closed-book, derive that a 7B-parameter model needs 14 GB in FP16, 7 GB in INT8 and 3.5 GB in INT4 for weights alone, then name the two costs the nominal count omits: per-group scales with zero points, and the KV cache.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.A 7B model needs 14 GB for weights in FP16. What do INT8 and INT4 need, and what is missing from both numbers?Answer

    7 GB and 3.5 GB. Both omit scale and zero-point storage, alignment padding, and the KV cache and activations.

  2. 2.Why does FP8 E4M3 suit spiky activations better than INT8 at the same width?Answer

    Its exponent bits give wide dynamic range for outlier magnitudes. INT8 spreads levels evenly, so one scale either saturates on the outlier or crushes small values.

  3. 3.A weight-only INT4 model shows slower first-token latency than the FP16 baseline at high concurrency. What mechanism explains it?Answer

    Weights are dequantized to 16-bit before compute, so prefill arithmetic does not shrink while dequantization overhead is added. Weight-only quantization buys memory and decode bandwidth, not compute.

  4. 4.The KV cache is quantized but attention still runs in FP16. What happens each step?Answer

    Values are dequantized back before the dot product. Capacity falls but arithmetic cost does not; keep this separate from a quantized-attention speedup.

5

Practice

  • 100 Days of LLM Inference Day 13: number-format experiments

    Try These Experiments in day13/quantization-number-formats.ipynb: run the FP8, INT8, INT4 and NVFP4 cells and record error per format with the memory model from Reproduce

    Treat the notebook numbers as implementation checks on tiny tensors, not as serving evidence.

You're done when

You derive the three weight-memory numbers without notes and can say for each of W4A16, W8A8 and FP8 KV which traffic shrinks and which kernel the speedup needs.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 10 more in the section
  • Hands-On LLM Serving and Optimization - Quantization (Chapter 6) and Speculative Decoding (Chapter 7)Chi Wang and Peiheng Hu (O'Reilly) · primary

    Read "Model Compression" in Chapter 6 for quantization and "Speculative Decoding" in Chapter 7, with its hands-on example. For each method write its correctness contract, the engine support it needs and a predicted winning and losing workload before running it.

  • 100 Days of LLM Inference - Days 13, 14 and 15Elizabeth Thomas · support

    Use the numeric-format, quantization-algorithm and speculative-decoding notebooks as compact preparation. Keep their synthetic demos separate from production-engine and hardware evidence.

  • Inference Engineering - Section 5.1, QuantizationPhilip Kiely (Baseten Books) · support

    Read 5.1.1 Number Formats for the format table and Precision/Type/Scale-factor with Dynamic range/Granularity, 5.1.2 for PTQ versus QAT and the what-to-quantize decisions, and 5.1.3 for the perplexity, benchmark and custom-eval quality checks.

Also in this section