Skip to content

[WebGPU] DequantizeLinear op fixes#27706

Merged
edgchen1 merged 10 commits intomainfrom
edgchen1/webgpu_fix_test_failures
Mar 20, 2026
Merged

[WebGPU] DequantizeLinear op fixes#27706
edgchen1 merged 10 commits intomainfrom
edgchen1/webgpu_fix_test_failures

Conversation

@edgchen1
Copy link
Copy Markdown
Contributor

Description

Fix some issues that show up as test failures in js/web/test/data/ops/dequantizelinear.jsonc.

  1. When component=4, output shapes where the last dimension was not divisible by component were not handled.
    onnxruntime/core/providers/webgpu/program.cc:247 TensorShape onnxruntime::webgpu::(anonymous namespace)::GetReducedShape(const TensorShape &, int) shape.NumDimensions() > 0 && shape.GetDims()[shape.NumDimensions() - 1] % component == 0 was false. Cannot reduce shape {2,2} by component=4
    Added ProgramOutput::Flatten to the output definition to address this.

  2. Fix handling of zero point in blocked quantization path.

Also renamed some test cases with more descriptive names.

Motivation and Context

Fix some issues with WebGPU DequantizeLinear op implementation.

@edgchen1 edgchen1 requested review from fs-eire and guschmue March 17, 2026 18:11
guschmue
guschmue previously approved these changes Mar 17, 2026
@edgchen1 edgchen1 requested review from Copilot March 17, 2026 18:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes WebGPU DequantizeLinear implementation issues that were causing test failures, and improves related test coverage/readability.

Changes:

  • Fix shader codegen for blocked quantization zero-point indexing (use correct linear offset).
  • Adjust program output definition to support cases where the last dimension isn’t divisible by component=4 (via output flattening when vectorized).
  • Rename existing JS test cases and add a new blocked dequantization test case.

Reviewed changes

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

File Description
onnxruntime/core/providers/webgpu/quantization/quantize_linear.cc Fixes zero-point indexing for blocked quantization shaders; updates output definition to flatten when using vectorized components.
js/web/test/data/ops/dequantizelinear.jsonc Renames test cases for clarity and adds a new blocked dequantization scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/web/test/data/ops/dequantizelinear.jsonc Outdated
Comment thread onnxruntime/core/providers/webgpu/quantization/quantize_linear.cc
Comment thread onnxruntime/core/providers/webgpu/quantization/quantize_linear.cc
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

guschmue
guschmue previously approved these changes Mar 18, 2026
@guschmue
Copy link
Copy Markdown
Contributor

this fixes some of the webnn DequantizeLinear compliance tests:
https://wpt.live/webnn/conformance_tests/dequantizeLinear.https.any.html?gpu

@guschmue guschmue added the ep:WebGPU ort-web webgpu provider label Mar 20, 2026
@edgchen1 edgchen1 merged commit a685789 into main Mar 20, 2026
118 of 121 checks passed
@edgchen1 edgchen1 deleted the edgchen1/webgpu_fix_test_failures branch March 20, 2026 16:42
guschmue added a commit that referenced this pull request Mar 30, 2026
…27778)

This PR is on top of a previous PR and fixes the remaining issues.
#27706

All tests here should be passing now over webgpu:

https://wpt.live/webnn/conformance_tests/dequantizeLinear.https.any.html?gpu

---------

Co-authored-by: edgchen1 <18449977+edgchen1@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ep:WebGPU ort-web webgpu provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants