Skip to content
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

[js/web] WebGPU backend #11695

Closed
josephrocca opened this issue Jun 1, 2022 · 6 comments
Closed

[js/web] WebGPU backend #11695

josephrocca opened this issue Jun 1, 2022 · 6 comments
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template

Comments

@josephrocca
Copy link
Contributor

josephrocca commented Jun 1, 2022

Is your feature request related to a problem? Please describe.
CPU/Wasm inference is slow on larger models. If a device has a GPU and the model is large, then using the CPU is not a good choice. The WebGL runtime has three problems:

  1. It is much harder to get it working due to op and data-type support issues. Examples: 1, 2
  2. It is likely to be significantly slower than WebGPU.
  3. In my testing it is often unstable and can either throw an error that requires refreshing the tab to fix, or breaks WebGL across all tabs (requiring a browser restart) or even freezes my whole laptop. That said, this may just be specific to Ubuntu, or even my specific OS/hardware combination - I'm not sure. I'm guessing that in general it has to do with high memory usage.

Describe the solution you'd like
By far the most important requirement is that there is very strong op support, just like the Wasm backend. The broad op support is what sets ORT Web (Wasm backend) apart from tfjs, and some other web runtimes.

I still bump into ORT Web Wasm op support problems sometimes, but far less often than with other runtimes. I'm guessing this is due to the fact that the ops can be compiled from their C++/C/etc code rather than having to be re-written specifically for the web. I hope that the WebGPU backend would be able to do something similar, because otherwise I fear that lack of op support would make it far less useful. I am rarely able to get the WebGL backend working with my models because of op and data type support issues.

Might it be possible to set up some sort of conversion pipeline (perhaps via SPIR-V) to WGSL using Naga and similar tools? This is beyond my pay grade, so I'm just guessing here.

Describe alternatives you've considered
Seems like there are people already working on this: https://github.com/webonnx/wonnx But it is unfortunately not stable or op/feature-complete.

Additional context
WebGPU is behind a flag in Chrome, and is expected to ship by default in Chrome this year or early next year. It might be useful to start working on this now so that the ORT Web team can perhaps provide feedback on the WebGPU spec while there's an opportunity to make changes. The earlier the feedback, the easier it is to make changes to the spec which could be critical for getting maximum ML performance out of WebGPU.

@yuslepukhin yuslepukhin added component:ort-web platform:web issues related to ONNX Runtime web; typically submitted using template labels Jun 1, 2022
@fs-eire fs-eire added ep:WebGPU and removed platform:web issues related to ONNX Runtime web; typically submitted using template labels Jun 1, 2022
@fs-eire
Copy link
Contributor

fs-eire commented Jun 1, 2022

thanks very much for the feedback! the ORT web team is working on solving the pain points that listed above. We are also tracking the previous issues that you created (like to support ES6 module and web worker) in backlogs.

a big benefit of WebGPU is the compute shader, which is expected to be more efficient compared to the WebGL standard graphics rendering pipeline (vertex + frag shader). However, this also means the shaders need to be rewritten.

I have a branch (ongoing) for a prototype of webgpu backend. trying to support a few models soon.

@sophies927 sophies927 added platform:web issues related to ONNX Runtime web; typically submitted using template and removed component:ort-web labels Aug 12, 2022
@LancerComet
Copy link

thanks very much for the feedback! the ORT web team is working on solving the pain points that listed above. We are also tracking the previous issues that you created (like to support ES6 module and web worker) in backlogs.

a big benefit of WebGPU is the compute shader, which is expected to be more efficient compared to the WebGL standard graphics rendering pipeline (vertex + frag shader). However, this also means the shaders need to be rewritten.

I have a branch (ongoing) for a prototype of webgpu backend. trying to support a few models soon.

Thanks for your hard work! May I ask you that is there any plan or roadmap for WebGPU backend?

@fs-eire
Copy link
Contributor

fs-eire commented Jan 9, 2023

thanks very much for the feedback! the ORT web team is working on solving the pain points that listed above. We are also tracking the previous issues that you created (like to support ES6 module and web worker) in backlogs.
a big benefit of WebGPU is the compute shader, which is expected to be more efficient compared to the WebGL standard graphics rendering pipeline (vertex + frag shader). However, this also means the shaders need to be rewritten.
I have a branch (ongoing) for a prototype of webgpu backend. trying to support a few models soon.

Thanks for your hard work! May I ask you that is there any plan or roadmap for WebGPU backend?

WebGPU backend will be available in ONNX Runtime web as "experimental feature" in April 2023, and a continuous development will be on going to improve coverage, performance and stability. Detailed plan is still being worked on.

@xenova
Copy link
Contributor

xenova commented Apr 5, 2023

WebGPU backend will be available in ONNX Runtime web as "experimental feature" in April 2023

Hi! Just wanted to ask when this month we will be able to use the WebGPU backend? Looking forward to integrating it into Transformers.js!

@xenova
Copy link
Contributor

xenova commented Apr 6, 2023

Chrome is now shipping with WebGPU! https://developer.chrome.com/blog/webgpu-release/

Can't wait to see it working with onnxruntime-web...

@fs-eire
Copy link
Contributor

fs-eire commented May 15, 2023

I close this issue as WebGPU EP is currently merged into main branch. It still need time to become stable.

Please check the following links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:web issues related to ONNX Runtime web; typically submitted using template
Projects
None yet
Development

No branches or pull requests

6 participants