Reza2kn's picture
Final Rizeh reader INT4 conversions; source 51b8c314b055; full-page qualification limits documented
2fb4ca2 verified
|
Raw History Blame Contribute Delete
2.4 kB

tract consumer harness

The same RTN/block16 ONNX readers run under tract CPU/Metal on Mac and CUDA on Linux. These target executions were retested on the final five checkpoints. HQQ/block32 is not supported by the tested tract importer. Native Windows was not tested. Detector execution under tract is not qualified by this reader harness.

Tested tract version:0.23.9-pre, source revision9653842d58e6f8a7b71f77b41a36a08458b33c57 from sonos/tract. recipe/tract-runner/src/main.rs is the persistent runner used for measurements. It keeps up to eight prepared plans by padded width, avoiding graph preparation on repeated shapes. The recorded five-reader CUDA runs each reused296 prepared plans across300 inputs. This cache stores execution plans, not repeated OCR results.

git clone https://github.com/sonos/tract.git recipe/tract-source
git -C recipe/tract-source checkout 9653842d58e6f8a7b71f77b41a36a08458b33c57
# Mac CPU and Metal build:
cargo build --release --manifest-path recipe/tract-runner/Cargo.toml
recipe/tract-runner/target/release/bina-rizeh-tract components/body/models/recognizer-w4-block16.onnx default
# Use runtime argument metal for Mac GPU.

For the Linux CUDA build, copy Cargo.cuda.toml over Cargo.toml before building. That enables cuda-13000 and requires the CUDA13 toolkit, cuDNN and corresponding native libraries. The tested Linux host had these installed; native-library setup and Windows packaging are not supplied by this model bundle. Run with runtime argument cuda after building. CPU-only builds can omit the metal/cuda feature, but that exact separate build configuration was not a fresh target in this release.

The runner reads one JSON request per stdin line:

{"width":512,"true_width":198,"pixels":"/absolute/path/to/padded-float32-ink.bin"}

Pixels are native-endian float32, shape1x1x64xpadded_width, black=1/paper=0, zero padded on the right. Tested machines were little-endian. Use powers-of-two widths512..8192 and retain true_width. Keep one process alive per active reader. The first request for a width prepares and warms the plan; later requests reuse it. Output includes frame tokens, valid CTC length, native model seconds and plan_cache_hit. Collapse repeated nonblank CTC IDs, map IDs1..1624 through vocab.json, then use rtl.flip(visual,base_rtl=True). Full page routing, geometry and table extraction remain separate.