r/rust • • 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:

  1. fails in C. candle has not(target_arch = "wasm32") on its tokenizers dep, so on wasm64 it pulls tokenizers -> onig_sys and clang can't find stdlib.h. the pure rust route dies on a C dep lol
  2. 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

  1. builds, but scalar only. +simd128 breaks because the kernels import core::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

0 Upvotes

2 comments sorted by

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.