Skip to content
fn

get_default_qat_qconfig

→QConfig
get_default_qat_qconfig()

Return the standard quantization-aware-training recipe.

The QAT analogue of get_default_qconfig: it uses the same grid geometry for activations and weights, but wraps each observer in a lucid.quantization.FakeQuantize module. During training that wrapper both refreshes (scale, zero_point) from live statistics and applies straight-through fake-quantization, so the training graph experiences the exact rounding / clamping of int8 inference while gradients keep flowing. Fine-tuning under that simulated error lets the weights adapt to it, recovering accuracy that plain PTQ leaves on the table for aggressive (low-bit or quantization-sensitive) models.

  • Activations — a per-tensor-affine quint8 fake-quant driven by a MovingAverageMinMaxObserver. The moving average smooths the per-batch range so the simulated grid does not jitter from step to step during training.
  • Weights — a per-channel-symmetric qint8 fake-quant on ch_axis=0, matching the eventual inference-time weight quantization exactly.

Returns

QConfig

A recipe whose two factories build lucid.quantization.FakeQuantize modules (rather than bare observers) for activations and weights.

Notes

  • Install it with lucid.quantization.prepare_qat, not lucid.quantization.prepare; after training, lucid.quantization.convert folds the fake-quant statistics into a genuinely quantized model.
  • The standard QAT schedule toggles the two FakeQuantize switches over time — observe + fake-quant early, then freeze the observer (and BN stats) as training converges — via lucid.quantization.FakeQuantize.disable_observer, etc.
  • Activations use a moving-average min/max here rather than a histogram: the range is re-estimated every step, so a cheap running statistic is both sufficient and more stable than a per-step histogram.

Examples

>>> import lucid.quantization as Q
>>> qat = Q.get_default_qat_qconfig()
>>> type(qat.activation()).__name__
'FakeQuantize'
>>> type(qat.weight()).__name__
'FakeQuantize'

See Also

  • get_default_qconfig—The static-PTQ counterpart (bare observers, no fake-quant).
  • get_default_qat_qconfig_mapping—Installs this recipe as a model-wide mapping.
  • lucid.quantization.FakeQuantize—The wrapper both factories build.

Used by 1