Skip to content

v16.8 — Importer fixes: tree feature grids and the requantizer clamp

Choose a tag to compare

@danmcleran danmcleran released this 08 Nov 15:52
· 48 commits to master since this release
dabcdf9

v16.8 — Importer fixes: tree feature grids and the requantizer clamp

Two of the importers could produce a model that compiled, ran and passed its own bit-exactness check while being less accurate than the source model, or carrying a requantizer shift outside the contract. Both are fixed. Nothing under cpp/ changed, so on-device code is the same as v16.7; re-export models made with the affected importers to pick up the fixes.

Fixes

  • Tree importer feature grid (apps/import_trees). FeatureQuant.from_data clipped each feature's zero point to the storage range. A feature whose calibration range does not include 0, such as a length, a temperature in kelvin or any always-positive sensor reading, needs a zero point outside that range, so the clip shifted the grid and every value above (qmax - qmin) * scale saturated. On iris at int8, sepal length quantized to 127 for every sample. Thresholds past that point merged or were dropped, and accuracy fell with no error reported. The zero point is now left unclipped; it was already int32 in the generated header. Its only bound keeps the int32 sum in quantizeFeatures from overflowing, and a feature beyond it (far from 0 with a span below float32's resolution there) falls back to a range that includes 0. A random forest on the wine dataset goes from 96.3% to 98.1% held-out accuracy, matching scikit-learn exactly, and an iris random-forest regressor on an int16 grid goes from a maximum error of 0.435 to 0. Four new tests fail on the old importer. Present since the importer was added in v16.1.
  • PyTorch importer requantizer clamp (apps/import_pytorch). quantize_multiplier now applies the same clamp as the C++ quantizeMultiplier from v16.7: a scale ratio small enough to need a shift above 31 becomes multiplier 0, and the shift is never below -31. It now matches the C++ on 644 ratios from 2^-80 to 2^80 (392 differed before), so the importer can no longer emit a shift outside Requantizer's contract.

Both bugs were found while porting the importers to tinymind-rs, whose parity tests require the same integer model from both implementations.

Docs

  • README brought up to date: the Mixture-of-Experts and upsampling layers, the Requantizer shift contract, which SIMD backends CI actually executes, five missing blocking quality gates and two advisory ones, 15 examples and 7 test suites that were missing from the project tree.
  • GitHub Pages brought up to date: the SVE-first Arm dispatch order on two pages, a new "How the backends are validated" section, Upsample1D, pages for the moe_regimes_int8 and import_moe_demo examples, 17 gallery plots, and the lowercase project name throughout.
  • The gbdt_tabular_int8 example no longer claims that the second feature moves the region boundaries; the decision map is three vertical bands.

Documentation, architecture guides, and example gallery: https://danmcleran.github.io/tinymind/

Full changelog: v16.7...v16.8