Hi, guys! I'm new to all this WASM stuff and looking for deterministic WASM runtime (for some POC). Please advise whether Wasmtime is handling non-determinism issues and if yes, how (would be nice to point to some article/code)?
Hi @Olexiy Kulchitskiy -- the execution of Wasm in Wasmtime should be completely deterministic with a few exceptions:
Ah, stack depth as well; the point at which one gets a stack-overflow trap is implementation-defined (but that should not be observable in any normally-returning Wasm call, as the trap terminates the instance)
And the memory allocation limit.
You may also want to use the static_memory_forced API, to prevent memory.grow allocation from failing nondeterministically.
got it. Thank you
Relaxed SIMD will be deterministic per-platform but will appear nondeterministic across platforms - basically the same problem as for NaNs, but will require a different solution.
Resurrecting this after a while, could someone expand on this for wasi-p2, and maybe even wasi-p3 with async in mind?
You could start by doing a text search for "determinstic" in https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md. Async task and thread scheduling are indeed nondeterministic, spec-wise, in the default profile, but enabling the deterministic profile can reduce (and maybe eliminate?) that nondeterminism.
@dakom have you read https://docs.wasmtime.dev/examples-deterministic-wasm-execution.html already? it attempts to answer your original question, if anything is missing we should update that page to contain it
@fitzgen (he/him) - that's an excellent resource, thank you!!
So I think my only high-level question is how this page might need to be updated for p3/async?
that all falls under "imports" -- if you want determinism, you need to make sure your imports are deterministic (or you are deterministically replaying a recording of non-deterministic imports) and http APIs are not particularly deterministic
It partially falls under "imports", but some of the "imports" for async are intrinsics over which the embedder has no control, and Wasmtime's implementation of some of those intrinsics are non-deterministic, with no option (yet) to make them deterministic.
It would also depend on the runtime being run in a deterministic way, e.g. tokio, right?
ah I would have assumed that like task scheduling was deterministic assuming that the imports themselves were deterministic
I guess I would say we haven't made an effort to make task scheduling deterministic yet, so if it is, that's a happy coincidence :)
@dakom FYI Wasmtime's async support doesn't depend on tokio (although wasmtime-wasi does), so you could bring your own deterministic executor if desired.
But I suspect there are sources of nondeterminism inside Wasmtime's scheduling even with a deterministic executor, just because we haven't tried to avoid that yet.
Last updated: Apr 12 2026 at 23:10 UTC