Skip to content

Conversation

jaehunkim
Copy link

@jaehunkim jaehunkim commented Jul 15, 2025

Summary

This PR introduces an experimental WebBackend that off-loads the heaviest parts of Poseidon proving to the GPU via wgpu. In early tests we observe ≈ 2 × speed-ups on Apple M3 Pro (Chrome /WASM) and up to ≈ 2.3 × on Windows 11 (Ryzen 7 7800X3D + RTX 4070 Ti, Chrome /WASM) compared with the current SimdBackend.

more comments on hackmd : https://hackmd.io/@wiNfxgvfSc-Ln2DBfsvoqQ/SyY_THluxg

What’s in this PR

Area Current Backend New Backend (web)
Trace extension (extend_trace) SIMD GPU
Constraint evaluation on the evaluation domain (evaluate_constraint_quotients_on_domain) SIMD GPU
All remaining stages Unchanged – stays on SimdBackend
  • A new WebBackend type lives alongside the existing SimdBackend.
  • The only compile-time branch between the two backends is in constraint_framework/src/component.rs – everything else is shared.
  • For now, shaders must be supplied manually by downstream crates if they want to enable GPU off-load inside air.
  • Referring to test_web_poseidon_prove() in crates/examples/src/poseidon/mod.rs is the easiest entry point for understanding how the WebBackend works.
    • It runs the same as the SimdBackend implementation until evaluate_constraint_quotients_on_domain, where it branches from SimdBackend.
    • It then calls FrameworkEval's eval() once to perform all evaluations in a single function call.

Benchmarks

  • Windows 11 - Ryzen 7 7800X3D + RTX 4070 Ti

  • Mac - Apple M3 Pro

  • The first pair of graphs compares the total Poseidon-prove pipeline when run on the SimdBackend versus the new GPU-accelerated WebBackend.

Pasted image 20250714171911 Pasted image 20250714171921
  • The next two graphs zoom in on the stages that are actually off-loaded to WebGPU—extend_trace and evaluate_constraint_quotients_on_domain—to show the raw shader speed-up in isolation.
Pasted image 20250714171854 Pasted image 20250714171901

How to Try It Out

cd crates/examples && wasm-pack test --chrome --release
  • Using wgpu in a headless browser is currently unstable, so it wasn’t included in the CI.

@reviewable-StarkWare
Copy link

This change is Reviewable

@ohad-agadi
Copy link
Contributor

this is very cool. I don't think this belongs in the main repo, as it will require support, which will give us a hard time.
perhaps it can be a separate crate that takes stwo as a cargo dependency. An 'extension' of sorts

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.

4 participants