VowpalWabbit / vowpal_wabbit

Vowpal Wabbit is a machine learning system which pushes the frontier of machine learning with techniques such as online, hashing, allreduce, reductions, learning2search, active, and interactive learning.
https://vowpalwabbit.org
Other
8.49k stars 1.93k forks source link

VowpalWabbit WASM in a Cloudflare Worker #4704

Open tizmagik opened 1 week ago

tizmagik commented 1 week ago

Description

I'm looking to deploy VW WASM (via the JS bindings) in a Cloudflare Worker. There were a number of issues with the JS wrapper that prevented developing locally via Miniflare, but that's a separate issue. I was finally able to get something going locally by using Cloudflare's Vitest worker pool which runs the worker via workerd which is how it would be run in production -- however I get the following error:

failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder
Aborted(CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder)
RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): Wasm code generation disallowed by embedder). Build with -sASSERTIONS for more info.
    at abort (Users/developer/project/node_modules/.pnpm/@vowpalwabbit+vowpalwabbit@0.0.8/node_modules/@vowpalwabbit/vowpalwabbit/dist/vw-wasm.js?mf_vitest_no_cjs_esm_shim:9:5434)
    at Users/developer/project/node_modules/.pnpm/@vowpalwabbit+vowpalwabbit@0.0.8/node_modules/@vowpalwabbit/vowpalwabbit/dist/vw-wasm.js?mf_vitest_no_cjs_esm_shim:9:4274190

My assumption is this is due to Cloudflare disallowing WASM code generation

How to unblock?

Does VowpalWabbit publish the built WASM module anywhere? Or any insight on the above error and how I could work around it? Many thanks in advance!