Skip to content

[WebGPU] Add robustness provider option - #31971

Open
Jiajia Qin (qjia7) wants to merge 2 commits into
microsoft:mainfrom
qjia7:webgpu-enable-robustness-option
Open

[WebGPU] Add robustness provider option#31971
Jiajia Qin (qjia7) wants to merge 2 commits into
microsoft:mainfrom
qjia7:webgpu-enable-robustness-option

Conversation

@qjia7

@qjia7 Jiajia Qin (qjia7) commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • Adds the WebGPU enableRobustness provider option to control Dawn robust buffer access for ORT-created devices.
  • Exposes the boolean option through the shared JavaScript type surface for the native Node.js WebGPU binding.
  • Keeps robustness independent from validationMode and preserves build-specific defaults: enabled in Debug, disabled in Release and RelWithDebInfo.
  • Handles the process-global WebGPU device lifecycle: the first created device establishes the value; later conflicts and requests for external devices are ignored with a warning.
  • Does not forward the option through browser/WASM WebGPU, where standard WebGPU APIs cannot configure Dawn toggle chains.
  • Adds focused native coverage for explicit values, defaults, invalid input, validation independence, conflicts, compile-only contexts, and external devices.

Motivation and Context

Dawn buffer robustness is a device-creation setting that is separate from validation. ONNX Runtime previously enabled Dawn's disable_robustness toggle unconditionally, so native users could not request robust buffer access or configure the safety/performance tradeoff independently.

This change exposes that choice for native WebGPU device creation while making the shared-device behavior explicit. It keeps the performance-oriented non-Debug default and enables the safer Debug default.

Testing

  • build\Windows\Release\Release\onnxruntime_provider_test.exe --gtest_filter=WebGpuContextTest.* (8 tests passed)
  • npm run prebuild --prefix js/web
  • npx prettier --check common/lib/inference-session.ts web/lib/wasm/session-options.ts web/test/test-types.ts

@qjia7
Jiajia Qin (qjia7) marked this pull request as draft August 11, 2026 02:40
@qjia7
Jiajia Qin (qjia7) force-pushed the webgpu-enable-robustness-option branch from d8bd11b to 53ba453 Compare August 11, 2026 02:57
@qjia7
Jiajia Qin (qjia7) marked this pull request as ready for review August 11, 2026 03:33
@qjia7
Jiajia Qin (qjia7) requested a lite review from Copilot August 11, 2026 03:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new WebGPU execution provider option, enableRobustness, to control Dawn robust buffer access when ONNX Runtime creates the WebGPU device (native/Node.js scenarios). It wires the option through the WebGPU context configuration, makes behavior explicit for the shared-device lifecycle, and adds native tests to validate defaults, explicit settings, and conflict handling.

Changes:

  • Added ep.webgpuexecutionprovider.enableRobustness config key with Debug/Release defaults and explicit parsing/validation.
  • Updated WebGPU device toggle selection so robust buffer access is controlled via Dawn’s disable_robustness toggle (enabled or explicitly disabled).
  • Exposed enableRobustness in the Node.js binding option parsing and in the shared JS TypeScript type surface; added native unit tests covering key scenarios.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
onnxruntime/test/providers/webgpu/webgpu_context_test.cc Adds unit tests verifying robustness toggles, defaults, invalid values, compile-only behavior, conflict warnings, and external-device ignore behavior.
onnxruntime/core/providers/webgpu/webgpu_provider_options.h Defines the new config key and "0"/"1" value constants for robustness.
onnxruntime/core/providers/webgpu/webgpu_provider_factory.cc Parses enableRobustness from config options, validates values, and logs the resolved setting.
onnxruntime/core/providers/webgpu/webgpu_context.h Adds robustness fields to WebGpuContextConfig with build-specific defaults and exposes Instance() for test/support usage.
onnxruntime/core/providers/webgpu/webgpu_context.cc Stores robustness setting on initialization, emits warnings for conflicts/external devices, and applies robustness via enabled/disabled Dawn toggles.
js/node/src/session_options_helper.cc Accepts enableRobustness as a boolean for the WebGPU EP in Node.js and maps it to "1"/"0".
js/common/lib/inference-session.ts Documents and exposes enableRobustness?: boolean on the shared JS WebGPU options type surface (noted as Node-only behavior).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@qjia7

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ep:WebGPU ort-web webgpu provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants