Skip to content

Training, adaptation, compression, and systems techniques · Training, fine-tuning, adaptation, compression, and systems techniques · TRN020 · Training method

Quantization-aware training

Trains or fine-tunes with simulated quantization so weights can adapt to deployment precision constraints.

Explained here Component demo, not a trained model CodeSplash's run and the reference's record

In CodeSplash

Documented in the Academy only. There's no Set up button.

Availability
Explained here
Code example
Component demo, not a trained model
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

Trains or fine-tunes with simulated quantization so weights can adapt to deployment precision constraints.

Question / hypotheses

Does this intervention improve the intended quality, adaptation, resource, or reliability objective under a controlled comparison? It defines a method, not an intrinsic null-hypothesis test.

Architecture / computational structure

Fake-quantization operators emulate clipping and rounding in the forward pass; surrogate gradients permit optimization.

Assumptions

The simulated quantizer must match the deployment backend’s range, granularity, and operators. Rounding is nondifferentiable, so the backward rule is an approximation.

Formula / computational definition

x^=s[clip⁡(round⁡(x/s)+z,qmin,qmax)−z].\hat x=s[\operatorname{clip}(\operatorname{round}(x/s)+z,q_{min},q_{max})-z].

Parameters and notation

Learned: model weights and optionally quantizer scales. Hyperparameters: bit width, per-channel/group granularity, observers, clipping, zero point z, scale s, straight-through rule.

Fitting, fine-tuning, and adaptation

Begin from a stable checkpoint, calibrate observers, then fine-tune with small learning rates and a staged observer-freezing policy. Export and evaluate the actual quantized model, not only fake quantization.

How to use and calibrate

Compare task quality, saturation, latency, and integer output parity. Example: compress a mobile vision or audio model.

Example application

compress a mobile vision or audio model.

Interpretation / pitfalls

Watch out

Training-time fake-quant accuracy can differ from the exported graph. Unsupported operations may fall back to floating point and erase speed gains.

Python and R code examples

Scope: numerical mechanism demonstration. Validation: Python executed successfully on the supplied synthetic inputs; R reviewed but not executed (Rscript unavailable).

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Component demo, not a trained model — numerical mechanism demonstration. · needs numpy

import numpy as np
x=np.array([-.7,-.1,.2,.9]); scale=.1; zero=0
q=np.clip(np.round(x/scale)+zero,-8,7); print(scale*(q-zero))
R

Component demo, not a trained model — numerical mechanism demonstration.

x <- c(-.7,-.1,.2,.9); scale <- .1; zero <- 0
q <- pmax(-8,pmin(7,round(x/scale)+zero)); print(scale*(q-zero))

Sources

From the CodeSplash reference, entry TRN020.