Open birkskyum opened 11 months ago
WebGPU was recently added to Deno, opening up i.e. usage of GPU accelerated ML frameworks like tensorflow.js server-side. Would be cool to be able to do such things with bun as well.
There is an implementation of webgpu in webkit now.
Ref: https://webkit.org/blog/14879/webgpu-now-available-for-testing-in-safari-technology-preview/
We are unlikely to add WebGPU support to Bun in any official capacity until WebGPU is far more widely used. This is a great usecase for napi.
WebLLM uses wasm combined with webgpu. I’m not sure a node napi would suffice, but it might… I’ll have to see how they connect them.
Generally speaking, I think if bun had great ai primitives (or direct support for those that do) it would be a force multiplier.
WebGPU is not a great AI primitive, imo. It happens to work for that usecase, but it is not designed for that usecase. It would be better to support something designed for AI/LLMs, but it's unclear what that is right now
AI aside, it would be very relevant for server side rendering of webgpu still, such as unit testing for maplibre-gl, which currently has jest tests with webgl rendering (through headless-gl)
I'd love to see this in Bun too, at least once WebGPU ships unflagged in Webkit like it did in Chrome last year. This would be perfect for headless automated testing of 3D applications, e.g. ones that use Three.js or Babylon.js with WebGPU backend.
Examples of how this is used in Deno for reference: https://github.com/denoland/webgpu-examples/ And this is how a similar thing is set up with Puppeteer (but it's a bit involved and limited): https://developer.chrome.com/blog/supercharge-web-ai-testing
Is this function being developed?
What is the problem this feature would solve?
Unit testing / server rendering of webgpu canvas
What is the feature you are proposing to solve the problem?
I propose for bun to use an off-the-shelf webgpu implementation (like wgpu or dawn), to provide access to a DOM / canvas Web API.
What alternatives have you considered?
The alternative would be from bun to spawn playwright/puppeteer browser, inject the code there to run it in chromium, and then try to exact it into bun and use it in the bun test.