liveBook · Manning

Chapter 5: Recovering Accuracy with Quantization-Aware Training

What you will learn in chapter 5 of Quantization and Fast Inference

The introduction explains when post-training quantization may need help and how quantization-aware training lets a model adapt to low precision.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains when post-training quantization may need help and how quantization-aware training lets a model adapt to low precision.

Key terms: post-training quantization, PTQ, INT8, INT4, observe and freeze, quantization-aware training, QAT, fake quantization operators, forward pass, gradients

5.1 Recognize when post-training methods fall short

This section explains that PTQ failure can be subtle, setting up the decision of when QAT may be warranted.

Key terms: PTQ, QAT, accuracy collapse, validation set

5.1.1 The accuracy cliff

This section shows how to spot a post-training quantization accuracy cliff and distinguish a damaged but useful model from one that has lost its learned signal.

Key terms: PTQ, accuracy cliff, bit-width, FP32 baseline, accuracy delta, INT4, random chance, remaining signal, QAT, BERT-base

5.1.2 Diagnostic signatures of PTQ failure

This section uses layer, per-class, and confidence diagnostics to distinguish PTQ failure patterns and choose between calibration, mixed precision, and QAT.

Key terms: layer sensitivity analysis, one-at-a-time perturbation analysis, mixed precision, diffuse failure pattern, QAT, per-class accuracy degradation, mode-collapsed model, aggregate accuracy, confidence distribution shift, maximum softmax probability

5.2 Train with fake quantization and straight-through estimators

This section explains why rounding blocks backpropagation and how fake quantization with a straight-through estimator lets training proceed while handling clipped values.

Key terms: round(), zero gradient, backpropagation, fake quantization, straight-through estimator, STE, forward pass, backward pass, clipped STE, qmin

5.2.1 Build a complete fake-quantized layer

This section shows how fake-quantized layers simulate low-bit inference during training, what QAT does to weight distributions, and how observers, STE choices, and stability safeguards support that training.

Key terms: FakeQuantizedLinear, FakeQuantizedConv2d, per-channel, symmetric, per-tensor, asymmetric, FP32, QAT, INT4 quantization grid, quantization error, weight distributions, observer

5.2.2 The QAT training loop

This section brings fake quantization and straight-through gradients into a QAT training loop and explains the fine-tuning choices that help it remain stable.

Key terms: fake quantization, STE, clipped variant, quantization grid, QAT, gradient clipping, cosine annealing, learning rate

5.3 Schedule training to minimize cost

This section explains why QAT needs a cost-conscious schedule rather than simply more training epochs.

Key terms: QAT, fine tuning, gradual transition to quantization, fake quantization, STE, memory-bandwidth-bound, epochs

5.3.1 Warm up the learning rate

This subsection explains how learning-rate scheduling, observer freezing, progressive quantization, and batch normalization folding help QAT adapt without creating an inference-time mismatch.

Key terms: warmup, cosine decay, STE, quantization grid, observers, scale factors, freeze, progressive quantization, INT8, INT4

5.3.2 Put the schedule together

This section combines bit-width changes, learning-rate scheduling, and observer freezing into a complete QAT schedule, then evaluates its training behavior against direct QAT.

Key terms: INT8, INT6, INT4, observers, quantization grid, cosine decay, batch normalization, max relative scale change, progressive quantization, cosine annealing

5.4 Use per-channel strategies for convolution and linear layers

This section explains how the scale granularity of a fake quantizer affects gradient survival during quantization-aware training.

Key terms: per-tensor fake quantization, per-channel quantization, straight-through estimator, clipping boundaries, scale

5.4.1 The gradient survival problem

Explains why per-tensor INT4 fake quantization can suppress gradients in channels with small weights and how per-channel scales preserve their ability to learn during QAT.

Key terms: per-tensor quantization, INT4, STE, clipped, gradient survival, per-channel fake quantization, per-channel scales, q_max, broadcasting, STE mask

5.4.2 Measure the training impact

This section measures when per-channel QAT improves training, explains why the benefit varies by model, and gives practical choices for scales and quantization axes.

Key terms: per-channel QAT, per-tensor QAT, gradient survival, STE masks, per-channel quantization, per-tensor, per-token, activations, abs-max calibration, per-channel scales

5.5 Adapt transformers efficiently

This section uses sublayer sensitivity profiling to choose transformer QAT strategies, shows how selective INT4 QAT recovers accuracy, and identifies components and limits that require different precision choices.

Key terms: sublayer diagnostic, output MSE, FP32 baseline, FFN, attention projections, weight quantization, INT4 PTQ, QAT, STE, attention-only

5.6 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 4: Applying Post-Training Quantization and Calibration Chapter 6: Porting Workflows Across Frameworks →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.