Skip to content

[Vulkan] Match ATen special values in pow.Tensor_Scalar - #23212

Closed
mergennachin wants to merge 1 commit into
mergennachin/vulkan-23156-11-fullfrom
mergennachin/vulkan-23156-12-power-contract
Closed

mergennachin wants to merge 1 commit into
mergennachin/vulkan-23156-11-fullfrom
mergennachin/vulkan-23156-12-power-contract

Conversation

@mergennachin

@mergennachin mergennachin commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #23251, part 12/15 of the ghstack replacement series. The current integration PR is #23254. This PR is closed in favor of the replacement; its previous description and review history are retained.


power_of only special-cased zero bases and used a 1e-5 tolerance to detect odd integer exponents, so NaN, infinities, signed zeros and negative bases with fractional exponents gave wrong results. It now follows ATen case by case, including the FP32 sqrt and rsqrt path for exponents of plus or minus 0.5. The requested tensor dtype survives device storage emulation, so FP16 keeps its distinct ATen special-value semantics on SwiftShader. Explicit nearest-even output conversion preserves the FP16 conformance cases on hardware GPUs.

Part 12/15 of the Vulkan transformer and operator-conformance stack. Depends on #23211; review against the selected base branch. Integration PR: #23162.

Validation: 1 passed, 2 warnings in 72.00s (0:01:12). Lintrunner and git diff --check pass. Native tests use MoltenVK with portable CPU kernels; hardware and SwiftShader CI are pending.

Authored with OpenAI Codex; split planned with Claude Code.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

power_of only special-cased zero bases and used a 1e-5 tolerance to detect odd integer exponents, so NaN, infinities, signed zeros and negative bases with fractional exponents gave wrong results. It now follows ATen case by case, including the FP32 sqrt and rsqrt path for exponents of plus or minus 0.5. The requested tensor dtype survives device storage emulation, so FP16 keeps its distinct ATen special-value semantics on SwiftShader. Explicit nearest-even output conversion preserves the FP16 conformance cases on hardware GPUs.

Authored with OpenAI Codex; split planned with Claude Code.
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Sep 28, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit 507c122 with merge base a318382 (image):
💚 Looks good so far! There are no failures yet. 💚

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 Sep 28, 2026
mergennachin added a commit that referenced this pull request Oct 8, 2026
power_of only special-cased zero bases and used a 1e-5 tolerance to
detect odd integer exponents, so NaN, infinities, signed zeros and
negative bases with fractional exponents gave wrong results. It now
follows ATen case by case: FP32 uses sqrt/rsqrt for exponents of plus or
minus 0.5, while FP16 rounds the scalar exponent to half and uses
generic pow. Tests cover exponents 2.0001 and 2049, whose half
conversion changes the result category or sign.

Devices without full FP16 support store half tensors as float. vTensor
now records the requested dtype, and the binary scalar shaders receive
it as a specialization constant so pow rounds the exponent and result to
half with round-to-nearest-even. Explicit conversion also handles native
FP16 stores whose rounding mode differs. These rules follow the graph's
requested dtype, including force_fp16. Other operators retain their
existing FP32 intermediate behavior on emulating devices.

Part 12/15 of the Vulkan transformer and operator-conformance stack. The
dependency #23250 has landed. Rebased onto `origin/main` at
`265ed38b340180af63b1feafed2671e623da19ef`; review against main.
Integration PR: #23254.

Validation after rebase: Rebuilt ExecuTorch 1.6.0+87402fb from source
with Vulkan enabled and PyTorch 2.14.0. Ran
`TestVulkanDynamic.test_power_special_values` through the public Buck
Python adapter on both drivers. SwiftShader passed all 40 combinations
in 98.598 seconds; MoltenVK 1.4.1 on Apple M1 Pro passed all 40 in
96.458 seconds. Both runs had zero failures, errors, or skips. Each run
covers FP32 and FP16, TEXTURE_3D and BUFFER, and all ten exponents, with
NaN and signed-zero checks against PyTorch. Native macOS arm64
SwiftShader at `1e80438d2b93ef36a7c05f8d2b81233bac0e3d16` reports
`shaderFloat16 = false` and `storageBuffer16BitAccess = false`, so that
run exercises FP16 storage emulation. Lintrunner passed for all eight
changed files; `git diff --check` and `pip check` passed. `git
range-diff` confirms the rebase preserved the original patch.

Recreates #23212 through ghstack. Prior review discussion remains on
that PR.

Authored with OpenAI Codex; split planned with Claude Code.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

This branch was successfully deployed

1 active deployment
cadence — 507c122c Deployed Sep 28, 2026 by mergennachin via hifi-op-test / hifi4 #30212
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. module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant