Skip to content

[WebGPU] User-provided GPUDevice fails when waiting for GPU work #32257

Description

Describe the issue

Passing a user-created GPUDevice through executionProviders: [{name: 'webgpu', device}] allows session creation, but inference fails when ORT downloads a GPU output to CPU. Error: BufferManager::Download ... Failed to wait for the operation:3.

Reproduce website https://xiaofeihan1.github.io/ort-webgpu-device-version-test/

Reproduction

const adapter = await navigator.gpu.requestAdapter();
const device = await adapter.requestDevice();

const session = await ort.InferenceSession.create('model.onnx', {
    executionProviders: [{ name: 'webgpu', device }]
});

// Runs a small MatMul model whose output is returned to CPU
const results = await session.run(inputs);

Expected behavior

The provided device works for session creation and inference, including CPU output download.

Root cause

Emscripten's WebGPU.importJsDevice() associates the device with the supplied WGPUInstance. ORT used a default-created instance that did not enable WGPUInstanceFeatureName_TimedWaitAny, while WebGPU EP synchronous buffer download calls wgpuInstanceWaitAny() with a timeout.

Validation

A browser E2E regression using a user-provided GPUDevice and real inference fails on unmodified main with the error above and passes after creating the import instance with TimedWaitAny enabled.

Mention that #26107 is related but different: it covers device selection/ignored device and external-buffer ownership, while this issue is synchronization failure after the custom device is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api:Javascriptissues related to the Javascript APIep:WebGPUort-web webgpu providerplatform:webissues related to ONNX Runtime web; typically submitted using template

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions