-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Correct check for WebGPU support #18144
Conversation
Just testing for the presence of navigator.gpu is not sufficient to establish WebGPU support: in particular, at time of writing, Chrome on Android exposes a navigator.gpu but does not return anything from requestAdapter. Context: microsoft#15796 (comment)
/azp run ONNX Runtime Web 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 |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run Windows GPU CI Pipeline,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 |
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
Azure Pipelines successfully started running 1 pipeline(s). |
@qjia7 and I had some discussion about the fix today and we're working on a better fix. Please hold the merge of this one. |
When doing session creation, onnxruntime selects the highest priority backend that is available during resolveBackend, then use this selected backend to init. The code change here already happens at WebGPU backend init stage, which is too late. |
### Description This PR revises the backend registration. The following describes the expected behavior after this change: (**bolded are changed behavior**) - (ort.min.js - built without webgpu support) - loading: do not register 'webgpu' backend - creating session without EP list: use default EP list ['webnn', 'cpu', 'wasm'] - creating session with ['webgpu'] as EP list: should fail with backend not available - (ort.webgpu.min.js - built with webgpu support) - loading: **always register 'webgpu' backend** ( previous behavior: only register 'webgpu' backend when `navigator.gpu` is available) - creating session without EP list: use default EP list ['webgpu', 'webnn', 'cpu', 'wasm'] - when WebGPU is available (win): use WebGPU backend - when WebGPU is unavailable (android): **should fail backend init,** and try to use next backend in the list, 'webnn' (previous behavior: does not fail backend init, but fail in JSEP init, which was too late to switch to next backend) - creating session with ['webgpu'] as EP list - when WebGPU is available (win): use WebGPU backend - when WebGPU is unavailable (android): **should fail backend init, and because no more EP listed, fail. related PRs: #18190 #18144
close this as an alternative solution #18715 is merged. |
### Description This PR revises the backend registration. The following describes the expected behavior after this change: (**bolded are changed behavior**) - (ort.min.js - built without webgpu support) - loading: do not register 'webgpu' backend - creating session without EP list: use default EP list ['webnn', 'cpu', 'wasm'] - creating session with ['webgpu'] as EP list: should fail with backend not available - (ort.webgpu.min.js - built with webgpu support) - loading: **always register 'webgpu' backend** ( previous behavior: only register 'webgpu' backend when `navigator.gpu` is available) - creating session without EP list: use default EP list ['webgpu', 'webnn', 'cpu', 'wasm'] - when WebGPU is available (win): use WebGPU backend - when WebGPU is unavailable (android): **should fail backend init,** and try to use next backend in the list, 'webnn' (previous behavior: does not fail backend init, but fail in JSEP init, which was too late to switch to next backend) - creating session with ['webgpu'] as EP list - when WebGPU is available (win): use WebGPU backend - when WebGPU is unavailable (android): **should fail backend init, and because no more EP listed, fail. related PRs: microsoft#18190 microsoft#18144
Description
Augments the naive check for
navigator.gpu
with anawait navigator.gpu.requestAdapter
in jsep'sComputeContextImpl
.Motivation and Context
Just testing for the presence of
navigator.gpu
is not sufficient to establish WebGPU support: in particular, at time of writing, Chrome on Android exposes a navigator.gpu but does not return anything from requestAdapter.Context:
#15796 (comment)