open-standards/wai/wai-web/demo/verify_int_hyper.sh
Transaction Science 4df6e87b70 wai-web: in-browser decode of the full conditional codec (decodeIntHyper)
The same pure-i64 Rust that decodes the conditional codec natively compiles
straight to wasm32 and runs in the browser engine with NO ML runtime — and its
RGB is byte-identical to the native reference. A SOTA-class learned image codec
(PTQ of mbt2018_mean) decoding deterministically in-page, verifiable against a
pinned hash: the integer-entropy contract, in-browser.

- decodeIntHyper(g_s, h_s, entropy, bitstream) -> DecodedImage: parses the model
  JSONs + bitstream, runs int_hyper_synth::decode_conditional (factorized z →
  integer h_s → integer-σ entropy → integer g_s), returns RGB. No float, no ONNX.
- demo/verify_int_hyper_wasm.mjs + .sh: build the nodejs-target pkg, decode, and
  FNV-1a the RGB against the native cond.json hash. Verified: wasm32 reproduces
  adeb12d347d0bf7e (256x256, 42.61 dB) == native — zero JS ML runtime.

The g_s/h_s model JSONs are large (PTQ weights), so they are NOT committed; the
verify reads the export tool's artifacts (default /tmp/sota_int), exactly like
the native int_hyper_synth test. pkg-node/ is a build artifact (gitignored).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-25 02:11:40 -04:00

11 lines
690 B
Shell
Executable file

#!/usr/bin/env bash
# Reproducible proof that the wasm32 FULL conditional-codec decode is byte-
# identical to the native reference. Builds the nodejs-target pkg and runs the
# check against the export-tool artifacts (default /tmp/sota_int).
# from wai-web/: ./demo/verify_int_hyper.sh [model-dir]
set -euo pipefail
cd "$(dirname "$0")/.." # wai-web/
command -v wasm-pack >/dev/null || { echo "needs wasm-pack"; exit 1; }
command -v node >/dev/null || { echo "needs node"; exit 1; }
wasm-pack build --release --target nodejs --out-dir demo/pkg-node --out-name wai_web >/dev/null 2>&1
node demo/verify_int_hyper_wasm.mjs ./pkg-node/wai_web.js "${1:-${WAI_SOTA_INT_DIR:-/tmp/sota_int}}"