Spaces:
Running
Running
Upload gpu-blake3.mjs with huggingface_hub
Browse files- gpu-blake3.mjs +2 -3
gpu-blake3.mjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
| 4 |
// getBlock to re-derive each streamed weight block's κ on the GPU (Law L5) — no CPU hash on the hot path.
|
| 5 |
// Lazy: the device + pipelines are created once on first use; gpuBlake3Hex throws if WebGPU is absent so the
|
| 6 |
// caller can fall back to the CPU verifier.
|
|
|
|
| 7 |
|
| 8 |
const WGSL = `
|
| 9 |
@group(0) @binding(0) var<storage, read> inp : array<u32>;
|
|
@@ -60,9 +61,7 @@ async function ensure() {
|
|
| 60 |
if (_dev) return true;
|
| 61 |
if (_initP) return _initP;
|
| 62 |
_initP = (async () => {
|
| 63 |
-
|
| 64 |
-
const ad = await navigator.gpu.requestAdapter();
|
| 65 |
-
_dev = await ad.requestDevice();
|
| 66 |
const mod = _dev.createShaderModule({ code: WGSL });
|
| 67 |
const ci = await mod.getCompilationInfo();
|
| 68 |
const er = ci.messages.filter((m) => m.type === "error");
|
|
|
|
| 4 |
// getBlock to re-derive each streamed weight block's κ on the GPU (Law L5) — no CPU hash on the hot path.
|
| 5 |
// Lazy: the device + pipelines are created once on first use; gpuBlake3Hex throws if WebGPU is absent so the
|
| 6 |
// caller can fall back to the CPU verifier.
|
| 7 |
+
import { getDevice } from "./holo-gpu-device.mjs"; // the ONE shared device (max limits) — never a second one
|
| 8 |
|
| 9 |
const WGSL = `
|
| 10 |
@group(0) @binding(0) var<storage, read> inp : array<u32>;
|
|
|
|
| 61 |
if (_dev) return true;
|
| 62 |
if (_initP) return _initP;
|
| 63 |
_initP = (async () => {
|
| 64 |
+
_dev = (await getDevice()).dev; // SHARE the engine's device (max limits) — no second device
|
|
|
|
|
|
|
| 65 |
const mod = _dev.createShaderModule({ code: WGSL });
|
| 66 |
const ci = await mod.getCompilationInfo();
|
| 67 |
const er = ci.messages.filter((m) => m.type === "error");
|