Skip to content

Fix WebGPU DequantizeLinear scalar/vector shader cache collisions - #33122

Merged
Jiajia Qin (qjia7) merged 1 commit into
microsoft:mainfrom
gyagp:fix-32931
Oct 6, 2026
Merged

Jiajia Qin (qjia7) merged 1 commit into
microsoft:mainfrom
gyagp:fix-32931

Conversation

@gyagp

Copy link
Copy Markdown
Contributor

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

  • Fresh Windows D3D12 build: 213 quantization tests passed, 4 expected DirectML skips, 0 failures.
  • All four new regressions fail on the unfixed kernel and pass with this change.
  • The issue attachment matches CPU and QDQ-disabled WebGPU exactly for three seeds after the fix, including the reported 128.0-error seed. Profiling confirms the affected DQ nodes execute on WebGPU.
  • Clang-format, lintrunner, and git diff --check passed.

Metal and browser/WASM were not tested. Explicit Vulkan selection found no available adapter.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 03:51
@azure-pipelines

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

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 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.

@gyagp

Copy link
Copy Markdown
Contributor Author

/run bots

@gyagp

Copy link
Copy Markdown
Contributor Author

Jiajia Qin (@qjia7) PTAL

@qjia7

Copy link
Copy Markdown
Contributor

The request was received. Approve workflow runs. Thanks.

@qjia7
Jiajia Qin (qjia7) merged commit dafbea6 into microsoft:main 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.
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.

QDQPropagationTransformer changes a DynamicQuantizeLinear fan-out result on WebGPU

3 participants

⌂ 换网址