Skip to content

Fix WebGPU grouped Conv vectorization across group boundaries - #33129

Merged
Xavier DuprΓ© (xadupre) merged 1 commit into
mainfrom
fix/webgpu-grouped-conv-vector-width
Oct 6, 2026
Merged

Xavier DuprΓ© (xadupre) merged 1 commit into
mainfrom
fix/webgpu-grouped-conv-vector-width

Conversation

@xadupre

Copy link
Copy Markdown
Member

Description

Choose the general NHWC grouped-Conv vector width from the number of output channels per group, rather than the total output channel count. This prevents a vector from straddling two groups while the shader uses one input-group offset for all its components.

Keep the dedicated depthwise vector path unchanged: its one-to-one input/output channel correspondence permits vectorization across groups. NCHW and existing aligned-group vector widths are unchanged.

Add 128 parameterized operator regressions with an independent scalar convolution reference:

  • Two/four groups and one/three input channels per group.
  • 1, 3, 4, 5, 6, 7, 8, and 12 output channels per group.
  • NHWC/NCHW and bias/no bias, with batch size two and a non-pointwise kernel.
  • Explicit WebGPU selection with CPU EP fallback disabled; unavailable providers skip before constructing the tester.

Motivation and Context

Fixes #33086.

For example, two groups with six output channels each previously selected vec4 from the total of twelve channels. The vector covering channels 4–7 crosses the group boundary, but all four lanes use the first group's input channels. Selecting vec2 from six channels per group preserves group boundaries.

Validation on Linux Release with Mesa lavapipe (software Vulkan), executing actual WebGPU shaders:

  • Full WebGPU provider-test build β€” passed:
    source .venv/bin/activate
    python tools/ci_build/build.py --config Release --build_dir build/linux_webgpu \
        --use_webgpu --cmake_generator Ninja --parallel 24 --skip_tests \
        --update --build --target onnxruntime_provider_test
  • Temporarily restoring the original vector-width selection and rebuilding reproduced three numerical failures for NHWC with 5, 6, and 7 output channels per group:
    cmake --build build/linux_webgpu/Release --target onnxruntime_provider_test -j 24
    cd build/linux_webgpu/Release
    VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
        timeout 180 ./onnxruntime_provider_test \
        --gtest_filter='Conv_WebGPU/GroupedConvVectorizationTest.OutputVectorsStayWithinGroups/13:Conv_WebGPU/GroupedConvVectorizationTest.OutputVectorsStayWithinGroups/17:Conv_WebGPU/GroupedConvVectorizationTest.OutputVectorsStayWithinGroups/21'
  • Restoring the fix and rebuilding β€” passed. Final targeted execution β€” 129 passed, none skipped, including the existing padding regression:
    cmake --build build/linux_webgpu/Release --target onnxruntime_provider_test -j 24
    cd build/linux_webgpu/Release
    VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
        timeout 180 ./onnxruntime_provider_test \
        --gtest_filter='Conv_WebGPU.GroupedConvWithPaddingUsesSignedCoordinates:Conv_WebGPU/GroupedConvVectorizationTest.*'
  • Formatting and whitespace β€” passed:
    .venv/bin/clang-format --dry-run --Werror \
        onnxruntime/core/providers/webgpu/nn/conv.cc \
        onnxruntime/test/providers/webgpu/grouped_conv_padding_test.cc
    git diff --check

Not validated locally: physical GPU drivers, Metal/D3D12, FP16, graph capture, or the full test suite. Software Vulkan establishes correctness for these MatMul-free grouped-Conv cases, not GPU performance.

Select NHWC grouped-Conv vector width from output channels per group, while retaining the depthwise specialization. Add scalar-reference regressions for group widths, layouts, bias and depthwise multipliers with CPU fallback disabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 12:11

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 focused fix preserves existing special cases and is covered across affected layouts and group configurations.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes #33086 by preventing NHWC grouped-Conv vectors from crossing group boundaries.

Changes:

  • Selects vector width using output channels per group.
  • Preserves depthwise and NCHW behavior.
  • Adds 128 WebGPU regression cases with an independent reference.

