Humuhumu33 commited on
Commit
81c5d37
·
verified ·
1 Parent(s): 1185393

Upload holo-load2bit.mjs with huggingface_hub

Browse files
Files changed (1) hide show
  1. holo-load2bit.mjs +6 -4
holo-load2bit.mjs CHANGED
@@ -10,7 +10,7 @@
10
  // SAME { manifest, fetchTensor } shape — so the engine, KV-cache, and Q's brain loader need no changes.
11
  import { f16ToF32 } from "./qvac-ingest.mjs";
12
  import { blake3hex } from "./holo-blake3.mjs"; // BLAKE3 σ-axis κ verify (opt-in via manifest.hash==="blake3") — the GPU-parallel tree hash
13
- import { gpuBlake3Hex } from "./gpu-blake3.mjs"; // the SAME BLAKE3, run entirely on the GPU (2.74 GB/s) — used when globalThis.__gpuVerify
14
 
15
  async function gunzip(u8) { const ds = new DecompressionStream("gzip"); const w = ds.writable.getWriter(); w.write(u8); w.close(); return new Uint8Array(await new Response(ds.readable).arrayBuffer()); }
16
  const hex = (buf) => [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, "0")).join("");
@@ -110,9 +110,11 @@ export async function loadKappaObject(baseUrl, opts = {}) {
110
  // hash the on-GPU verifier reproduces; else SHA-256 (SRI axis, default). Untrusted-CDN-safe either way.
111
  let got;
112
  if (man.hash === "blake3") {
113
- if (typeof globalThis !== "undefined" && globalThis.__gpuVerify) {
114
- try { got = "blake3:" + await gpuBlake3Hex(gz); } // re-derive on the GPU (no CPU hash on the hot path)
115
- catch (e) { got = "blake3:" + blake3hex(gz); } // fall back to CPU if WebGPU verify is unavailable
 
 
116
  } else got = "blake3:" + blake3hex(gz);
117
  } else got = "sha256:" + hex(await crypto.subtle.digest("SHA-256", gz));
118
  if (got !== kappa) throw new Error("κ MISMATCH " + kappa.slice(0, 24));
 
10
  // SAME { manifest, fetchTensor } shape — so the engine, KV-cache, and Q's brain loader need no changes.
11
  import { f16ToF32 } from "./qvac-ingest.mjs";
12
  import { blake3hex } from "./holo-blake3.mjs"; // BLAKE3 σ-axis κ verify (opt-in via manifest.hash==="blake3") — the GPU-parallel tree hash
13
+ import { gpuBlake3Hex, gpuBlake3Available } from "./gpu-blake3.mjs"; // the SAME BLAKE3, run entirely on the GPU (2.74 GB/s)
14
 
15
  async function gunzip(u8) { const ds = new DecompressionStream("gzip"); const w = ds.writable.getWriter(); w.write(u8); w.close(); return new Uint8Array(await new Response(ds.readable).arrayBuffer()); }
16
  const hex = (buf) => [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, "0")).join("");
 
110
  // hash the on-GPU verifier reproduces; else SHA-256 (SRI axis, default). Untrusted-CDN-safe either way.
111
  let got;
112
  if (man.hash === "blake3") {
113
+ // DEFAULT: re-derive on the GPU (2.74 GB/s, no CPU hash on the hot path) whenever WebGPU is present;
114
+ // set globalThis.__gpuVerify=false to force the CPU path. CPU BLAKE3 is the automatic fallback.
115
+ if (gpuBlake3Available() && (typeof globalThis === "undefined" || globalThis.__gpuVerify !== false)) {
116
+ try { got = "blake3:" + await gpuBlake3Hex(gz); }
117
+ catch (e) { got = "blake3:" + blake3hex(gz); }
118
  } else got = "blake3:" + blake3hex(gz);
119
  } else got = "sha256:" + hex(await crypto.subtle.digest("SHA-256", gz));
120
  if (got !== kappa) throw new Error("κ MISMATCH " + kappa.slice(0, 24));