Skip to content

softplus support for webgpu#27457

Merged
guschmue merged 2 commits intomainfrom
gs/wgpu-softplus
Feb 27, 2026
Merged

softplus support for webgpu#27457
guschmue merged 2 commits intomainfrom
gs/wgpu-softplus

Conversation

@guschmue
Copy link
Copy Markdown
Contributor

needed by onnx-community/Falcon-H1-Tiny-90M-Instruct-ONNX

@guschmue guschmue requested review from Copilot and fs-eire February 25, 2026 17:33
@guschmue guschmue added the ep:WebGPU ort-web webgpu provider label Feb 25, 2026
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

Adds ONNX Softplus operator support to the WebGPU Execution Provider, enabling execution of models (e.g., onnx-community/Falcon-H1-Tiny-90M-Instruct-ONNX) that include Softplus nodes on WebGPU.

Changes:

  • Register WebGPU Softplus kernels for ONNX opsets 1–21 and opset 22.
  • Implement Softplus as a WebGPU unary elementwise shader using a numerically-stable formulation.

Reviewed changes

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

File Description
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc Registers Softplus kernels in the WebGPU kernel registry for opsets 1–21 and 22.
onnxruntime/core/providers/webgpu/math/unary_elementwise_ops.cc Adds the Softplus WGSL expression and hooks it into the WebGPU unary elementwise kernel macros (versioned + opset 22).

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

Comment thread onnxruntime/core/providers/webgpu/math/unary_elementwise_ops.cc Outdated
Copy link
Copy Markdown
Contributor

@xenova xenova left a comment

Choose a reason for hiding this comment

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

LGTM ✅

>>> import torch
>>> (torch.log(1 + torch.exp(torch.tensor(20.0, dtype=torch.float32))) - 20.0).item()
0.0
>>> (torch.log(1 + torch.exp(torch.tensor(11.0, dtype=torch.float16))) - 11.0).item()
0.0

in pytorch, error is zero using these approximations in the relevant cases.

@guschmue guschmue enabled auto-merge (squash) February 26, 2026 19:06
@guschmue guschmue merged commit f73b1d7 into main Feb 27, 2026
100 of 106 checks passed
@guschmue guschmue deleted the gs/wgpu-softplus branch February 27, 2026 01:58
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.

4 participants