liveBook · Manning

Quantization-aware training

As explained in Transformers in Action

Quantization-aware training retrains a model while simulating or applying quantized weights and activations so the model adapts to quantization effects.

Quantization-aware training retrains a model with quantized weights and activations, allowing it to adapt to quantization-induced changes and retain performance at very low precision. section 8.3.3

Use quantization-aware training when:

  • Targeting extremely low precision, including 2-bit quantization, while preserving model performance. section 8.3.3
  • Accepting additional training cost in exchange for adaptation to quantization effects. section 8.3.3
  • Choosing it over posttraining quantization, which requires no further training but typically remains limited to 8-bit or 6-bit precision. 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 bit widths, numeric ranges, and memory reductions for common lower-precision data types. section 8.3.3

How Transformers in Action covers it

How deep it goes
Defines retraining with quantized weights and activations, notes computational cost, and stops short of implementation procedure.
Examples
Uses 2-bit quantization as a low-precision target and compares float32, float16, int8, and int4 formats.
What it assumes
Assumes familiarity with quantization and lower-precision numeric formats.
What you can do after
Evaluate the training-cost and precision trade-off between quantization-aware and posttraining quantization.
How it connects
Connects quantization with uniform quantization, nonuniform quantization, posttraining quantization, and QLoRA.

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.