Skip to content

[WebGPU EP] grouped conv audio underflow fix - #32478

Open
Prathik Rao (prathikr) wants to merge 2 commits into
mainfrom
prathikrao/grouped-conv-audio-underflow-fix
Open

[WebGPU EP] grouped conv audio underflow fix#32478
Prathik Rao (prathikr) wants to merge 2 commits into
mainfrom
prathikrao/grouped-conv-audio-underflow-fix

Conversation

@prathikr

Copy link
Copy Markdown
Contributor

Fix padded WebGPU grouped convolution coordinates

Issue

Gemma 4 audio processing could abort on macOS while Dawn compiled the WebGPU GroupedConv shader:

std::out_of_range: absl::container_internal::raw_hash_map<>::at

The generated shader computed padded convolution coordinates as u32. When an output position required a negative input coordinate, subtracting the padding underflowed to a large unsigned value. The subsequent x < 0u check could never succeed. This affected the padded grouped-convolution path used by the audio frontend and could trigger a Metal/Dawn shader-compilation failure.

Fix

GroupedConv now:

  • Computes convolution coordinates as signed i32 values.
  • Performs bounds checks before indexing tensor data.
  • Converts coordinates to u32 only after they are known to be in range.

Regression test

Added a WebGPU test using a two-group, 1D-style convolution represented as a padded 2D convolution. The test exercises negative left-border coordinates and verifies the expected zero-padding behavior.

Validation:

Conv_WebGPU.GroupedConvWithPaddingUsesSignedCoordinates: PASSED

Copilot AI balanced review requested due to automatic review settings September 8, 2026 18:53

@github-actions github-actions Bot 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.

You can commit the suggested changes from lintrunner.

Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Outdated

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.

🟢 Approval recommended

The signed-coordinate fix is correctly bounded and covered by a focused regression test.

Pull request overview

Fixes WebGPU grouped convolution padding underflow during shader generation.

Changes:

  • Uses signed WGSL coordinates for padded convolution bounds checks.
  • Converts validated coordinates to unsigned indices.
  • Adds a grouped-convolution padding regression test.

No actionable findings identified.

File summaries
File Description
onnxruntime/core/providers/webgpu/nn/grouped_conv.cc Corrects padded coordinate arithmetic and indexing.
onnxruntime/test/providers/webgpu/grouped_conv_padding_test.cc Verifies grouped convolution zero-padding behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants