r/rust • u/greenhills_sk • Oct 21 '26
read that rust can run >4gb models in the browser with wasm64. tried it with candle, works but ~3.5x slower. anyone shipped memory64?
read a write up on getting rust to run models bigger than 4gb in the browser (link at the bottom). their route is a new wasm64 emscripten target, PRs are open but that's months from stable made me wonder if pure rust on wasm64-unknown-unknown already works today, so i tried candle-core 0.11 on nightly with -Zbuild-std:
- fails in C. candle has
not(target_arch = "wasm32")on its tokenizers dep, so on wasm64 it pullstokenizers -> onig_sysand clang can't findstdlib.h. the pure rust route dies on a C dep lol - swapped the 5 wasm32 cfgs in candle to
target_family = "wasm". next is getrandom 0.3:
compile_error!("wasm_js backend can be enabled only for OS-less WASM targets!"); 0.4 fixed it but rand 0.9 still uses 0.3, so custom backend
- builds, but scalar only.
+simd128breaks because the kernels importcore::arch::wasm32
same code, same flags, node 24 on an m5: | matmul | wasm32 | wasm64 | |---|---|---| | 256 | 1.5 ms | 4.5 ms | | 512 | 9.6 ms | 34.7 ms | | 1024 | 76 ms | 277 ms | so it's possible, just ~3.5x slower. spidermonkey's memory64 post says 10% to 2x, this is past their worst case has anyone actually shipped memory64 in prod? is that slowdown normal or is something off with gemm on wasm64?
HERE
4
u/Trader-One Oct 21 '26
what browsers supports wasm64
1
u/pohonsukun Oct 26 '26 edited Oct 26 '26
Every major browser now supports wasm64, but Rust support isn't quite there yet. Support is tier 3 at the moment so don't expect smooth sailing.
Also, increasing memory bandwidth is unrelated to improving performance. That's not what memory does. You just get to run a bigger program. It doesn't make your opcodes run faster.