-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Experiment] WebGPU backend #1789
base: main
Are you sure you want to change the base?
Conversation
@zcbenz that's extremely cool. I'm supportive of exploring the addition of WebGPU as a back-end for MLX. One initial comment is it would be nice to avoid breaking the "unified memory" programming model. So instead of changing the array API.. it might make more sense to change the WebGPU specific allocator (and maybe kernels) to have a This actually fits pretty well with our notion of I'm also very curious to know If there are any other major internal API changes needed or if mostly it just plugs in without much difficulty. |
Thanks for your support! What do you think if we add a "null" backend in upstream that mimics the general gpu backend by copying data to a separate buffer and then just calls |
If you a share a PR for what you mean it might be easier to say if this is something we could include upstream. I'm not sure we necessarily need to merge it though.. it seems like it could be ok to just have a fork / branch of this for now until we converge a bit on what's useful there. |
@awni I have updated the code to use a custom allocator to create data the holds both CPU and GPU buffers, can you do a simple review? There are also 2 allocator design decisions that need your help:
|
This PR adds an experiment WebGPU backend which only has support for binary ops, this is not something aimed to be merged, it only means to show the possibility.
The actual shaders and WebGPU API calls are put in a separate project: https://github.com/frost-beta/betann.
To build:
Run the example: