Skip to content

chore: webgpu msm infra#24447

Draft
suyash67 wants to merge 6 commits into
merge-train/barretenbergfrom
sb/webgpu-msm-fresh
Draft

chore: webgpu msm infra#24447
suyash67 wants to merge 6 commits into
merge-train/barretenbergfrom
sb/webgpu-msm-fresh

Conversation

@suyash67

@suyash67 suyash67 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

wip

suyash67 added 6 commits July 1, 2026 20:59
New BBERG_WEBGPU_MSM_HOOK CMake option (default OFF, WASM-only) that lets a BN254 batch MSM delegate to a JS-imported WebGPU host call. Adds the hook TU, the request/result marshalling plus its unit test, and the bb_* WASM exports the runtime toggle (bb_set_webgpu_msm_enabled) and bridge use. Default builds link none of this; the native Pippenger path is untouched.
Self-contained src/msm_webgpu: the MsmV2 pair-tree pipeline, BatchMsmV2, additive scalar masking, the SAB GPU bridge (host + worker stub), the cuZK shader manager, the WGSL templates and their inlined _generated bundle, and a runtime capability gate that routes miscompiling/slow GPUs back to WASM. Pure TS/WGSL; imported only when the bridge is wired.
…flag

The bridge is set up only when Barretenberg is constructed with webgpuMsm: true and navigator.gpu exists, so every existing consumer is unaffected. Adds the env-import stubs so a hook-built WASM links cleanly, the worker-factory plumbing, the blocklist/enable calls, and the package.json deps (@noble/curves, mustache, bigint-crypto-utils) plus the generate:wgsl script. Also raises clock_time_get to performance-clock resolution for the phase-level trace.
Under BBERG_WEBGPU_MSM_HOOK and the runtime flag, MSM<BN254>::batch_multi_scalar_mul delegates each batch to the bridge, and commit() registers the full monomial-points SRS once so every commit routes as a prefix-with-offset of one uploaded pool instead of re-shipping the SRS per MSM. Both guarded, so default builds are unaffected.
Cap the iOS shared-memory maximum at 512MB (WebKit reserves the full maximum upfront and iOS counts it against the WebContent budget; the Chonk prover peaks ~270MiB), and slice an oversized cached SRS to numPoints*64 so srsInitSrs does not infer the wrong bytes-per-point and reject it.
…PU harness

Thin Barretenberg wrappers over the backend's bb_emit_msm_phase raw export and dumpBenchTraceJson; both no-op on a backend without the export. Used by the bench harness to read MSM-phase wall time and the phase-level BB_BENCH trace.
@suyash67 suyash67 force-pushed the sb/webgpu-msm-fresh branch from 4f2e78e to 2e31995 Compare July 1, 2026 21:15
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​types/​mustache@​4.2.61001007480100
Addednpm/​mustache@​4.2.010010010075100
Addednpm/​bigint-crypto-utils@​3.3.01001009680100
Addednpm/​@​webgpu/​types@​0.1.7110010010094100

View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant