-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[js/web] Add Wasm Relaxed SIMD support to wasm backend #22794
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
Conversation
Hi, @fs-eire , would you please take a look? |
sorry, in my queue but have not gotten to it |
I am trying this patch, I have built a small demo to compare relaxed vs non relaxed in Firefox Nightly. https://github.com/tarekziade/onnx-relaxed-simd So far I am not seeing any difference, digging... |
So I forced Is this patch for x86 only? |
If this patch is trying to exploit Please confirm if this the case. |
Yes this patch is currently for x86 with AVX-VNNI only. The check (maybe a similar |
Yes... The patch uses a check My local experiment shows ~1.15x performance for SAM model, and this is the best way I can think of to make use of the native AI HW capabilities in the world of Wasm. Actually XNNPACK also uses |
Thanks @jing-bao for the feedback. I tried on my AMD Ryzen Threadripper PRO (x86_64) and I get some errors, unrecognized opcode fd113 for my summarizer demo. Maybe the way I compiled it was not right? I used those flags to compile
and pushed the builds to https://github.com/tarekziade/onnx-relaxed-simd/tree/main Do you have your example available somehwere so I can try it? maybe the model I used triggers specific opcodes |
Hi @tarekziade , The build flags seem OK. This error looks like that the relaxed-simd opcode |
This is in Firefox Nightly 134. I see it defined in our code base https://searchfox.org/mozilla-central/source/third_party/rust/wast/src/core/expr.rs#1189 @yurydelendik do you know if we have partial implementation there? |
For sure |
Hi @fs-eire and @tarekziade, I updated the code to add |
Thanks, looking this week |
/azp run ONNX Runtime Web CI Pipeline,Windows GPU CI Pipeline,Linux Android Emulator QNN CI Pipeline |
/azp run Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,Linux OpenVINO CI Pipeline,Linux QNN CI Pipeline,MacOS CI Pipeline,Windows ARM64 QNN CI Pipeline,Windows CPU CI Pipeline |
/azp run Windows GPU TensorRT CI Pipeline,onnxruntime-binary-size-checks-ci-pipeline,orttraining-linux-ci-pipeline,orttraining-linux-gpu-ci-pipeline,orttraining-ortmodule-distributed,Windows x64 QNN CI Pipeline,Big Models |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run Windows GPU CUDA CI Pipeline,Windows GPU DML CI Pipeline,Windows GPU Doc Gen CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI |
Azure Pipelines successfully started running 4 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 4 pipeline(s). |
Azure Pipelines successfully started running 9 pipeline(s). |
Hi, just a gentle reminder to check if there are any follow-ups needed from my side. Thanks! |
Hi @fs-eire , any follow-ups needed from my side? Thanks! |
Azure Pipelines successfully started running 9 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 9 pipeline(s). |
Close the PR and re-open to trigger the github builds. |
/azp run Windows GPU WebGPU CI Pipeline, Linux ROCm CI Pipeline, Windows ARM64 QNN CI Pipeline |
Azure Pipelines successfully started running 2 pipeline(s). |
Thanks @fs-eire! Do I need other reviewers for MLAS changes? |
@liqunfu @fajin-corp can you review the proposed changes to mlas files? |
A soft reminder @liqunfu @fajin-corp. Thanks! |
Close and re-open to trigger the pipeline |
/azp run Windows ARM64 QNN CI Pipeline,Windows x64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline,ONNX Runtime Web CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,Linux OpenVINO CI Pipeline |
/azp run Linux QNN CI Pipeline,onnxruntime-binary-size-checks-ci-pipeline,Big Models,Linux Android Emulator QNN CI Pipeline,Android CI Pipeline,iOS CI Pipeline,ONNX Runtime React Native CI Pipeline,Linux DNNL CI Pipeline,Linux MIGraphX CI Pipeline,Linux ROCm CI Pipeline |
Azure Pipelines successfully started running 7 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 7 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this PR is good to merge:
- all critical pipelines including the old Web CI and the new (github actions based) Web CI are passing. there are failing CIs but those are the ones under migration, while the old ones are passing.
- The MLAS part is generally new code and modification to existing code is guarded by macros so it should be safe for existing users.
thanks for the contribution. @jing-bao
### Description This PR revised the flag `ort.env.wasm.simd` to enhance its usage so that more use scenarios are covered. - Allow setting to `false` explicitly to disable SIMD checking. resolves #24292 (@Eldow) - Allow setting to `'relaxed'` to enable Relaxed SIMD checking. Relaxed SIMD is introduced first in #22794 (@jing-bao) - Behavior is not changed when not setting (ie. `undefined`) or setting to `true` - Added a warning message when setting to unknown value, and reset to `false` in this case
### Description <!-- Describe your changes. --> Add Wasm Relaxed SIMD support. Use integer dot product instructions for QGemmU8X8. 1. Build with --enable_wasm_relaxed_simd 2. Use env.wasm.relaxedSimd to run it ### Motivation and Context microsoft#22533 --------- Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>
### Description This PR revised the flag `ort.env.wasm.simd` to enhance its usage so that more use scenarios are covered. - Allow setting to `false` explicitly to disable SIMD checking. resolves microsoft#24292 (@Eldow) - Allow setting to `'relaxed'` to enable Relaxed SIMD checking. Relaxed SIMD is introduced first in microsoft#22794 (@jing-bao) - Behavior is not changed when not setting (ie. `undefined`) or setting to `true` - Added a warning message when setting to unknown value, and reset to `false` in this case
Description
Add Wasm Relaxed SIMD support.
Use integer dot product instructions for QGemmU8X8.
Motivation and Context
#22533