Spaces:
Running
Running
Upload holo-load2bit.mjs with huggingface_hub
Browse files109 unmodified lines110111112113114115116117118119120121109 unmodified lines// hash the on-GPU verifier reproduces; else SHA-256 (SRI axis, default). Untrusted-CDN-safe either way.let got;if (man.hash === "blake3") {// OPT-IN (?verify=gpu → globalThis.__gpuVerify): re-derive on the GPU. Default = CPU BLAKE3 (the proven,// working path). GPU verify wired here fails during engine construction (2-device conflict — see note);// needs a single-device refactor before it can be default. On any GPU error, fall back to CPU.if (typeof globalThis !== "undefined" && globalThis.__gpuVerify && gpuBlake3Available()) {try { const h = await gpuBlake3Hex(gz); got = "blake3:" + h; }catch (e) { got = "blake3:" + blake3hex(gz); }} else got = "blake3:" + blake3hex(gz);} else got = "sha256:" + hex(await crypto.subtle.digest("SHA-256", gz));if (got !== kappa) throw new Error("κ MISMATCH " + kappa.slice(0, 24));109 unmodified lines110111112113114115116117118119120121109 unmodified lines// hash the on-GPU verifier reproduces; else SHA-256 (SRI axis, default). Untrusted-CDN-safe either way.let got;if (man.hash === "blake3") {// DEFAULT: re-derive on the SHARED GPU device (2.74 GB/s). SAFE fallback: on any GPU error OR if the GPU// digest disagrees with the pin, re-derive on the CPU — so a GPU quirk degrades to CPU speed, never fails// the load. Only a CPU mismatch (real corruption) throws. Set globalThis.__gpuVerify=false to force CPU.if (gpuBlake3Available() && (typeof globalThis === "undefined" || globalThis.__gpuVerify !== false)) {try { got = "blake3:" + await gpuBlake3Hex(gz); } catch (e) { got = "blake3:" + blake3hex(gz); }if (got !== kappa) got = "blake3:" + blake3hex(gz); // GPU disagreed → trust the CPU verifier} else got = "blake3:" + blake3hex(gz);} else got = "sha256:" + hex(await crypto.subtle.digest("SHA-256", gz));if (got !== kappa) throw new Error("κ MISMATCH " + kappa.slice(0, 24));
holo-load2bit.mjs+6-6