Live data from Hacker News

WebAssembly: Adding Python support to WASM language runtimes

wasmlabs.dev

11–20 of 88 posts

Re: WebAssembly: Adding Python support to WASM language runtimes

#13
post #4

So for someone who has python installed locally, what's the point? Is it just the sandbox or is there anything else I'm missing?

You get an extra layer of isolation, even at your development environment level.

I remember a NodeJs CVE that was caused by a poisoned dependency. It was affecting people when downloading it from npm.

There’s still a gap here to cover, but the benefits may be worth :)

Re: WebAssembly: Adding Python support to WASM language runtimes

#14
post #6
post #5

the issue right now with Python support in WASM (at least for machine learning, the main driver of the language) is that Python is largely a wrapper language and none the utilities that make it so powerful (numpy, PyTorch, JAX) work particularly well in wasm, since it's so limited performance-wise (no FMA, no GPU support). I'm excited for pairing wasm with WebGPU, which will likely unblock these projects from buildin…

I have integrated pyodide + webgpu recently. (you can do matmul using webgpu's compute pipeline). The real problem is that browser tabs have 4gb max memory size. So, training neural networks on this stack is almost impossible. ( I don't even want to mention pyTorch's dependency hell).

My claim is that it’s not easy, not impossible. There’s little incentive to hack in JavaScript or maintain a Pyodide compatible build. The 4gb limit isn’t a technical limitation, just a standards thing (it could change easily).

Re: WebAssembly: Adding Python support to WASM language runtimes

#15
post #3

This looks very promising! The thing I most want to solve right now is this: I want to write a regular Python application that can safely execute untrusted Python code in a WASM sandbox as part of its execution. I want to do this so I can let end users customize my web applications in weird and interesting ways by pasting their own Python code into a textarea - think features like "run this Python code to transform m…

The startup I'm working at is basically trying to do exactly that as a service, but a one-off thing for a regular Python application shouldn't be as hard to figure out as it is. Can you link to the Mastodon thread (darn lack of search!) and we can continue there?

Re: WebAssembly: Adding Python support to WASM language runtimes

#16
post #3

This looks very promising! The thing I most want to solve right now is this: I want to write a regular Python application that can safely execute untrusted Python code in a WASM sandbox as part of its execution. I want to do this so I can let end users customize my web applications in weird and interesting ways by pasting their own Python code into a textarea - think features like "run this Python code to transform m…

Have you tried to do it with pyodide? What issues did you hit using that?

Re: WebAssembly: Adding Python support to WASM language runtimes

#18
post #5

the issue right now with Python support in WASM (at least for machine learning, the main driver of the language) is that Python is largely a wrapper language and none the utilities that make it so powerful (numpy, PyTorch, JAX) work particularly well in wasm, since it's so limited performance-wise (no FMA, no GPU support). I'm excited for pairing wasm with WebGPU, which will likely unblock these projects from buildin…

I've come across this notion that nowadays machine learning provides (in some sense) the biggest group of Python users a few times recently.

What reason is there to suppose this is true? It seems surprising to me.

Re: WebAssembly: Adding Python support to WASM language runtimes

#19

The non-Docker version seems to require an external site-packages, unless I missed it. Is it possible to produce a single wasm binary with all dependencies compiled in?

Hey! Dev here :)

For external libraries, it requires you to mount the libraries with WASI when running the python.wasm module. Another option we're exploring is to use wasi-vfs[1] to include some common modules in our pre-built binaries. For example, Ruby does require some extra libraries for common workloads (like JSON parsing). This is still on the exploration phase, but we may do something with it.

[1] https://github.com/kateinoigakukun/wasi-vfs

Re: WebAssembly: Adding Python support to WASM language runtimes

#20
post #18
post #5

the issue right now with Python support in WASM (at least for machine learning, the main driver of the language) is that Python is largely a wrapper language and none the utilities that make it so powerful (numpy, PyTorch, JAX) work particularly well in wasm, since it's so limited performance-wise (no FMA, no GPU support). I'm excited for pairing wasm with WebGPU, which will likely unblock these projects from buildin…

I've come across this notion that nowadays machine learning provides (in some sense) the biggest group of Python users a few times recently. What reason is there to suppose this is true? It seems surprising to me.

It's really hard to do much ML in anything _except_ python. Virtually everyone improving the ML ecosystems of other language got their start in Python and are knowingly competing with Python (e.g. R, Julia). If you want to get started in ML today, python is the obvious easiest path forward.

So, most ML users are python users. I don't know how that group compares to non-ML python users, but I have a feeling there isn't a flood of eager new Django devs the way there is Pytorch users. Most non-ML things you could do with python can be done similarly well in Go/Rust/Typescript, but there's no other option for most ML stuff.

Post reply on HN