No actionable issues identified.

File Description
onnxruntime/​core/​providers/​webgpu/​nn/​conv.cc Corrects grouped-Conv vector-width selection.
onnxruntime/​test/​providers/​webgpu/​grouped_conv_padding_test.cc Adds comprehensive grouped-Conv regressions.

πŸ’‘ Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@xadupre
Xavier DuprΓ© (xadupre) deleted the fix/webgpu-grouped-conv-vector-width branch October 6, 2026 14:53
eserscor pushed a commit that referenced this pull request Oct 7, 2026
### Description
<!-- Describe your changes. -->

Choose the general NHWC grouped-Conv vector width from the number of
output channels **per group**, rather than the total output channel
count. This prevents a vector from straddling two groups while the
shader uses one input-group offset for all its components.

Keep the dedicated depthwise vector path unchanged: its one-to-one
input/output channel correspondence permits vectorization across groups.
NCHW and existing aligned-group vector widths are unchanged.

Add 128 parameterized operator regressions with an independent scalar
convolution reference:

- Two/four groups and one/three input channels per group.
- 1, 3, 4, 5, 6, 7, 8, and 12 output channels per group.
- NHWC/NCHW and bias/no bias, with batch size two and a non-pointwise
kernel.
- Explicit WebGPU selection with CPU EP fallback disabled; unavailable
providers skip before constructing the tester.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

Fixes #33086.

For example, two groups with six output channels each previously
selected `vec4` from the total of twelve channels. The vector covering
channels 4–7 crosses the group boundary, but all four lanes use the
first group's input channels. Selecting `vec2` from six channels per
group preserves group boundaries.

Validation on Linux Release with Mesa lavapipe (software Vulkan),
executing actual WebGPU shaders:

- Full WebGPU provider-test build β€” **passed**:
  ```bash
  source .venv/bin/activate
python tools/ci_build/build.py --config Release --build_dir
build/linux_webgpu \
      --use_webgpu --cmake_generator Ninja --parallel 24 --skip_tests \
      --update --build --target onnxruntime_provider_test
  ```
- Temporarily restoring the original vector-width selection and
rebuilding reproduced **three numerical failures** for NHWC with 5, 6,
and 7 output channels per group:
  ```bash
cmake --build build/linux_webgpu/Release --target
onnxruntime_provider_test -j 24
  cd build/linux_webgpu/Release
  VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
      timeout 180 ./onnxruntime_provider_test \

--gtest_filter='Conv_WebGPU/GroupedConvVectorizationTest.OutputVectorsStayWithinGroups/13:Conv_WebGPU/GroupedConvVectorizationTest.OutputVectorsStayWithinGroups/17:Conv_WebGPU/GroupedConvVectorizationTest.OutputVectorsStayWithinGroups/21'
  ```
- Restoring the fix and rebuilding β€” **passed**. Final targeted
execution β€” **129 passed, none skipped**, including the existing padding
regression:
  ```bash
cmake --build build/linux_webgpu/Release --target
onnxruntime_provider_test -j 24
  cd build/linux_webgpu/Release
  VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json \
      timeout 180 ./onnxruntime_provider_test \

--gtest_filter='Conv_WebGPU.GroupedConvWithPaddingUsesSignedCoordinates:Conv_WebGPU/GroupedConvVectorizationTest.*'
  ```
- Formatting and whitespace β€” **passed**:
  ```bash
  .venv/bin/clang-format --dry-run --Werror \
      onnxruntime/core/providers/webgpu/nn/conv.cc \
      onnxruntime/test/providers/webgpu/grouped_conv_padding_test.cc
  git diff --check
  ```

Not validated locally: physical GPU drivers, Metal/D3D12, FP16, graph
capture, or the full test suite. Software Vulkan establishes correctness
for these MatMul-free grouped-Conv cases, not GPU performance.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

[WebGPU] Grouped Conv (channels-last) gives wrong results when output channels per group is not a multiple of the vector width

3 participants