int_synth + int_entropy are pure i64 (no ort, no float), so the SAME Rust that decodes natively compiles to wasm32 and runs in the browser with no ML runtime at all — and the bytes are identical to native on every machine. This is the integer-entropy contract's payoff made visible: a learned-codec reconstruction whose hash is portable. - int_synth: factor the decode into `decode_from_spec(payload, spec_bytes)` (no std::fs); `decode(payload, path)` now reads the spec and delegates. WASM/no-FS sinks call the bytes entry point with host-supplied weights. Behavior- identical (4 int_synth tests green). - wai-web: add the `neural_int` feature + a `neural_int` wasm-bindgen module: decodeIntSynth(payload, specJson) -> RGB, the int_entropy primitives (fixedScaleEdges / quantizeScale / detBuildIndex), and blake3Hex for the in-page receipt check. Compiles to wasm32 (web + nodejs targets). - demo: int_synth.html/.js — decode a vector to a canvas and verify its BLAKE3 against the frozen native hash in-page. verify_int_synth.sh + verify_int_synth_wasm.mjs — reproducible CLI proof. Verified: all four conformance vectors (incl. the real trained 128×128 photo model, 21.6 dB) decode in wasm32 byte-identical to the frozen NATIVE corpus hashes. Deterministic learned-codec decode in-browser, zero JS ML runtime. Co-Authored-By: Claude Opus 4.8 <[email protected]>
64 lines
3.9 KiB
HTML
64 lines
3.9 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>WAI — integer-exact neural image sink</title>
|
||
<style>
|
||
:root { --bg:#06080c; --bg2:#0d1117; --border:#1e2736; --text:#e6edf5; --text2:#8b99ad; --text3:#4a5568; --g:#00e5a0; --w:#f0b429; --mono:'JetBrains Mono','SF Mono',Menlo,monospace; }
|
||
* { box-sizing:border-box; margin:0; padding:0; }
|
||
body { background:var(--bg); color:var(--text); font-family:var(--mono); padding:24px; }
|
||
h1 { font-size:15px; letter-spacing:.04em; margin-bottom:4px; } h1 em { font-style:normal; color:var(--g); }
|
||
.sub { font-size:11px; color:var(--text2); margin-bottom:14px; max-width:880px; line-height:1.5; }
|
||
code { color:var(--w); }
|
||
.bar { display:flex; gap:10px; align-items:center; margin-bottom:10px; flex-wrap:wrap; }
|
||
select { background:var(--bg2); color:var(--text); border:1px solid var(--border); border-radius:6px; padding:6px 12px; font-family:var(--mono); font-size:12px; cursor:pointer; }
|
||
select:hover { border-color:var(--g); }
|
||
canvas { background:#04060a; border:1px solid var(--border); border-radius:10px; display:block; image-rendering:pixelated; }
|
||
.hud { display:flex; gap:22px; margin-top:10px; font-size:11px; color:var(--text2); flex-wrap:wrap; }
|
||
.hud b { color:var(--text); } .hash { color:var(--g); }
|
||
#badge { font-size:12px; padding:4px 12px; border-radius:99px; display:none; }
|
||
#badge.ok { display:inline-block; background:rgba(0,229,160,.12); color:var(--g); border:1px solid rgba(0,229,160,.5); }
|
||
#badge.bad { display:inline-block; background:rgba(255,107,107,.12); color:#ff6b6b; border:1px solid rgba(255,107,107,.5); }
|
||
.note { margin-top:14px; font-size:10.5px; color:var(--text3); max-width:880px; line-height:1.55; }
|
||
.note b { color:var(--text2); }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<h1>WAI <em>integer-exact neural image</em> — in-browser, no ML runtime</h1>
|
||
<p class="sub">
|
||
A <code>wai.neural.int_synth</code> payload arrived: int8 latents + a model spec. This tab decodes it
|
||
to RGB with the <b>same pure-i64 Rust</b> that decodes natively, compiled to wasm32 — <b>no
|
||
onnxruntime-web, no WebGPU, no float anywhere</b>. Because the decode is integer all the way down
|
||
(the integer-entropy contract), the reconstruction is byte-identical on every machine, so the page
|
||
re-checks its BLAKE3 against the hash the native reference froze into
|
||
<code>neural-conformance/expected_hashes.json</code> — a learned-codec image verified client-side,
|
||
no server round-trip.
|
||
</p>
|
||
<div class="bar">
|
||
<select id="vec">
|
||
<option value="photo">photo — real trained model, 128×128, 4 layers (PSNR 21.6 dB)</option>
|
||
<option value="facade">facade — 72×72, 3 layers</option>
|
||
<option value="gradient">gradient — 38×38, 2 layers</option>
|
||
<option value="bloom">bloom — 18×18, 1 layer</option>
|
||
</select>
|
||
<span id="badge"></span>
|
||
</div>
|
||
<canvas id="c" width="512" height="512"></canvas>
|
||
<div class="hud">
|
||
<span>image <b id="dims">—</b></span>
|
||
<span>latent channels <b id="inch">—</b></span>
|
||
<span>synthesis layers <b id="layers">—</b></span>
|
||
<span>decoded hash <b class="hash" id="got">—</b></span>
|
||
<span>frozen hash <b class="hash" id="want">—</b></span>
|
||
</div>
|
||
<p class="note">
|
||
<b>Why this is the moat:</b> a float learned codec (the SOTA learned-image family) desyncs on ~1e-5 of
|
||
cross-platform float drift in the entropy scale, so its decode is reproducible only on the same build —
|
||
you cannot put its reconstruction in a receipt. <code>int_synth</code> is integer all the way down, so
|
||
the hash above is portable: this browser, a native sink, and the conformance corpus all produce the
|
||
same bytes. The wire carried latents + weights; your device produced the exact image, and proved it.
|
||
</p>
|
||
<script type="module" src="int_synth.js"></script>
|
||
</body>
|
||
</html>
|