-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow proving in wasi #250
Conversation
We've run into memory issues with this solution when applying it to non-toy problems. We're working on an alternative approach using https://docs.rs/tempfile/latest/tempfile/fn.tempfile_in.html and an env var to define the temporary directory, since that will work in WASI ( |
Hey @hosted-fornet, just wanted to say that it's super awesome you're trying to get this working. There's another team right now trying to get SP1 working on mobile, so this could be quite interesting for them. |
Nice, that sounds like an interesting application: we're building a p2p node that uses wasm32-wasi components as userspace apps. SP1 would be a great unlock for us. Hopefully we can get our fix out soon so we can all have something more concrete to discuss. |
Ok, so @tadad did some good work tracking down the issue. It turns out the issue is not with the tempfiles; it is a separate issue. The problem is that WASM modules are limited to 4GB of memory since they are 32bit! This PR allows at least the smaller cases (fibonacci, e.g.) to work inside WASM modules. However, for more "real world" usecases, WASM is probably not ready for proving without the memory64 proposal. Verification works great, though. More specifically, adapting the ed25519 example to our system doesn't work because we hit the 4GB memory limit here. |
Just to follow up, it takes something like 20GB of memory, running natively on my machine, to prove the ed25519 example. Manipulating the shard size/threshold has no effect on this memory peak. |
Hey @nick1udwig, I am about to merge in a PR which should make memory performance much better. It could worth retrying this after a new merge from main. |
@jtguibas Thanks for the heads up; will try later today. |
Conflicts: core/src/stark/prover.rs
I still see ~20GB memory usage at peak when running the ed25519 example natively (and a The wasm component runs out of memory in the iterator here: Lines 107 to 112 in ff14294
|
Hi @nick1udwig, thanks for running it. Yeah hm, lowering the memory usage there is a bit hard to avoid in the current design of the system. I'm going to look into lowering the memory usage even more. |
Gotcha. @dr-frmr has told me that the ed25519 example is unrealistic for production because it'd be a precompile, so maybe I should just be using a different example? I do not understand this technology at more than a "user" level. |
Hey @jtguibas, I updated this branch and kept the minimum change to allow the prover to run in Wasm. This is the code we've been using in our Wasm apps, and it seems to work. The memory limits are a separate problem of course, but this allows us to handle small-medium proofs without the |
Hi @dr-frmr, in the latest version of the prover, we no longer use tempfile::tempfile(), so hopefully it should work more out of the box now! |
Oh, well that's great to hear -- can go ahead and close this then. |
Nice |
In attempting to get the sp1 prover working in wasm32-wasi, we ran into an error originating from https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/wasi/os.rs#L268-L270
This fix avoids using
tempfile
for wasm32, which was traced as the source of the problem.