Skip to content

Accept integral Double select scalars (#21387) - #21387

Open
JCNTH wants to merge 1 commit into
pytorch:mainfrom
JCNTH:export-D113588820
Open

Accept integral Double select scalars (#21387)#21387
JCNTH wants to merge 1 commit into
pytorch:mainfrom
JCNTH:export-D113588820

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary:

Loads existing Vulkan-serialized select graphs whose integer arguments alias Double constants.

Problem: Vulkan serialization deduplicates equal scalar values, so an integer select dimension or index can reference a previously emitted Double. WebGPU rejected those graphs even though Vulkan accepts the scalar representation.

Solution:

  • Before: aten.select_copy.int accepted only serialized Int values.
  • After: it also accepts exactly integral Double values in the int64_t range and rejects fractional, non-finite, out-of-range, and symbolic values.

Implementation:

  • Select.cpp — validates Double range and integrality before conversion.
  • test_webgpu_native.cpp — adds direct VK00 success, boundary, and rejection coverage.
  • Mirrors Vulkan ComputeGraph::extract_scalar<int64_t> scalar acceptance while retaining stricter checked conversion.

Constraints: The shader, dispatch, resize behavior, and SymInt policy are unchanged.

Co-authored-with: Claude Code.

Differential Revision: D113588820

Copilot AI review requested due to automatic review settings July 24, 2026 19:59
@pytorch-bot

pytorch-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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

@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 Jul 24, 2026
@meta-codesync

meta-codesync Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

@JCNTH has exported this pull request. If you are a Meta employee, you can view the originating Diff in D113588820.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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.

Pull request overview

This PR improves WebGPU runtime compatibility with Vulkan-serialized graphs by allowing aten.select_copy.int to consume Double scalar values when they are exactly integral and within int64_t range, matching Vulkan’s scalar deduplication behavior while still rejecting fractional/non-finite/out-of-range and symbolic values.

Changes:

  • Extend WebGPU select scalar parsing to accept Double values only when they are integral and safely convertible to int64_t.
  • Add WebGPU native regression tests covering successful execution for integral Double dim/index, boundary cases, and expected build-time rejections (fractional, NaN/Inf, out-of-range, SymInt).

Reviewed changes

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

File Description
backends/webgpu/runtime/ops/select/Select.cpp Accept integral Double scalars for select dim/index with validated conversion; keep SymInt/dynamic rejection behavior.
backends/webgpu/test/test_webgpu_native.cpp Add regression + negative tests for Vulkan-serialized select graphs where integer args alias cached Double scalars.

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

Summary:

**Loads existing Vulkan-serialized select graphs whose integer arguments alias Double constants.**

Problem: Vulkan serialization deduplicates equal scalar values, so an integer select dimension or index can reference a previously emitted Double. WebGPU rejected those graphs even though Vulkan accepts the scalar representation.

Solution:
- Before: `aten.select_copy.int` accepted only serialized Int values.
- After: it also accepts exactly integral Double values in the `int64_t` range and rejects fractional, non-finite, out-of-range, and symbolic values.

Implementation:
- `Select.cpp` — validates Double range and integrality before conversion.
- `test_webgpu_native.cpp` — adds direct VK00 success, boundary, and rejection coverage.
- Mirrors Vulkan `ComputeGraph::extract_scalar<int64_t>` scalar acceptance while retaining stricter checked conversion.

Constraints: The shader, dispatch, resize behavior, and SymInt policy are unchanged.

Co-authored-with: Claude Code.

Differential Revision: D113588820
@meta-codesync meta-codesync Bot changed the title Accept integral Double select scalars Accept integral Double select scalars (#21387) Jul 25, 2026
@JCNTH
JCNTH force-pushed the export-D113588820 branch from d87aba9 to e0c53cd Compare July 25, 2026 06:55
Copilot AI review requested due to automatic review settings July 25, 2026 06:55

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.

Pull request overview

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

@SS-JIA SS-JIA 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.

Review automatically exported from Phabricator review in Meta.

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants