Skip to content

[ET-VK][test] Allow FP16 underflow in SwiGLU comparisons - #23719

Closed
pytorchbot wants to merge 1 commit into
mainfrom
gh/SS-JIA/669/orig
Closed

pytorchbot wants to merge 1 commit into
mainfrom
gh/SS-JIA/669/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #23716 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/669/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/669/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/669/orig
Differential Revision: D124833698
@diff-train-skip-merge

Pull Request resolved: #23716

## Ulterior Motive

Keep `VulkanSwiGLUTest` correctness checks usable on Vulkan devices that flush FP16 subnormal values to zero.

## Rationale

**What**: Increase the absolute error allowances in `MatchesUnfusedAcrossResizes` to account for FP16 underflow.

**Why**: On stable, all 28 FP16 configurations fail on Adreno 750 while FP32 passes. The first expected output is `5.30033e-6`, below FP16's minimum normal value, but the shader returns zero. The unfused path can also flush subnormal inputs and intermediate tensors before later multiplications amplify the difference.

## Details

- Fused versus CPU reference:
  - **Before**: Absolute allowance `1e-7`.
  - **After**: Absolute allowance `2^-14`, FP16's minimum normal value; relative allowance remains `1e-3`.
- Fused versus unfused graph:
  - **Before**: Absolute allowance `6e-8 * (abs(x*y) + abs(y) + 1)` assumes subnormal preservation.
  - **After**: Keep the original rounding allowance and add `(1 + 1e-3) * abs(reference)` only when an FP16 input is subnormal or a computed intermediate/output can round below the minimum normal value. Use the existing `3e-3` relative tolerance as the rounding margin at that boundary.
  - If the unfused result flushes to zero, its relative tolerance vanishes. `abs(reference)` covers the lost output, and the extra `1e-3` covers the fused result's relative error.
  - Cases without underflow keep the small original absolute allowance: `x=20, y=2` gives `2.58e-6`; the original tiny-output case gives about `6.63e-6`.
- FP32 uses its existing assertions. Both FP16 comparisons keep `ASSERT_NEAR`.

Differential Revision: [D124833698](https://our.internmc.facebook.com/intern/diff/D124833698/)
ghstack-source-id: 446951678
@pytorchbot
pytorchbot requested a review from SS-JIA as a code owner October 13, 2026 01:38
@pytorch-bot

pytorch-bot Bot commented Oct 13, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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 Oct 13, 2026
@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.

This branch was successfully deployed

1 active deployment
cadence — b5c3969f Deployed Oct 13, 2026 by pytorchbot via hifi-op-test / hifi4 #33009
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants