Declare the rounding contract

At a scaled value of 2.5, rounding to the nearest even integer gives 2. Rounding to the nearest integer with ties away from zero gives 3. At 2.25, both give 2. A test set containing only ordinary values can therefore agree with two implementations that have different halfway rules. The useful question is which rule the task actually requires.[3][4]

This worksheet declares a scalar int8 contract: divide x by a positive scale, round the exact result to nearest with ties to even, then clamp the integer to [-128, 127]. The zero point is zero. Its deliberate alternative changes only the tie rule to away from zero. Neither policy is universally correct: the alternative fails here because the declared contract requires nearest-even rounding. The worksheet represents each output as a Python integer constrained to that range; it does not allocate an int8 tensor.[3][4]

  • Declare the tie rule: 2.5 maps to2 under nearest-even and3 under nearest-away;3.5 maps to4 under both.

Retain ties and clipping controls

The first stratum contains 64 ordinary cases: positive and negative quarter-step values at two scales. The alternative matches every expected output. The second contains 32 small exact ties. It fails 16 of those outputs. The stored ratios use numerator and denominator pairs, so a value intended to be halfway is exactly halfway in this model. The two scales are 1 and 3/8; each normalized case appears at both scales with a correspondingly scaled x.[3][4]

Sign and parity both matter. At -2.5 the required answer is -2 and the alternative gives -3. At either 3.5 or -3.5, both policies agree, producing 4 or -4. Testing only one tie can miss the distinction. This fixture includes ties on both sides of zero and beside both even and odd integers, with ordinary cases alongside them.[3][4]

Clipping adds another trap. At -128.5, nearest-even produces -128 before clipping while nearest-away produces -129. Both final int8 outputs are -128. That input satisfies the final-output contract under both policies, despite their different intermediate integers. At 126.5, the required output is 126 and the alternative produces 127, so the difference survives. Of the 16 boundary cases, eight have different rounded integers; four differences disappear after clipping and four remain visible.[3][4]

The complete fixture contains 112 scalar evaluations across three authored strata. It retains 24 differences before clipping and 20 different final outputs. These counts describe this deliberately constructed worksheet. They are not a distribution of real model activations, an empirical error rate, or 112 independent experiments. A passing clipping case is retained as a useful positive boundary control rather than mislabeled as a final-output failure.[3][4]

  • Saturation can hide the difference: At -128.5, rounded values -128 and -129 both become final int8 output -128.

Exact rational scalar inputs; nearest-even contract versus the deliberate nearest-away alternative.

Authored stratumCasesRounded integers differFinal int8 outputs differDifferences masked by clipping
Ordinary values64000
Small exact ties3216160
Boundary ties16844
All cases11224204
  • The same56 normalized cases appear at two scales.
  • Counts are designed coverage, not an empirical error rate.

Reproduce the saved arithmetic

The oracle is Python Fraction.__round__, which implements nearest-even rounding on exact rational inputs. A separate positive candidate uses integer quotient, remainder and parity. It matches all 112 cases. The file also retains four valid-input controls and twelve selected malformed inputs that are refused. Literal expected ratios, rounded integers, final outputs and aggregate counts were frozen before the original CPU invocation on December 1, 2026 UTC. All 560 literal case checks passed, alongside the positive candidate and input controls.[3][4]

The runnable download needs only Python 3.8 or later and the standard library. Extract it and run python3 -I -B quantization_ties_demo.py to print the full JSON ledger. Every case includes x, scale, exact normalized value, both rounded integers and both final outputs. The saved original result is included. The script never calls ONNX, PyTorch, NumPy, CUDA or a provider, and this article reuses that one saved execution.[3][4]

Apply the contract and credit the sources

For a kernel grader, write the rounding rule into the correctness contract before attaching a speed reward. Include unsaturated halfway cases with both signs and parities, and inspect final integer outputs exactly when exact int8 equality is the contract. Keep saturation cases too, but recognize that they can hide a rounding-policy difference. If the production path uses floating-point division, construct and verify cases in that actual dtype and operation order: an exact-rational worksheet does not prove the divided floating value lands on a tie.[3][4]

ONNX contributors document nearest-even rounding of the scaled value and int8 saturation in QuantizeLinear version 13. That is one concrete operator contract motivating the choice here; no ONNX runtime was tested. Python Software Foundation contributors document the Fraction oracle. Nodus authored this small fixture and worked example. The contribution is inspectable test coverage for an established rounding distinction, not a new rounding rule or a discovered framework defect.[1][2]

  • Preserve halfway cases with both signs and parities, and make the rounding policy part of the grader contract.

Sources

  1. ONNX contributors — QuantizeLinear version 13 onnx.ai
  2. Python Software Foundation and contributors — Fraction.__round__ docs.python.org
  3. MIT source and complete saved result data.nodus-compute.ai
  4. Complete scalar case ledger data.nodus-compute.ai
  5. Original saved execution and provenance data.nodus-compute.ai
  6. Original vector figure data.nodus-compute.ai