chore: webgpu msm infra#24447
Draft
suyash67 wants to merge 6 commits into
Draft
Conversation
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.
4f2e78e to
2e31995
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wip