Skip to content

Enable multi-device WebGPU plugin routing - #32234

Open
Xiaofei Han (xiaofeihan1) wants to merge 2 commits into
microsoft:mainfrom
xiaofeihan1:webgpu-plugin-multi-device
Open

Enable multi-device WebGPU plugin routing#32234
Xiaofei Han (xiaofeihan1) wants to merge 2 commits into
microsoft:mainfrom
xiaofeihan1:webgpu-plugin-multi-device

Conversation

@xiaofeihan1

Copy link
Copy Markdown
Contributor

Description

Enable the WebGPU plugin EP to route distinct OrtEpDevice instances to distinct physical GPUs on Windows D3D12.

  • Assign a stable logical device ID and per-device OrtMemoryInfo to each discovered GPU.
  • Carry the Windows adapter LUID through EP metadata into WebGpuContext creation.
  • Select the matching Dawn adapter with RequestAdapterOptionsLUID and validate its vendor/device identity.
  • Cache and reference-count one WebGpuContext per logical device while continuing to share the Dawn instance.
  • Route shared allocators and data transfers by logical device ID, and reject direct cross-device GPU copies.
  • Keep non-D3D12 platforms on the existing single-default-adapter fallback.
  • Move WebGPU allocator coverage into a dedicated AutoEP test file, including a disabled manual dual-GPU memory/compute test.

Testing

  • onnxruntime_autoep_test: 92/92 passed
  • WebGpuPluginSharedAllocatorTest.*:SharedAllocators.*: 7/7 passed
  • Manual dual-GPU load: NVIDIA and Intel each allocated 512 MiB and completed inference
  • ONNX Runtime Web WebGPU WASM Release build completed
  • Edge WebGPU browser smoke tests: 3/3 passed
  • Lintrunner and git diff --check: passed

@xiaofeihan1
Xiaofei Han (xiaofeihan1) marked this pull request as ready for review August 24, 2026 07:52
Copilot AI balanced review requested due to automatic review settings August 24, 2026 07:52

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

Enables WebGPU plugin routing to distinct Windows D3D12 GPUs using logical device IDs and adapter LUIDs.

Changes:

  • Adds per-device discovery metadata, memory information, and Dawn adapter selection.
  • Caches contexts and routes allocators/transfers by logical device ID.
  • Adds dedicated allocator and manual multi-GPU tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
onnxruntime/test/autoep/test_webgpu_allocators.cc Adds WebGPU allocator, transfer, and manual multi-GPU tests.
onnxruntime/test/autoep/test_allocators.cc Adjusts includes alongside extracted tests.
onnxruntime/core/providers/webgpu/webgpu_provider_options.h Defines adapter identity configuration keys.
onnxruntime/core/providers/webgpu/webgpu_provider_factory.cc Parses adapter metadata and routes transfers per device.
onnxruntime/core/providers/webgpu/webgpu_context.h Extends context configuration and retention APIs.
onnxruntime/core/providers/webgpu/webgpu_context.cc Selects and validates Dawn adapters by LUID.
onnxruntime/core/providers/webgpu/ep/factory.h Introduces per-device factory state.
onnxruntime/core/providers/webgpu/ep/factory.cc Enumerates devices and creates routed allocators and EPs.

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

Comment on lines +489 to +495
if (src_is_gpu && dst_is_gpu && src_device_id != dst_device_id) {
return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT,
"WebGPU does not support direct copies between different devices.");
}
const int tensor_context_id = src_is_gpu ? src_device_id : dst_device_id;
if (tensor_context_id < 0 || (impl.context_id_ >= 0 && tensor_context_id != impl.context_id_)) {
return OrtApis::CreateStatus(ORT_INVALID_ARGUMENT, "Invalid WebGPU device for tensor copy.");
Comment on lines +187 to +190
#if defined(_WIN32) && defined(DAWN_ENABLE_D3D12)
auto adapter_luid = GetHardwareDeviceLuid(*devices[i]);
if (adapter_luid.has_value()) {
candidates.push_back({devices[i], adapter_luid});
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.

2 participants