PTQ versus QAT for model quantization
quantization workflows.
PTQ quantizes a trained model with calibration data, fast but may lose accuracy; QAT simulates quantization in training so weights adapt.
thinking QAT needs no data or PTQ is always lossless.
What's really being asked
The interviewer checks practical knowledge of model optimization trade-offs between development cost and accuracy preservation.
The full answer
Ptq
start from a fully trained FP32 model and convert weights and activations to INT8 after the fact. It uses a small representative calibration dataset to estimate the dynamic ranges needed to pick scale and zero-point parameters. It is fast, needs no labels or backprop, and is easy to deploy, but quantization error can noticeably degrade accuracy for sensitive layers or networks with large activation outliers. QAT: insert fake-quantization operations into the graph that simulate INT8 rounding during forward passes while keeping gradients flowing, then train or fine-tune. The model thus learns weights that tolerate quantization, usually recovering most accuracy. It costs extra training time and data and a more complex pipeline. Decision: try PTQ first because it is cheap; if the accuracy loss exceeds your budget, especially for compact or low-bit models, move to QAT.
The mistakes people make
Saying PTQ is always lossless, ignoring that some models degrade. Or claiming QAT requires no data or training, when it specifically needs a training loop. Or conflating dynamic-range PTQ with full integer quantization.
What usually comes next
What does calibration estimate and why does it need representative data. Why do activation outliers hurt PTQ. How does the straight-through estimator let gradients flow through fake-quant ops. How do per-channel scales help.
A concrete example
You PTQ a MobileNet for a phone using a few hundred representative images for calibration, but accuracy drops several points, too much for the product, largely because compact models have little redundancy and some layers have wide activation outliers. You switch to QAT, inserting fake-quantization ops and fine-tuning for a few epochs so the weights learn to tolerate INT8 rounding, with the straight-through estimator letting gradients flow. Accuracy recovers to within a fraction of a point of FP32 while you keep the INT8 speedup and the smaller model size. Per-channel weight scales further reduce the loss compared with a single per-tensor scale.
Interview question
When is quantization-aware training the better choice over post-training quantization?
- a.When you have no training data or compute at all
- b.When you want the fastest possible conversion with no fine-tuning
- c.When PTQ's accuracy loss exceeds the acceptable budgetCorrect
- d.When the model is already INT8 and needs no change
Why? this is the answer
QAT is worth its extra cost when PTQ degrades accuracy too much, since training lets weights adapt to quantization. QAT specifically requires data and compute, so the no-data and fastest-conversion options describe PTQ.
Just read this? Test yourself on what you have been reading.
Read the original → tensorflow.org
- #quantization
- #ptq
- #qat
- #int8
- #inference-optimization
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles