Humuhumu33 commited on
Commit
f789de8
·
verified ·
1 Parent(s): b5ae11e

Upload holo-load2bit.mjs with huggingface_hub

Browse files
Files changed (1) hide show
  1. holo-load2bit.mjs +6 -2
holo-load2bit.mjs CHANGED
@@ -114,8 +114,12 @@ export async function loadKappaObject(baseUrl, opts = {}) {
114
  // digest disagrees with the pin, re-derive on the CPU — so a GPU quirk degrades to CPU speed, never fails
115
  // the load. Only a CPU mismatch (real corruption) throws. Set globalThis.__gpuVerify=false to force CPU.
116
  if (gpuBlake3Available() && (typeof globalThis === "undefined" || globalThis.__gpuVerify !== false)) {
117
- try { got = "blake3:" + await gpuBlake3Hex(gz); } catch (e) { got = "blake3:" + blake3hex(gz); }
118
- if (got !== kappa) got = "blake3:" + blake3hex(gz); // GPU disagreed trust the CPU verifier
 
 
 
 
119
  } else got = "blake3:" + blake3hex(gz);
120
  } else got = "sha256:" + hex(await crypto.subtle.digest("SHA-256", gz));
121
  if (got !== kappa) throw new Error("κ MISMATCH " + kappa.slice(0, 24));
 
114
  // digest disagrees with the pin, re-derive on the CPU — so a GPU quirk degrades to CPU speed, never fails
115
  // the load. Only a CPU mismatch (real corruption) throws. Set globalThis.__gpuVerify=false to force CPU.
116
  if (gpuBlake3Available() && (typeof globalThis === "undefined" || globalThis.__gpuVerify !== false)) {
117
+ const t0 = performance.now();
118
+ let h = null; try { h = await gpuBlake3Hex(gz); } catch (e) {}
119
+ if (h && "blake3:" + h === kappa) { // verified ON THE GPU, matches the pin
120
+ got = kappa;
121
+ try { const v = globalThis.__vs || (globalThis.__vs = { n: 0, bytes: 0, ms: 0 }); v.n++; v.bytes += gz.length; v.ms += performance.now() - t0; } catch (e) {}
122
+ } else got = "blake3:" + blake3hex(gz); // GPU errored/disagreed → CPU re-derive (never fail on a GPU quirk)
123
  } else got = "blake3:" + blake3hex(gz);
124
  } else got = "sha256:" + hex(await crypto.subtle.digest("SHA-256", gz));
125
  if (got !== kappa) throw new Error("κ MISMATCH " + kappa.slice(0, 24));