Per-tensor quantization

On this page 7

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.

ParameterSymmetric caseAsymmetric caseWhat it affects
Scale (s)max absolute value / 127(max – min) / 255Step size and rounding error
Zero point (z)Fixed at 0Integer from 0 to 255Exact representation of zero
Integer range-127 to 1270 to 255Number of usable levels
Parameters storedOne floatOne float and one integerMetadata overhead
Parameters of per-tensor INT8 quantization

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.

GranularityValues sharing one scaleAccuracyHardware cost
Per-tensorEntire tensorLowest of the groupMinimal, widely supported
Per-channelOne output channelHigher for weightsLow, supported by most runtimes
Group-wiseBlocks of 32-128 valuesHigh at 4 bitsMore metadata, custom kernels
Per-tokenOne activation rowHigh for outlier activationsRuntime scale computation
Quantization granularity options

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.

MethodHow the range is chosenWhen it works well
Min-maxObserved minimum and maximumWell-behaved ranges without outliers
PercentileFor example the 99.99th percentileRare extreme activations
Entropy (KL)Minimizes distribution divergenceLong-tailed activation histograms
MSE searchMinimizes reconstruction errorGeneral use, slightly slower
Moving averageSmoothed ranges during trainingQuantization-aware training
Range selection methods for per-tensor calibration

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.

SymptomCauseFix
Large accuracy drop in one layerChannel ranges differ widelySwitch weights to per-channel
Collapse after depthwise convolutionPer-channel ranges vary by orders of magnitudePer-channel scales or equalization
Degraded LLM outputActivation outlier channelsSmoothQuant or per-token scales
Poor results at 4 bitsToo few levels for one scaleGroup-wise quantization
Typical problems and fixes

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.