Per-tensor quantization is a quantization scheme in which all values of a tensor share a single scale factor and, in the asymmetric case, a single zero point when they are converted from floating point to low-bit integers such as INT8. In Edge AI, it is the simplest and most hardware-friendly granularity, because one set of parameters covers an entire weight matrix or activation tensor.
The scheme contrasts with finer granularities such as per-channel and group-wise quantization, which assign separate parameters to smaller slices. Per-tensor quantization keeps metadata and integer arithmetic minimal, but it is sensitive to outliers, since one extreme value stretches the range for every other element.
How per-tensor quantization maps values to integers
Per-tensor quantization works by finding one range for the whole tensor, deriving a scale from that range, and rounding every element onto the integer grid. With an affine mapping, the quantized value is q = round(x / s) + z, clipped to the integer limits, and the dequantized value is x’ = s (q – z).
In symmetric per-tensor quantization, the zero point is fixed at 0 and the scale is the maximum absolute value divided by 127 for signed INT8. In asymmetric quantization, the scale is the range from minimum to maximum divided by 255 and the zero point shifts the grid so that real zero is represented exactly.
The table below lists the parameters involved and their typical values.
| Parameter | Symmetric case | Asymmetric case | What it affects |
|---|---|---|---|
| Scale (s) | max absolute value / 127 | (max – min) / 255 | Step size and rounding error |
| Zero point (z) | Fixed at 0 | Integer from 0 to 255 | Exact representation of zero |
| Integer range | -127 to 127 | 0 to 255 | Number of usable levels |
| Parameters stored | One float | One float and one integer | Metadata overhead |
Because the scale is shared, the rounding error is the same absolute size for every element, at most half of one step. Elements far smaller than the largest value therefore suffer larger relative error.
Per-tensor quantization compared with finer granularities
Granularity describes how many values share one set of quantization parameters. Per-tensor is the coarsest common option, and each finer level trades extra metadata and kernel complexity for lower quantization error.
| Granularity | Values sharing one scale | Accuracy | Hardware cost |
|---|---|---|---|
| Per-tensor | Entire tensor | Lowest of the group | Minimal, widely supported |
| Per-channel | One output channel | Higher for weights | Low, supported by most runtimes |
| Group-wise | Blocks of 32-128 values | High at 4 bits | More metadata, custom kernels |
| Per-token | One activation row | High for outlier activations | Runtime scale computation |
In practice, many edge runtimes use per-channel scales for weights and per-tensor scales for activations. Activation scales must often be applied inside fused integer kernels, and a single activation scale keeps the requantization step after each matrix multiplication simple.
Why edge hardware favors per-tensor scales
Per-tensor quantization suits integer-only accelerators found in microcontrollers, mobile NPUs and digital signal processors. When the input and weights each have one scale, the integer accumulator can be rescaled to the output with one fixed-point multiplier and one shift, which many accelerators implement directly in hardware.
- Simpler kernels: no per-element or per-channel scale lookup in the inner loop.
- Lower memory traffic: metadata is a few bytes per tensor instead of per channel or group.
- Broad delegate support: older NPUs and DSP delegates sometimes accept only per-tensor parameters.
- Easier operator fusion: element-wise additions and concatenations work best when inputs share a scale.
For operations such as residual additions and concatenation, matching per-tensor scales across inputs avoids extra rescaling. Converters therefore often force shared scales on the inputs of these operators during calibration.
Calibrating the range
The quality of per-tensor quantization depends mainly on how the clipping range is chosen. Weight ranges can be read directly from the trained values, while activation ranges require calibration on representative input data, typically a few hundred samples.
| Method | How the range is chosen | When it works well |
|---|---|---|
| Min-max | Observed minimum and maximum | Well-behaved ranges without outliers |
| Percentile | For example the 99.99th percentile | Rare extreme activations |
| Entropy (KL) | Minimizes distribution divergence | Long-tailed activation histograms |
| MSE search | Minimizes reconstruction error | General use, slightly slower |
| Moving average | Smoothed ranges during training | Quantization-aware training |
Clipping a few outliers increases error for those elements but shrinks the step size for all others. The best range is the one that minimizes total error on the layer output, not the one that covers every observed value.
Limitations and common mistakes
Per-tensor quantization degrades when value distributions differ strongly across channels or contain extreme outliers. Large language models are a known example: certain activation channels reach magnitudes tens of times larger than the rest, so a single scale wastes most integer levels.
| Symptom | Cause | Fix |
|---|---|---|
| Large accuracy drop in one layer | Channel ranges differ widely | Switch weights to per-channel |
| Collapse after depthwise convolution | Per-channel ranges vary by orders of magnitude | Per-channel scales or equalization |
| Degraded LLM output | Activation outlier channels | SmoothQuant or per-token scales |
| Poor results at 4 bits | Too few levels for one scale | Group-wise quantization |
A common mistake is calibrating with unrepresentative data, such as synthetic noise or a single class. The resulting ranges either clip real inputs or waste resolution, and the error appears only after deployment.
In everyday language
Think of a ruler with only 256 marks. Before measuring anything, you choose how long the ruler is. Per-tensor quantization picks one ruler length for a whole block of numbers.
This is fast and simple for small chips. But if one number is huge, the ruler must be long. Then the marks sit far apart, and small numbers lose detail. That is why some models need several rulers instead of one.
Seen in the real world
An engineering team builds a keyword spotting model for a battery-powered smart doorbell with a microcontroller and no floating-point unit. The trained model uses 32-bit floats and needs about 250 kilobytes, too large for the device’s memory budget.
The team applies post-training INT8 quantization with per-tensor scales for activations and calibrates on 500 recorded audio clips from real homes. The model shrinks to roughly one quarter of its size, runs entirely in integer arithmetic, and inference time falls enough to keep the microphone pipeline always on. Accuracy drops by less than one percentage point. One depthwise layer loses more accuracy, so the team switches only that layer’s weights to per-channel scales, which the runtime supports, and recovers most of the loss.