Skip to content

Add WebGPU sigmoid operator#20504

Draft
iamorlando wants to merge 1 commit into
pytorch:mainfrom
iamorlando:main
Draft

Add WebGPU sigmoid operator#20504
iamorlando wants to merge 1 commit into
pytorch:mainfrom
iamorlando:main

Conversation

@iamorlando

Copy link
Copy Markdown

Summary

Adds WebGPU runtime support for aten.sigmoid.default to expand the Llama-oriented operator coverage in the WebGPU backend.

This includes:

  • a WGSL fp32 sigmoid compute shader and generated embedded header
  • C++ WebGPU op registration and CMake wiring
  • WebGPU tester allowlist plus export/op-test coverage
  • README/TODO support matrix updates

The op follows the existing WebGPU runtime path: models are lowered through the existing VulkanBackend delegate serialization, and the WebGPU runtime consumes that delegate graph.

Test plan

  • .venv/bin/python backends/webgpu/scripts/gen_wgsl_headers.py --check
  • git diff HEAD --check
  • PYTHONPYCACHEPREFIX=/tmp/executorch_pycache .venv/bin/python -m py_compile backends/webgpu/test/tester.py backends/webgpu/test/op_tests/cases.py backends/webgpu/test/op_tests/generate_op_tests.py backends/webgpu/test/op_tests/test_generator.py backends/webgpu/test/op_tests/test_schema.py backends/webgpu/test/ops/sigmoid/test_sigmoid.py
  • .venv/bin/lintrunner --force-color <changed files> --skip MYPY (no lint issues)
  • .venv/bin/python -m pytest backends/webgpu/test/ops/sigmoid/test_sigmoid.py -vv (4 passed)
  • .venv/bin/python -m pytest backends/webgpu/test/op_tests/test_schema.py backends/webgpu/test/op_tests/test_generator.py -vv (11 passed)
  • .venv/bin/python -m executorch.backends.webgpu.test.op_tests.generate_op_tests --output /tmp/webgpu_op_tests_all
  • Linux amd64 Docker native build with Dawn prebuilt and Mesa lavapipe:
    • built webgpu_scratch_buffer_test, webgpu_op_test_util_test, and webgpu_op_test
    • /tmp/build/backends/webgpu/webgpu_scratch_buffer_test (passed)
    • /tmp/build/backends/webgpu/webgpu_op_test_util_test (3 passed)
    • /tmp/build/backends/webgpu/webgpu_op_test --manifest /artifacts/manifest.json (25 passed, including 5 OpTest_sigmoid cases)
  • Browser/WASM smoke validation (out-of-tree proof harness only; not added to this repo because there is no matching checked-in browser/WASM WebGPU test target):
    • exported a torch.sigmoid(x) Python model to ExecuTorch .pte
    • built Emscripten WASM linked with webgpu_backend and emdawnwebgpu
    • ran in browser with real input [-8, -4, -1, 0, 1, 4, 8, 12, -12]
    • verified method metadata: backends=["VulkanBackend"], numInstructions=1
    • instrumented WebGPU calls: requestAdapter=1, requestDevice=1, createShaderModule=1, createComputePipeline=1, dispatchWorkgroups=1, queueSubmit=1
    • output matched PyTorch golden with maxAbsError=2.9103830456733704e-11

@pytorch-bot

pytorch-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20504

Note: Links to docs will display an error until the docs builds have been completed.

❗ 2 Active SEVs

There are 2 currently active SEVs. If your PR is affected, please view them below:

⚠️ 11 Awaiting Approval

As of commit f1077bd with merge base 80b6c34 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla

meta-cla Bot commented Jun 25, 2026

Copy link
Copy Markdown

Hi @iamorlando!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@iamorlando

Copy link
Copy Markdown
Author

@pytorchbot label "release notes: ops & kernels"

@pytorch-bot pytorch-bot Bot added the release notes: ops & kernels Changes to the opset and any new / changed kernel implementations label Jun 25, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 25, 2026
@meta-cla

meta-cla Bot commented Jun 25, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. release notes: ops & kernels Changes to the opset and any new / changed kernel implementations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant