Fake quantization, also called simulated quantization, is an operation that rounds floating-point values to a low-precision integer grid and immediately converts them back to floating point, so that a model experiences quantization error while it still runs in full-precision arithmetic. In Edge AI, it is the core mechanism of quantization-aware training (QAT), which prepares neural networks to run accurately as INT8 or lower-precision models on phones, microcontrollers and neural processing units.
The name reflects that no real integer arithmetic takes place during training. The tensors remain in FP32 or BF16, but their values are restricted to the levels an integer format can represent, which lets gradient-based training adapt the weights to the precision loss that real integer inference will later introduce.
How fake quantization works
A fake quantization node performs a quantize-dequantize pair, often abbreviated QDQ. Given a real value x, a scale s and a zero point z, it computes the integer q = clamp(round(x / s) + z, q_min, q_max) and then returns the dequantized value s × (q − z). The output has the same data type as the input, but only a finite set of 2^b distinct values, where b is the bit width.
The difference between the input and the output is the quantization error, consisting of rounding error for values inside the representable range and clipping error for values outside it. Choosing the range is therefore a balance: a wide range reduces clipping but makes each step coarser.
| Parameter | Role | Typical setting |
|---|---|---|
| Bit width | Number of integer levels | 8 bits, sometimes 4 or fewer |
| Scale | Step size between levels | Derived from observed range or learned |
| Zero point | Integer that represents real zero | 0 for symmetric, nonzero for asymmetric |
| Granularity | How many scales per tensor | Per-tensor or per-channel |
| Range observer | Tracks minimum and maximum | Moving average or histogram |
Fake quantization nodes are inserted wherever the deployed model will hold integers, typically on weights before each convolution or linear layer and on activations after each layer or fused block. Frameworks such as PyTorch and TensorFlow provide these nodes as built-in modules, and the resulting graph is later converted into a true integer model.
Gradients through rounding: the straight-through estimator
Rounding has a derivative of zero almost everywhere, so ordinary backpropagation through a fake quantization node would stop learning. The standard workaround is the straight-through estimator (STE), which treats the rounding step as the identity function in the backward pass.
In the common clipped variant, gradients pass through unchanged for inputs inside the quantization range and are set to zero for clipped inputs. The forward pass therefore sees the quantized values, while the backward pass behaves almost as if no quantization existed. This mismatch between forward and backward behavior is a known source of instability, especially at very low bit widths.
Methods such as learned step size quantization (LSQ) and PACT extend the idea by making the scale or clipping threshold a trainable parameter with its own gradient, allowing the network to learn the best range for each layer instead of relying only on observed statistics.
Fake quantization compared with real integer inference
Fake quantization is a training and simulation tool, not a deployment format. A model containing fake quantization nodes is no smaller or faster than the original; the savings appear only after conversion to an integer model in which weights are stored as integers and kernels execute integer arithmetic.
| Aspect | Fake quantization | Real integer inference |
|---|---|---|
| Storage type | FP32 or BF16 tensors | INT8, INT4 or similar |
| Arithmetic | Floating-point operations | Integer multiply-accumulate |
| Model size | Unchanged | Roughly 4x smaller at INT8 versus FP32 |
| Speed | Slightly slower than baseline | Faster on supporting hardware |
| Purpose | Train or evaluate under quantization | Deploy on edge devices |
Because the two paths differ in accumulation width, operator fusion and rounding modes, a small numerical mismatch often remains between the simulated accuracy and the accuracy on the target device. Reliable workflows therefore validate the converted model on the actual runtime, not only the fake-quantized graph.
Where fake quantization fits in the quantization workflow
Fake quantization appears in more than one workflow. In quantization-aware training, it stays active during fine-tuning so that weights adapt. In post-training quantization, the same QDQ nodes can be used only for calibration and accuracy estimation, without any weight updates.
| Workflow | Role of fake quantization | When to choose it |
|---|---|---|
| Post-training quantization | Simulate accuracy after calibration | Quick conversion, tolerant models |
| Quantization-aware training | Active during fine-tuning | Accuracy loss after PTQ is too high |
| Mixed-precision search | Test bit widths per layer | Tight memory or latency budget |
| QDQ model export | Mark quantization points in the graph | Runtimes that fuse QDQ into integer kernels |
A common recipe starts from a pretrained floating-point model, folds batch normalization into the preceding layers, inserts fake quantization nodes, and fine-tunes for a small fraction of the original training schedule at a reduced learning rate. Observers are usually frozen after a few epochs so that the ranges stop moving while the weights settle.
Limitations and common mistakes
- Mismatched fusion: simulating unfused layers when the runtime fuses convolution, batch normalization and activation produces misleading accuracy estimates.
- Unfrozen observers: letting ranges drift until the end of training can destabilize convergence.
- Ignoring unsupported operators: layers the target hardware cannot run in integer form fall back to floating point and erode the speedup.
- Too few calibration samples: unrepresentative data produces poor activation ranges and large clipping error.
- Assuming 8-bit results transfer to 4-bit: lower bit widths often need per-channel or group-wise scales and learned ranges.
Fake quantization also increases training cost, because each node adds computation and memory for observers. For very large language models, full quantization-aware training is often too expensive, which is why weight-only post-training methods are more common there, with fake quantization reserved for evaluation or targeted fine-tuning.
The simple explanation
Small devices such as phones run AI models faster when the numbers inside the model are rough whole numbers instead of precise decimals. Rounding, however, can make the model less accurate.
Fake quantization is a rehearsal for that rounding. During training, every number is rounded the way the device will round it, then turned back into a normal decimal. The model practices with imperfect numbers and learns to cope. It is like training for a race while wearing the same shoes you will wear on race day.
The rehearsal does not make the model smaller by itself. That happens later, when the model is converted for the device.
How it is used in practice
A team building a smart doorbell camera needs a person-detection model to run on a low-power neural accelerator that supports only INT8. After standard post-training quantization, the model loses about four points of detection accuracy, mostly on people seen at night.
The engineers insert fake quantization nodes with per-channel weight scales and fine-tune the network for three epochs on their own day and night footage, freezing the observers after the first epoch. They then convert the model to integer form and test it on the actual device, not only in the training framework.
The quantization-aware model recovers most of the lost accuracy, ending within about half a point of the floating-point original, while it runs at the frame rate and power budget the battery-powered doorbell requires.