Skip to content

Support Conv+QuickGelu fusion in the WebGPU EP - #2

Open
4n4ny4 wants to merge 1 commit into
mainfrom
t-anaanand-microsoft-webgpu-quickgelu-fusion
Open

Support Conv+QuickGelu fusion in the WebGPU EP#2
4n4ny4 wants to merge 1 commit into
mainfrom
t-anaanand-microsoft-webgpu-quickgelu-fusion

Conversation

@4n4ny4

@4n4ny4 4n4ny4 commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Problem

The WebGPU EP could not fuse Conv with com.microsoft.QuickGelu, so SiLU-style activations ran as standalone dispatches. On YOLO26n that is 87 extra dispatches, each reading and rewriting a full tensor to apply one cheap elementwise operation.

The activation appears as QuickGelu rather than Sigmoid+Mul because QuickGeluFusion merges that pair earlier in the pipeline. ConvActivationFusion then declined it, and GetFusedActivationAttr had no parser for it.

Change

  • Allow Convcom.microsoft.QuickGelu fusion for kWebGpuExecutionProvider, preserving the alpha attribute.
  • Implement QuickGelu parsing and its fused WGSL epilogue in onnxruntime/core/providers/webgpu/nn/fuse_utils.{h,cc}.

Important invariant

An execution provider must never be authorized in the optimizer allow-list without its matching activation parser. Without the native parser, conv.h's ORT_ENFORCE(GetFusedActivationAttr(info, activation_).IsOK()) hard-fails rather than falling back. The path is reachable on ordinary models: partition, Level 2, QuickGeluFusion, then a Level 4 graph mutation re-runs the optimization loop and Level 2 sees ConvQuickGelu.

This PR therefore gates authorization to the native WebGPU EP only. Extending it to the JSEP backend is future work and must ship in the same change as the JSEP parser plus positive tests for both providers.

Validation

graph_transform_test.cc verifies the fusion including default alpha. On YOLO26n, dispatches drop 288 → 201 with 0 standalone QuickGelu remaining, and output is unchanged.

Performance

Dispatch-count reduction is real, but end-to-end GPU time on this path is unchanged — those dispatches were already overlapped and off the critical path. The measurable benefit is roughly 0.100 ms of host-side encode work. Presented as correctness and enablement, not a performance win.

Gate QuickGelu fusion to WebGPU and parse it in WebGPU fused Conv. Preserve an explicit alpha and materialize 1.702 when omitted so the fused node retains the schema default.

An EP must not be authorized without its parser: conv.h hard-fails with ORT_ENFORCE(GetFusedActivationAttr(info, activation_).IsOK()). Any future backend authorization must therefore ship with its parser.

Integrated browser measurements eliminated 87 standalone QuickGelu dispatches and reduced total steady dispatches from 288 to 201. The GPU path was performance-neutral, while host-side T0-T2 improved by about 0.100 ms.

Co-authored-by: Copilot App <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.

1 participant