liveBook · Manning

Uniform quantization

As explained in Transformers in Action

Uniform quantization maps values to discrete levels separated by equal-sized intervals across a numerical range.

Uniform quantization maps a numerical range into discrete levels separated by equal-sized intervals. Its regular structure simplifies hardware implementation and can reduce computational and energy costs. section 8.3.3

Quantization choices involve distinct trade-offs:

  • Nonuniform quantization varies interval sizes to match data distributions and potentially reduce quantization error. section 8.3.3
  • Quantization-aware training retrains with quantized weights and activations, while posttraining quantization applies quantization without further training. section 8.3.3
Table 8.1 Comparison of data types
Data type
Bit width
Range
Memory reduction from FP32
float32
32 bits
≈ ± 3.4 × 10^{38}
–
float16
16 bits
≈ ± 6.5 × 10^{4}
50%
int8
8 bits
-128 to 127
75%
int4
4 bits
-8 to 7
87.5%

Compare float32, float16, int8, and int4 bit widths, numerical ranges, and memory reductions when assessing quantization choices. section 8.3.3

How Transformers in Action covers it

How deep it goes
Defines equal-sized intervals and compares alternatives, but does not detail interval calculation or quantization error formulas.
Examples
Uses float32, float16, int8, and int4 comparisons plus a bitsandbytes Falcon 7B loading configuration.
What you can do after
Evaluate quantization variants by interval structure, memory reduction, implementation efficiency, and expected accuracy trade-offs.
How it connects
Connects quantization with nonuniform quantization, quantization-aware training, posttraining quantization, and numerical data types.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Transformers in Action. The section links point to the parts of the book it draws on.