open-standards/wai/wai-web/demo
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Transaction Science 89e0da789e wai: compact binary model + in-browser conditional-codec demo
Makes the in-browser decode of the full conditional codec practical: the model
shrinks from ~52MB JSON to ~23.5MB binary (~15.5MB gzipped on the wire), and a
real HTML page decodes a SOTA-class learned codec in the browser, verifying its
hash against the native reference.

- typed IntModel: refactored run_net/decode/decode_conditional off serde_json
  Value onto an IntModel { afrac, gf, shift, layers: Vec<IntLayer> }, built by
  either IntModel::from_json (existing schema) or IntModel::from_bytes (compact
  binary: magic WHM1, int12 weights as i16, IGDN gamma as i32, the rest i64).
  Decode is byte-identical whichever the source.
- export tool writes *_model.bin alongside the JSON (model_to_bin).
- conformance: the binary model decodes byte-identically to JSON (new assert in
  tests/int_hyper_synth.rs); all 3 tests green in release (~11s, the 100s was
  debug — release wasm decode is ~10s).
- wasm: decodeIntHyperBin (binary path) beside decodeIntHyper (JSON); shared
  cond_decode helper. demo/verify_int_hyper_wasm.mjs checks both paths.
- demo/int_hyper.html + .js: fetch the binary models + 1.4KB bitstream, decode
  with pure-i64 wasm (no ML runtime), paint the canvas, FNV-1a the RGB against
  cond.json. Verified in headless Chrome: 256x256, 42.61 dB, decoded hash
  adeb12d347d0bf7e == native, ~10s decode, zero console errors.

The PTQ model files are large and NOT committed (gitignored demo/int_hyper/);
regenerate with tools/wai_sota_int_synth_export.py. pkg/ stays a build artifact.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-25 03:14:46 -04:00
..
audio wai: interactive + temporal cargo classes, provenance, telepresence 2026-06-13 23:16:42 -04:00
int_synth wai-web: integer-exact neural decode in the browser, no ML runtime 2026-06-21 05:53:41 -04:00
vectors wai: interactive + temporal cargo classes, provenance, telepresence 2026-06-13 23:16:42 -04:00
audio.html wai: interactive + temporal cargo classes, provenance, telepresence 2026-06-13 23:16:42 -04:00
audio.js wai: interactive + temporal cargo classes, provenance, telepresence 2026-06-13 23:16:42 -04:00
int_hyper.html wai: compact binary model + in-browser conditional-codec demo 2026-06-25 03:14:46 -04:00
int_hyper.js wai: compact binary model + in-browser conditional-codec demo 2026-06-25 03:14:46 -04:00
int_synth.html wai-web: integer-exact neural decode in the browser, no ML runtime 2026-06-21 05:53:41 -04:00
int_synth.js wai-web: integer-exact neural decode in the browser, no ML runtime 2026-06-21 05:53:41 -04:00
README.md wai-web: integer-exact neural decode in the browser, no ML runtime 2026-06-21 05:53:41 -04:00
verify_int_hyper.sh wai-web: in-browser decode of the full conditional codec (decodeIntHyper) 2026-06-25 02:11:40 -04:00
verify_int_hyper_wasm.mjs wai: compact binary model + in-browser conditional-codec demo 2026-06-25 03:14:46 -04:00
verify_int_synth.sh wai-web: integer-exact neural decode in the browser, no ML runtime 2026-06-21 05:53:41 -04:00
verify_int_synth_wasm.mjs wai-web: integer-exact neural decode in the browser, no ML runtime 2026-06-21 05:53:41 -04:00
world.html wai: interactive + temporal cargo classes, provenance, telepresence 2026-06-13 23:16:42 -04:00
world.js wai: interactive + temporal cargo classes, provenance, telepresence 2026-06-13 23:16:42 -04:00

wai-web demo — interactive-worlds browser sink

world.html is a conformant wai.world.replay sink running in a tab: the WWLD payload (a tick-0 world + signed op log, ~1.3 KB for the truss vector) is re-derived frame by frame in WebGPU by the same wai crate native sinks run, compiled to wasm32 with the codec chain off (--no-default-features --features world). At the sealed final tick the sink recomputes the BLAKE3 state hash and compares it to the publisher's Ed25519-signed seal — replay-equivalence, demonstrated: the hash the browser computes is byte-identical to world-conformance/expected_hashes.json.

Run

# from wai-web/: rebuild the wasm pkg after engine changes
wasm-pack build --target web --out-dir demo/pkg

# vectors come from the conformance corpus
cp ../world-conformance/vectors/{truss_fracture,ballistic_bounce,basic_kinematics}.wwld demo/vectors/

# serve (any static server; WASM needs http, not file://)
python3 -m http.server 8741
# → http://localhost:8741/demo/world.html

Needs a WebGPU browser (Chrome/Edge stable, Safari TP). No build steps beyond wasm-pack; no JS dependencies.

int_synth.html — integer-exact neural image sink (no ML runtime)

int_synth.html decodes a wai.neural.int_synth payload to RGB with the same pure-i64 Rust that decodes natively, compiled to wasm32 — no onnxruntime-web, no WebGPU, no float. Because the decode is integer all the way down (the integer-entropy contract, SPEC §6), the reconstruction is byte-identical on every machine, so the page re-checks its BLAKE3 against the hash the native reference froze into neural-conformance/expected_hashes.json. The four staged vectors (demo/int_synth/, copied from the corpus) include the real trained photo model (128×128, 21.6 dB PSNR).

# from wai-web/: build the web pkg, then serve
wasm-pack build --release --target web --out-dir demo/pkg --out-name wai_web
python3 -m http.server 8741   # → http://localhost:8741/demo/int_synth.html

Reproducible CLI proof that the wasm decode equals the native corpus (builds the nodejs-target pkg and checks all four vectors' hashes):

./demo/verify_int_synth.sh