Repository navigation
Fix WebGPU DequantizeLinear scalar/vector shader cache collisions - #33122
Merged
Merged
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The localized cache-key fix has focused regression coverage and no unresolved findings.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes WebGPU DequantizeLinear shader-cache collisions behind the incorrect results reported in #32931, without changing quantization arithmetic.
Changes:
- Includes output type/component count in shader-cache metadata.
- Adds four regressions covering int8/uint8, FP32/FP16, and both node insertion orders, with CPU fallback disabled.
| File | Description |
|---|---|
| onnxruntime/test/providers/webgpu/tensor/quantize_linear_test.cc | Adds scalar/vector cache-collision regressions. |
| onnxruntime/core/providers/webgpu/quantization/quantize_linear.cc | Distinguishes scalar and vector output shader variants. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Author
|
/run bots |
Contributor
Author
|
Jiajia Qin (@qjia7) PTAL |
Contributor
|
The request was received. Approve workflow runs. Thanks. |
Jiajia Qin (qjia7)
approved these changes
Oct 6, 2026
Jiajia Qin (qjia7)
pushed a commit
that referenced
this pull request
Oct 10, 2026
### Description Fix five native WebGPU shader-cache collisions using the existing metadata and cache hints: - **BiasAdd / BiasSplitGelu:** key one input's program type, which captures both element type and vector width. - **LayerNormalization:** distinguish mean-only from inverse-standard-deviation-only outputs. Output count already distinguishes the other combinations. - **InstanceNormalization:** include the epsilon literal embedded in the shader. - **Boolean And:** distinguish full-vector reads from single-lane broadcasts, which both use Boolx4 storage. Also correct BiasSplitGelu's FP16 division operand type so the correctly selected shader compiles. Add six small GPU regression tests. Each puts conflicting variants in one session, covers both node insertion orders, and repeats inference for warm-cache reuse. CPU fallback is disabled and full WebGPU validation is enabled. ### Motivation and Context This extracts the confirmed correctness fixes from #33153 so they can land before the proposed cache-framework migration. The DequantizeLinear fix is already merged in #33122. ### Validation - Fresh Windows Release build with native WebGPU/D3D12, based on `6e0f154e32`. - All six new tests fail on unmodified main and pass with the fixes; about 2.5 seconds locally. - With the FP16 arithmetic correction but without BiasSplitGelu's type key, five tests pass and BiasSplitGelu still fails numerically, independently confirming that collision. - 201 affected tests pass, zero skipped, with two BERT tests rerun after staging their missing model fixtures. Broad counts include CPU execution. - All 14 original numerical reproduction checks pass, including dynamic Boolean shape swaps and cross-session cache reuse, with CPU fallback disabled. - Clang-format, lintrunner, and `git diff --check` pass. Metal, WASM and plugin builds were not run locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix a DequantizeLinear shader-cache collision between scalar and vec4 output paths. Packed int8/uint8 inputs use the same storage type in both paths, and the output rank alone does not distinguish the generated shaders.
Include the output type/component count in the cache metadata. Add four WebGPU-only regressions covering int8/uint8 and FP32/FP16, with both node insertion orders and CPU fallback disabled.
Motivation and Context
QDQ propagation inserts a scalar-output DequantizeLinear after Reshape in the reported model. A later vector-output operation can reuse that scalar shader and produce incorrect values. This fixes the cache identity without changing QDQ propagation or quantization arithmetic.
Fixes #32931.
Validation
git diff --checkpassed.Metal and browser/WASM were not tested. Explicit Vulkan selection found no available adapter.