liveBook · Manning

QAT decision framework

As explained in Quantization and Fast Inference

The QAT decision framework is a diagnostic process for selecting an intervention based on quantization failure mode and bit-width.

Choose an intervention by first checking whether PTQ meets accuracy requirements. If it does, deploy PTQ; if not, use bit width and layer sensitivity to guide the next step. section 5.1.2

Use this decision sequence when PTQ misses its accuracy target:

  • For INT8, revisit calibration first: failures almost always trace to calibration problems. section 5.1.2
  • For INT4, run layer sensitivity analysis. If sensitivity is concentrated in a few layers, keep those layers at INT8 and quantize the rest to INT4; if it is diffuse, use QAT. section 5.1.2
Listing 5.2 Layer sensitivity analysis
def run_layer_sensitivity_analysis(model, data_loader, device, eval_fn, bits=4):
    """Quantize one layer at a time and measure impact."""
    baseline_acc = eval_fn(model, data_loader, device)
    sensitivities = {}
 
    for name, module in model.named_modules():
        if isinstance(module, (nn.Linear, nn.Conv2d)):
            # Quantize only this layer (weights + activations)
            q_model = quantize_single_layer(model, name, bits=bits)
            acc = eval_fn(q_model, data_loader, device)
            sensitivities[name] = baseline_acc - acc  #A
 
    return sorted(sensitivities.items(), key=lambda x: x[1], reverse=True)
 

The analysis quantizes one layer at a time and measures the resulting accuracy drop, producing a ranked sensitivity list. section 5.1.2

Concentrated versus diffuse sensitivity

At INT4, one BERT layer causes a 26.4% accuracy drop when quantized alone, suggesting a target for mixed precision. ResNet-18 sensitivity is diffuse, with no single layer dominating its degradation. section 5.1.2

How Quantization and Fast Inference covers it

How deep it goes
Provides a decision sequence and sensitivity-analysis procedure, but does not detail QAT implementation.
Examples
Uses BERT's concentrated INT4 sensitivity and ResNet-18's diffuse sensitivity to distinguish mixed precision from QAT.
What it assumes
Assumes a PTQ accuracy check and bit-width identification before sensitivity-guided intervention.
What you can do after
Diagnose PTQ failures and select calibration review, mixed precision, or QAT based on bit width and sensitivity.
How it connects
Connects post-training quantization, calibration, layer sensitivity analysis, mixed precision, and quantization-aware training.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantization and Fast Inference. The section links point to the parts of the book it draws on.