6 ms·
Mmm… The wasm-nn that this relies on (https://github.com/WebAssembly/wasi-nn https://github.com/WebAssembly/wasi-nn) is a proposal that relies on sending arbit
by wokwokwok 3y ago
Mmm…
The wasm-nn that this relies on (https://github.com/WebAssembly/wasi-nn https://github.com/WebAssembly/wasi-nn) is a proposal that relies on sending arbitrarily chunks to some vendor implementation. The api is literally like set input, compute, set output.
…and that is totally non portable.
The reason this works, is because it’s relying on the abstraction already implemented in llama.cpp that allows it to take a gguf model and map it to multiple hardware targets,which you can see has been lifted as-is into WasmEdge here: https://github.com/WasmEdge/WasmEdge/tree/master/plugins/wasi_nn/thirdparty/ggml https://github.com/WasmEdge/WasmEdge/tree/master/plugins/was...
So..
> Developers can refer to this project to write their machine learning application in a high-level language using the bindings, compile it to WebAssembly, and run it with a WebAssembly runtime that supports the wasi-nn proposal, such as WasmEdge.
Is total rubbish; no, you can’t.
This isn’t portable.
It’s not sandboxed.
It’s not a HAL.
If you have a wasm binary you might be able to run it if the version of the runtime you’re using happens to implement the specific ggml backend you need, which it probably doesn’t… because there’s literally no requirement for it to do so.
…and if you do, you’re just calling the llama.cpp ggml code, so it’s as safe as that library is…
There’s a lot of “so portable” and “such rust” talk in this article which really seems misplaced; this doesn’t seem to have the benefits of either of those two things.
Let’s imagine you have some new hardware with a WASI runtime on it, can you run your model on it? Does it have GPU support?
Well, turns out the answer is “go and see if llama.cpp compiles on that platform with GPU support and if the runtime you’re using happens have a ggml plugin in it and happens to have a copy of that version of ggml vendored in it, and if not, then no”.
..at which point, wtf are you even using WASI for?
Cross platform GPU support is hard, but this… I dunno. It seems absolutely ridiculous.
Imagine if webGPU was just “post some binary chunk to the GPU and maybe it’ll draw something or whatever if it’s the right binary chunk for the current hardware.”
That’s what this is.
- ikurei 3y agoCould you please elaborate on the security implications?
- wokwokwok 3y agoIt’s as secure as any C++ backend that performs no input validation. Ie. whatever memory safety or sandbox you had from using wasm or rust is gone when you use it.
- jart 3y agoThe llama.cpp author thinks security is "very low priority and almost unnecessary". https://github.com/ggerganov/llama.cpp/pull/651#pullrequestreview-1368052138 https://github.com/ggerganov/llama.cpp/pull/651#pullrequestr... So I'm not sure why a sandbox would bundle llama.cpp and claim to be secure. They would need more evidence than this to make such a claim.
- halyconWays 3y agoThis user was caught stealing code and banned from llama.cpp by its creator https://news.ycombinator.com/item?id=35411909 https://news.ycombinator.com/item?id=35411909
- anentropic 3y agoThanks for clarifying, I was wondering where there were getting GPU support in WASM from...