Skip to content

Make shared WebGPU data transfers stateless - #33208

Merged
Mustapha Jaber (mustjab) merged 1 commit into
mainfrom
fix/webgpu-stateless-shared-transfer
Oct 9, 2026
Merged

Mustapha Jaber (mustjab) merged 1 commit into
mainfrom
fix/webgpu-stateless-shared-transfer

Conversation

@mustjab

@mustjab Mustapha Jaber (mustjab) commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to the review of #33110.

The shared WebGPU data-transfer wrapper does not need to own a context. A session stream already supplies its owning execution provider's transfer state, while a streamless copy can select its registered context from the GPU tensor's memory-device ID.

  • Remove the cached context, initialization mutex, and context-ID argument from the internal transfer creator.
  • Route session copies directly through their stream. Retain the tensor-selected registered context only for each streamless copy, including context zero, and flush successful streamless GPU-to-GPU copies.
  • Document that memory-device identity does not register Dawn objects, the current Env/global allocator context-zero restriction, and the registration requirements for external-context copies.

Allocator/session context IDs and the public C API are unchanged. This does not add pre-session external-context registration.

Validation

  • Scoped C++ lintrunner and staged whitespace checks passed.
  • Fresh Windows x64 Release external-Dawn plugin build on upstream main 864d87126864c64651f58a9b51d9006ad71b2c78 passed.
  • All five native-host modes passed against the fresh ORT/plugin DLLs: baseline, host-device, missing-sync, callback-failure, and missing-proc-table. The host executable was reused after verifying its source was unchanged.
  • Host-device coverage includes coexisting default/external context allocation and transfers, shader-cache reuse/isolation, and device usability after ORT teardown. Negative modes rejected invalid inputs or contained callback failures as expected.
  • The same follow-up also passed the five host modes in both built-in and plugin configurations before rebasing onto current main.

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

The stateless lifecycle and routing changes are internally consistent and covered by existing multi-context transfer validation.

0 open findings

What changed in this PR

Makes shared WebGPU transfers stateless while preserving context-correct routing and lifecycle behavior.

Changes:

  • Routes session copies through their WebGPU streams.
  • Retains tensor-selected contexts only during streamless copies and flushes GPU-to-GPU copies.
  • Documents external-context registration requirements.

No actionable findings identified.

File Description
webgpu_provider_factory.cc Removes cached transfer context and implements per-copy routing.
webgpu_provider_factory_creator.h Updates the internal transfer creator contract.
ep/​factory.cc Adopts the context-free creator.
WebGPU_External_Dawn.md Documents memory identity and context registration constraints.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mustjab
Mustapha Jaber (mustjab) marked this pull request as ready for review October 8, 2026 18:46
@mustjab
Mustapha Jaber (mustjab) merged commit ac44e16 into main Oct 9, 2026
@mustjab
Mustapha Jaber (mustjab) deleted the fix/webgpu-stateless-shared-transfer branch October 9, 2026 04:19
Edward Chen (edgchen1) added a commit that referenced this pull request Oct 14, 2026
### Description
<!-- Describe your changes. -->

This cherry-picks the following commits for the release:

| Commit ID | PR Number | Commit Title |
|-----------|-----------|-------------|
| ac44e16 | #33208 | Make shared WebGPU data transfers stateless |
| 6e0f154 | #33082 | [WebGPU] Restore ORT 1.24.4 compatibility with
per-Session recording and serialized execution |

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

WebGPU EP 0.5.0 release preparation.

---------

Co-authored-by: Mustapha Jaber <mustjab@users.noreply.github.com>
Co-authored-by: Xiaofei Han <xiaofeihan@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b6fbaacb-9846-4330-8fb3-2f0b13737d48
Copilot-Session: 8ca4e5fc-8c08-46bd-82a9-5cff5108efed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂ 换网址