Skip to content

[Framework] Report missing or unavailable execution backends - #33957

Merged
Sushanth Rajasankar (sushraja-msft) merged 3 commits into
mainfrom
user/sushraja/webgpu-provider-assignment-errors
Nov 13, 2026
Merged

Sushanth Rajasankar (sushraja-msft) merged 3 commits into
mainfrom
user/sushraja/webgpu-provider-assignment-errors

Conversation

@sushraja-msft

@sushraja-msft Sushanth Rajasankar (sushraja-msft) commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What changes

Return a clear error when an operation has no assigned execution backend, or names a backend that is not registered, instead of failing while preparing data copies. This prevents cases where ops could not be assigned an ep from crashing the browser GPU process when ORT WebGPU is used as the backend for webnn.

The error identifies the affected node. Unsupported operations return NOT_IMPLEMENTED; invalid backend names return INVALID_ARGUMENT. Validation happens before copy nodes are inserted. Valid CPU-assigned nodes keep their existing behavior.

ModifyGraph now returns Status and reports graph modification through a bool& output parameter. Assignment checks run in its existing initial node scan, before collecting each node's copy requirements; there is no separate validation traversal in ApplyImpl. ApplyImpl propagates failures with ORT_RETURN_IF_ERROR. These are internal helper changes, with no public API/ABI change. The existing non-CPU-provider guard and subgraph recursion remain unchanged.

Native tests

3 tests passed, with no skips, after the refactor. They cover an unassigned node, an unavailable named backend, an unchanged valid CPU-assigned node, and successful CPU-to-GPU-to-CPU copy insertion with modified == true. Invalid assignments are tested after an earlier valid GPU-assigned node has been processed; node assignments and connections remain unchanged on failure.

Regression-sensitivity checks used disposable faulty source copies with the unchanged tests. Dropping the modification flag, omitting a GPU-to-CPU copy, and changing an earlier valid node's assignment each failed the intended assertion. The production source was then rebuilt and all three tests rerun successfully.

From an existing Release build configured with WebGPU:

cmake --build build\latest-webgpu\Release --target onnxruntime_test_all --parallel 8
Push-Location build\latest-webgpu\Release
.\onnxruntime_test_all.exe --gtest_filter=TransformerTest.MemcpyTransformer*
Pop-Location

The tests use a small test backend and do not depend on GPU hardware.

Sushanth Rajasankar and others added 2 commits November 6, 2026 13:06
Reject unassigned nodes and unknown execution providers before inserting
device copies, instead of reaching a fatal memcpy-transformer invariant.
Cover invalid assignments and a valid CPU assignment without GPU hardware.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Return Status and a separate modification flag from the memcpy helper.
Validate assignments in its existing scan before graph mutation, avoiding
a second traversal. Cover late invalid assignments and successful
host/device copy insertion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sushraja-msft
Sushanth Rajasankar (sushraja-msft) force-pushed the user/sushraja/webgpu-provider-assignment-errors branch from 433de07 to e640bd3 Compare November 9, 2026 03:51
@sushraja-msft
Sushanth Rajasankar (sushraja-msft) marked this pull request as ready for review November 9, 2026 04:14
Copilot AI balanced review requested due to automatic review settings November 9, 2026 04:14

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.

🟢 Approval recommended

No active review issues are recorded for the execution-provider diagnostics change.

No open issues 🎉

What changed in this PR

Improves execution-provider diagnostics in the memcpy graph transformer so invalid node assignments return clear errors before copy nodes are inserted.

Changes:

  • Returns node-specific NOT_IMPLEMENTED errors for unassigned nodes and INVALID_ARGUMENT errors for unregistered providers.
  • Refactors the internal ModifyGraph helper to return Status and report modifications through a bool&.
  • Adds hardware-independent tests for invalid assignments, unchanged CPU nodes, and successful CPU–GPU copy insertion.
File Description
onnxruntime/​test/​framework/​memcpy_transformer_test.cc Adds a test provider and regression coverage for assignment validation and copy insertion.
onnxruntime/​core/​optimizer/​transformer_memcpy.cc Validates provider assignments during the initial scan and propagates errors through Status.

Review effort: Balanced

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.

🟢 Approval recommended

No active review issues remain for the memcpy transformer's provider-assignment validation changes.

No open issues 🎉

Review effort: Balanced

Recognize the new missing-execution-provider status for unsupported Reshape and Unsqueeze types while preserving existing rejection checks.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sushraja-msft

Copy link
Copy Markdown
Contributor Author

Copilot update on behalf of Sushanth Rajasankar (@sushraja-msft) (human owner; @mention them for human follow-up): fixed the Web Debug/Release CI failures in 312bfcc. Unsupported Reshape/Unsqueeze sessions now return the new recoverable missing-provider diagnostic, which the negative-test allowlist did not recognize. The added check is operator-specific and does not accept arbitrary errors or successful session creation. It deliberately does not require the model opset number because the diagnostic reports the resolved operator schema version.

Validation: using the failing-head Release WASM artifact, the focused browser suite changed from 110 passed / 16 failed / 16 skipped to 126 passed / 0 failed / 16 skipped. Skips are float16 cases unsupported by the local GPU. TypeScript, targeted ESLint/Prettier, lintrunner -a, and whitespace checks passed. Debug browser execution and the full Web suite were not rerun locally; new-head CI remains pending.

@sushraja-msft
Sushanth Rajasankar (sushraja-msft) merged commit 27d11c0 into main Nov 13, 2026
102 of 103 checks passed
@sushraja-msft
Sushanth Rajasankar (sushraja-msft) deleted the user/sushraja/webgpu-provider-assignment-errors branch November 13, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants