Skip to content

[WebGPU] Fix initializer upload on GPUs without Resizable BAR - #32816

Merged
Jiajia Qin (qjia7) merged 1 commit into
microsoft:mainfrom
SharmaRithik:fix/webgpu-small-bar-mapped-upload
Sep 29, 2026
Merged

Jiajia Qin (qjia7) merged 1 commit into
microsoft:mainfrom
SharmaRithik:fix/webgpu-small-bar-mapped-upload

Conversation

@SharmaRithik

Copy link
Copy Markdown
Contributor

Description

This PR fixes model loading on discrete GPUs without Resizable BAR. The WebGPU Execution Provider now writes model weights straight into GPU memory only when the CPU can reach all of that memory. Otherwise it copies the weights through a temporary buffer first, which works on every GPU.

Motivation and Context

Without Resizable BAR, the CPU can write to only 256 MiB of GPU memory. On an AMD Radeon RX 7900 XT, Dawn's Vulkan backend still offers BufferMapExtendedUsages, so the WebGPU Execution Provider tried to put every model weight into those 256 MiB. Any weight larger than 256 MiB failed with "Allocation size too large", so Qwen3-0.6B FP16 could not load on that GPU. With this change it loads and runs. Dawn tracks this case in crbug.com/422798184.

### Description

This PR fixes initializer upload on discrete GPUs without Resizable BAR.
BufferMapExtendedUsages is now requested only when a host visible device local
heap is as large as the largest device local heap. Otherwise initializers use
the staged upload.

### Motivation and Context

On an AMD Radeon RX 7900 XT without Resizable BAR, the CPU can write directly
into only 256 MiB of GPU memory. Dawn's Vulkan backend still offers
BufferMapExtendedUsages, so the WebGPU Execution Provider creates every
initializer as a mapped storage buffer that must fit in those 256 MiB.
Initializers larger than 256 MiB fail with "Allocation size too large", so
Qwen3-0.6B FP16 failed to load on that GPU and now loads and runs with this
change. Dawn tracks this case in crbug.com/422798184.
Copilot AI balanced review requested due to automatic review settings September 26, 2026 07:19

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@SharmaRithik

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="University of California, Santa Cruz"

@SharmaRithik

Copy link
Copy Markdown
Contributor Author

Jiajia Qin (@qjia7) Yulong Wang (@fs-eire) could you take a look when you have time? This keeps mapped initializer upload for UMA and Resizable BAR GPUs and falls back to the staged upload when the host visible device local heap is smaller than device memory. The CI workflows are waiting for maintainer approval, so I would appreciate it if one of you could approve them as well.

@qjia7
Jiajia Qin (qjia7) enabled auto-merge (squash) September 29, 2026 07:29
@qjia7
Jiajia Qin (qjia7) merged commit 96f7311 into microsoft:main Sep 29, 2026
95 of 96 checks passed
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