[WebGPU] Make max_num_pending_dispatches configurable#28894
Conversation
|
@microsoft-github-policy-service agree |
d49fc3a to
7df5bf7
Compare
There was a problem hiding this comment.
Pull request overview
This PR makes the WebGPU Execution Provider’s maximum number of pending dispatches configurable via a new provider option (ep.webgpuexecutionprovider.maxNumPendingDispatches), instead of being hardcoded to 16, while preserving the existing default behavior.
Changes:
- Added a new WebGPU provider option key for
maxNumPendingDispatches. - Parsed the option into
WebGpuContextConfigand applied it duringWebGpuContextone-time initialization (with a warning if a different value is later requested for an already-initialized context). - Added a WebGPU Expand test that supplies the new option and verifies execution succeeds with a custom value.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| onnxruntime/test/providers/cpu/tensor/expand_test.cc | Adds a WebGPU execution test that passes the new provider option. |
| onnxruntime/core/providers/webgpu/webgpu_provider_options.h | Defines the new provider option key constant. |
| onnxruntime/core/providers/webgpu/webgpu_provider_factory.cc | Parses maxNumPendingDispatches into WebGpuContextConfig and logs it. |
| onnxruntime/core/providers/webgpu/webgpu_context.h | Extends WebGpuContextConfig and makes the context’s max pending dispatches configurable. |
| onnxruntime/core/providers/webgpu/webgpu_context.cc | Applies the configured value during one-time context initialization and warns on mismatched reinit requests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7df5bf7 to
21efc5d
Compare
|
The changes look good to me. Let’s see if Hari has any additional comments. Thanks. |
21efc5d to
6158924
Compare
|
Fixed the formatting issue reported by the lint checks. |
|
Hi @hariharans29, just a gentle ping on this PR when you have a chance. |
Review of PR #28894 —
|
6158924 to
81d3409
Compare
|
@hariharans29 Thanks for the detailed review. Good catch on the synchronization issue around the pre- |
Re-review — PR #28894Verdict: approve. Commit 81d3409 addresses both substantive concerns from the prior pass exactly as requested. What got fixed
What didn't changeThe two optional items I flagged are still as-is, and that's fine:
Bottom lineShip it. Net code reduction (+63/-1 vs the previous +66/-1) on top of an already small PR. Approve and merge once the remaining CI rebuild settles. |
Description
Adds support for configuring the WebGPU execution provider's maximum number of pending dispatches via a provider option.
Previously,
WebGpuContext::max_num_pending_dispatches_was hardcoded to16. This change introduces a new WebGPU provider option:ep.webgpuexecutionprovider.maxNumPendingDispatchesThe value is parsed into
WebGpuContextConfigand applied duringWebGpuContextinitialization, while preserving the existing default value of16.A WebGPU execution test was also added to verify that the new provider option can be supplied successfully and that execution proceeds correctly with a custom value.
Testing
Built ONNX Runtime with WebGPU enabled.
Ran:
ExpandOpTest.Expand_3x3_int64_webgpu_max_num_pending_dispatchesExpandOpTest.*webgpu*All tests passed.
Motivation and Context
Fixes #28613.
Some devices may achieve better inference performance with a different pending dispatch limit. This change makes the existing hardcoded value configurable without changing the default behavior.