﻿# ONNX Runtime CPU QuantizeLinear: read the scale using its own type before choosing division precision

The 1.32 CPU QuantizeLinear update separates tensor storage types from division precision; rounding-sensitive mixed-type inputs are essential tests.

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-ort-quantizelinear-independent-scale-type/
Language: en

ONNX Runtime 1.32.0 supports independent input and scale types and the opset-23 precision attribute in CPU QuantizeLinear. The linked PR distinguishes reading each tensor correctly from choosing arithmetic precision. Rounding a wider scale down to the input type first can change the final integer code even when the input value itself is unchanged.

## The scale is not an input-typed byte array

The input and scale have independent declared element types. Reading scale storage as though it used the input type is therefore not a valid shortcut. A proposed test uses a scale whose wider representation differs meaningfully from its narrowed form. Keep its raw encoding and the input fixed, then compare against an explicit reference that reads each with the correct type before doing arithmetic.

## Arithmetic precision is another decision

After storage is interpreted correctly, the operator still has a precision rule for division. The PR handles explicit precision and a default based on the scale type for the relevant opset path. Test default and explicit modes separately. A tolerance on dequantized output can hide a one-code boundary difference, so compare the quantized codes directly where exact output is specified. Preserve the model’s declared opset with the result.

## Granularity and packed tails add indexing coverage

The linked regressions cover granularities and packed outputs as well as the scalar precision example. A local suite should include per-axis or blocked parameters used by the application and an odd tail where supported. Correct scalar rounding does not establish the right scale was selected for every element. Use different scales across parameter groups so a wrong index cannot be hidden by identical values.

## CPU quantization is the stated scope

The PR explicitly separates CPU quantization from dequantization and CUDA work. Do not infer identical coverage for those routes from this release entry. This article reports the type-and-precision correction and proposed tests without independent numerical measurements. A useful compatibility result names provider, opset, input type, scale type and precision mode, connecting the accepted model contract to the actual code path exercised.

## Sources

- [ONNX Runtime v1.32.0 release](https://github.com/microsoft/onnxruntime/releases/tag/v1.32.0)
- [ONNX Runtime pull request #32735](https://github.com/microsoft/onnxruntime/pull/32735)

## Related reading

- [ONNX QuantizeLinear: the scale shape and axis define what is quantized together](/journal/fg2-onnx-quantize-linear-axis-scale-contract/)
- [llama.cpp b12202 and the difference between a precision request and an accumulator](/journal/news-llamacpp-b12202-precision-request-vs-accumulator/)
