AI models are usually trained with high-precision numerical formats such as FP32. That is practical on GPUs and cloud servers, but embedded hardware often has tight limits on Flash, SRAM, memory bandwidth, power, and inference latency.
Quantization reduces the precision used to represent model weights and activations. A common transformation is:
FP32 → INT8
This can make a model much smaller and more efficient while preserving acceptable accuracy.
For microcontrollers and embedded NPUs, quantization is often the difference between a model that fits only on a workstation and one that can run in production hardware.
Fundamentals and Technology Overview
What Is AI Model Quantization?
Quantization converts neural-network numbers from a high-precision representation into a lower-precision format.
Examples include:
- FP32 → FP16
- FP32 → INT8
- FP32 → INT4
- mixed-precision combinations
The objective is to reduce resource usage without reducing task accuracy beyond an acceptable level.
Why Quantization Matters for Embedded AI
Quantization can reduce:
- model storage,
- peak runtime memory,
- memory bandwidth,
- arithmetic cost,
- inference latency,
- energy per inference.
These benefits are especially important for:
- TinyML,
- AI microcontrollers,
- NPU-enabled MCUs,
- smart sensors,
- edge cameras,
- industrial condition-monitoring devices.
Simple Model Size Example
Assume a model contains 1 million parameters.
FP32
Each parameter uses 4 bytes.
Approximate weight storage:
4 MB
INT8
Each parameter uses 1 byte.
Approximate weight storage:
1 MB
That is roughly a 4× reduction in weight storage.
Actual deployed size also includes metadata, operator tables, alignment, and runtime code.
Floating Point vs Integer Representation
FP32 provides a large dynamic range and high numerical precision.
INT8 normally represents values in:
-128 to 127
or, for unsigned representation:
0 to 255
To approximate real-valued tensors, quantized models use parameters such as:
- scale,
- zero point.
A common affine relationship is:
real_value = scale × (quantized_value - zero_point)
Quantization Error
Lower precision means fewer representable values.
A floating-point value may therefore be rounded to a nearby integer-representable value.
The resulting difference is quantization error.
Some models tolerate this extremely well. Others are sensitive and may lose meaningful accuracy.
Weight Quantization
Weights are learned model parameters.
Reducing weight precision decreases:
- Flash usage,
- model-loading traffic,
- storage bandwidth.
Activation Quantization
Activations are intermediate tensors generated during inference.
Reducing activation precision decreases:
- SRAM consumption,
- accelerator bandwidth,
- runtime energy.
For small embedded systems, activation memory can be more important than model-file size.
W8A8 Quantization
W8A8 means:
- 8-bit weights,
- 8-bit activations.
This is a common embedded NPU format.
W8A16 Quantization
W8A16 means:
- 8-bit weights,
- 16-bit activations.
It can preserve accuracy better for sensitive models but increases runtime activation memory compared with W8A8.
Current ST tooling supports workflows that compare 8-bit and 16-bit activation quantization on compatible targets.
FP16
FP16 uses 16-bit floating-point values.
Compared with FP32 it can reduce:
- memory use,
- bandwidth,
- execution cost on compatible hardware.
FP16 can be useful when integer quantization damages accuracy too much.
INT4
INT4 uses only four bits per value.
It can provide very large storage savings and is increasingly important for larger edge and mobile models.
However, efficient INT4 deployment depends strongly on hardware and software support.
For MCU-class embedded AI, INT8 remains the most broadly supported starting point.
Mixed Precision
Not every layer must use the same precision.
A model may use:
- INT8 for most layers,
- FP16 for sensitive layers,
- INT4 for selected weights.
This is mixed-precision quantization.
The goal is to balance efficiency and accuracy.
Symmetric vs Asymmetric Quantization
Symmetric Quantization
Usually centers the integer range around zero.
This can simplify arithmetic on some accelerators.
Asymmetric Quantization
Uses a non-zero zero point when needed.
This can represent non-centered distributions more efficiently.
Per-Tensor Quantization
One scale is used for the entire tensor.
Advantages:
- simple,
- low metadata overhead.
Limitation:
- less precise when tensor channels have very different distributions.
Performance, Memory, and Data Processing
Per-Channel Quantization
Different channels use different scales.
This is especially useful for convolution weights and often improves accuracy.
Post-Training Quantization
Post-Training Quantization, or PTQ, converts an already trained floating-point model into lower precision.
Typical workflow:
- train FP32 model,
- provide calibration data,
- estimate tensor ranges,
- quantize weights and activations,
- validate accuracy.
PTQ is usually the first optimization to try because it does not require full retraining.
Why Calibration Data Matters
Quantization needs representative value ranges.
Calibration data helps estimate realistic activation distributions.
Poor calibration data can produce poor quantization parameters.
For industrial applications, calibration samples should represent:
- different machine loads,
- temperature variation,
- sensor noise,
- normal process variation,
- production lighting conditions for vision.
Quantization-Aware Training
Quantization-Aware Training, or QAT, simulates low-precision effects during training.
The network learns to tolerate:
- rounding,
- clipping,
- limited precision.
QAT usually requires more development effort than PTQ but can preserve accuracy better.
PTQ vs QAT
| Factor | PTQ | QAT |
|---|---|---|
| Retraining required | No | Yes |
| Development effort | Low | Higher |
| Deployment speed | Fast | Slower |
| Accuracy retention | Good for many models | Often better |
| Best use | First optimization | Accuracy-sensitive models |
Quantization and Accuracy
Never assume a quantized model is good simply because it runs.
A robust validation flow is:
- measure FP32 baseline accuracy,
- quantize,
- evaluate quantized model on representative validation data,
- compare against FP32 baseline,
- compile for target hardware,
- validate again on the target.
This distinction is important because target-side comparison against the already-quantized model can hide accuracy already lost during quantization.
Quantization and Flash
Lower-precision weights reduce model storage.
This can allow:
- larger model on the same MCU,
- smaller Flash requirement,
- more room for bootloader and firmware.
Quantization and SRAM
Activation quantization reduces runtime memory.
This is often critical because embedded AI must share SRAM with:
- RTOS stacks,
- DMA buffers,
- sensor buffers,
- communication stacks.
Quantization and Memory Bandwidth
An FP32 tensor uses 4 bytes per value.
An INT8 tensor uses 1 byte per value.
That reduces memory traffic by approximately 4× for the same element count.
Lower bandwidth can improve:
- latency,
- energy efficiency,
- cache behavior.
Quantization and Cache Efficiency
Smaller weights and activations fit more easily into:
- cache,
- local SRAM,
- NPU memory.
This can reduce expensive external-memory accesses.
Quantization and Latency
Integer kernels can execute much faster on hardware designed for them.
Modern MCU/NPU deployment tools therefore commonly optimize INT8 models for lower latency and lower power.
Quantization on Cortex-M
Cortex-M processors can accelerate INT8 neural networks using optimized libraries and architectural features such as:
- DSP instructions,
- SIMD,
- M-profile Vector Extension,
- CMSIS-NN.
Quantization on Embedded NPUs
Many embedded NPUs are optimized primarily for integer inference.
For example, the STM32N6 Neural-ART accelerator executes INT8 operations.
If a model remains partly floating point, unsupported or non-quantized portions may fall back to CPU execution.
That can reduce NPU utilization and overall speedup.
Accelerator Coverage
When benchmarking a quantized model, measure:
What percentage of compute actually runs on the accelerator?
Do not assume the entire graph runs on the NPU.
Processing Resources and Performance Tradeoffs
Operator Support
Some operators may not have native quantized kernels.
Potentially difficult areas can include:
- custom operators,
- unusual activations,
- some recurrent layers.
Unsupported layers may require:
- CPU fallback,
- model redesign,
- mixed precision.
Operator Fusion
A compiler may combine operations such as:
convolution + bias + activation
into a single optimized execution block.
This reduces:
- intermediate memory writes,
- runtime overhead.
Quantized Input Handling
The sensor pipeline must respect the input tensor's:
- data type,
- scale,
- zero point.
Do not simply cast floating-point input values into an INT8 buffer.
Incorrect input scaling can destroy model accuracy.
Quantized Output Handling
The model output may also be quantized.
Software may need to dequantize it to obtain:
- probability,
- regression value,
- physical measurement.
Model File Size Is Not Runtime Size
A small quantized model file does not guarantee low SRAM usage.
Activations can still dominate memory.
Always measure separately:
- weights,
- activations,
- tensor arena,
- preprocessing buffers.
Example: Vision Model
Suppose an FP32 vision model contains 8 MB of weights.
INT8 weight storage may fall to roughly:
2 MB
But if peak activations need:
5 MB RAM
the model still will not fit on a small MCU.
Sensitive Layers
Not every layer tolerates low precision equally.
A mixed-precision strategy can keep sensitive layers at:
- FP16,
- INT16,
- another higher precision.
Outliers
A few unusually large values can stretch the quantization range.
That can reduce resolution for the majority of values.
Advanced quantization techniques may use:
- clipping,
- per-channel scaling,
- outlier-aware methods.
Quantization for CNNs
CNNs often respond well to INT8 quantization.
This is one reason embedded vision accelerators commonly prioritize INT8.
Quantization for Recurrent Models
RNN, LSTM, and GRU models can be more sensitive because numerical errors can propagate through sequence steps.
Some deployment tools therefore support:
- W8A16,
- FP16 fallback,
- mixed precision.
Quantization for Transformers
Transformers increasingly use:
- INT8,
- INT4,
- weight-only quantization,
- mixed precision.
This is especially relevant to on-device language and multimodal models.
Weight-Only Quantization
Weight-only quantization reduces the precision of model weights while leaving activations in higher precision.
This can dramatically reduce model storage and is common in larger edge models.
Full Integer Quantization
Full integer quantization converts both:
- weights,
- activations
to integer formats.
This is particularly important for integer-only MCU/NPU accelerators.
Hardware-Aware Quantization
The best numerical format depends on the target hardware.
Examples:
MCU CPU
Often INT8.
MCU With NPU
Usually the NPU's preferred integer format.
Vector CPU
INT8 or FP16 depending on implementation.
Mobile LLM
INT8, INT4, or mixed precision.
Quantization should therefore be chosen together with the target architecture.
Applications and Practical Examples
Industrial Example: Vibration Monitoring
A small CNN may process FFT features from an accelerometer.
INT8 PTQ may reduce:
- Flash,
- inference time,
- energy.
If task accuracy remains acceptable, no QAT may be necessary.
Industrial Example: Machine Vision
A defect-detection model can be quantized for an INT8 NPU.
Calibration data should include realistic:
- lighting,
- materials,
- defect types,
- camera variation.
Industrial Example: Motor Anomaly Detection
A quantized model can analyze:
- current,
- vibration,
- acoustic signals
while leaving CPU resources available for communication and supervisory control.
Industrial Example: Smart Camera
Quantization can move a workload from an MPU-class system to a lower-power NPU-enabled MCU or SoC.
That can reduce:
- BOM cost,
- power,
- thermal requirements.
Quantization and Real-Time Scheduling
Reducing inference latency can make AI easier to schedule inside an RTOS.
But hard real-time safety and motion-control functions should still have deterministic protection from AI workload interference.
Quantization and Product Cost
A smaller and faster model may allow:
- less external memory,
- smaller MCU,
- simpler thermal design.
However, aggressive quantization also costs engineering time.
The total decision should consider:
- BOM savings,
- development effort,
- validation cost.
When PTQ Is Usually Enough
Start with PTQ when:
- model architecture quantizes well,
- representative calibration data is available,
- accuracy loss is small.
When QAT Is Better
Use QAT when:
- PTQ accuracy loss is unacceptable,
- target is integer-only,
- production accuracy is strict.
When FP16 Is Better
FP16 can be useful when:
- hardware accelerates FP16,
- INT8 damages accuracy,
- memory reduction is still valuable.
When INT4 Is Worth Considering
INT4 is attractive when:
- model size dominates,
- target hardware explicitly supports it,
- accuracy remains acceptable.
For microcontroller TinyML, INT8 is still the safer default in most cases.
Implementation, Testing, and Optimization
Common Quantization Mistakes
Mistake 1: No Representative Calibration Data
Random or unrealistic data produces unreliable quantization ranges.
Mistake 2: Comparing Only Model File Size
Also measure:
- peak SRAM,
- latency,
- energy,
- task accuracy.
Mistake 3: Ignoring Input Scale and Zero Point
Incorrect preprocessing can make a good quantized model appear broken.
Mistake 4: Assuming INT8 Is Always Faster
Speed depends on optimized hardware and kernels.
Mistake 5: Ignoring CPU Fallback
A partly supported graph can lose much of the accelerator advantage.
Mistake 6: Validating Only the Deployed Quantized Model
Compare against the original FP32 baseline first.
Practical Quantization Workflow
Step 1: Build the FP32 Baseline
Record:
- accuracy,
- model size,
- latency.
Step 2: Define the Target Hardware
Identify:
- supported precisions,
- accelerator capabilities,
- SRAM.
Step 3: Try INT8 PTQ
This is the most practical first step for MCU AI.
Step 4: Use Representative Calibration Data
Match production inputs.
Step 5: Validate Accuracy
Compare FP32 vs quantized using the real application metric.
Step 6: Analyze Target Compatibility
Check:
- operator support,
- NPU coverage,
- fallback.
Step 7: Measure Memory
Record:
- weights,
- activations,
- input/output buffers.
Step 8: Benchmark On Hardware
Measure:
- end-to-end latency,
- energy,
- CPU utilization.
Step 9: Improve if Needed
If accuracy is insufficient, try:
- QAT,
- mixed precision,
- W8A16,
- FP16.
Step 10: Validate the Complete Pipeline
Measure from:
sensor input → final decision
not only neural-network kernel time.
Quantization Selection Matrix
| Deployment Goal | Good Starting Format |
|---|---|
| TinyML MCU | INT8 |
| Integer NPU MCU | INT8 |
| Accuracy-sensitive embedded AI | QAT INT8 / mixed precision |
| FP16-capable vector target | FP16 |
| Larger mobile model | INT8 / INT4 |
| Lowest development effort | PTQ INT8 |
The Accuracy-Efficiency Trade-Off
Quantization is not a contest to use the fewest bits possible.
The right goal is:
use the lowest precision that still meets the product's accuracy, latency, memory, and reliability requirements.
Future of Quantized Embedded AI
Quantization will become increasingly important as edge systems run larger models.
Future embedded hardware will support more combinations of:
- INT8,
- INT4,
- FP16,
- mixed precision.
On-device language and multimodal AI will push advanced:
- weight-only quantization,
- low-bit arithmetic,
- hardware-aware compression.
Quantization and Physical AI
Robots and autonomous machines need substantial AI compute under strict power and thermal limits.
Quantization makes it easier to run:
- perception,
- anomaly detection,
- sensor-fusion models
closer to sensors and actuators.
That can improve:
- response time,
- energy efficiency,
- autonomy.
Conclusion
AI model quantization is one of the most important techniques for deploying machine learning on resource-constrained hardware.
It reduces numerical precision so neural networks require less:
- Flash,
- SRAM,
- bandwidth,
- compute energy.
For embedded AI, INT8 provides a strong balance between efficiency, accuracy, and hardware support.
Post-training quantization is usually the best first step.
When PTQ loses too much accuracy, developers can move to:
- quantization-aware training,
- mixed precision,
- higher-precision activations.
The central engineering principle is:
optimize quantization for both the model and the target hardware.
Do not evaluate only model size.
Measure:
- production accuracy,
- peak activation memory,
- inference latency,
- energy,
- accelerator coverage.
For resource-constrained embedded AI, good quantization is often what turns a research model into a practical industrial product.