Skip to content

[ET-VK] Fused RMSNorm operator to fix fp16 overflow#18786

Merged
SS-JIA merged 1 commit intomainfrom
etvk_manual_sync
Apr 9, 2026
Merged

[ET-VK] Fused RMSNorm operator to fix fp16 overflow#18786
SS-JIA merged 1 commit intomainfrom
etvk_manual_sync

Conversation

@SS-JIA
Copy link
Copy Markdown
Contributor

@SS-JIA SS-JIA commented Apr 9, 2026

Pull Request resolved: #18772

Fused RMSNorm operator that performs squaring, mean, rsqrt, and weight scaling in a single shader dispatch. All accumulation is done in fp32 regardless of input dtype, preventing fp16 overflow when residual stream values exceed sqrt(65504) ≈ 256.

The Python reference impl (rms_norm_impl) must preserve the input dtype — PyTorch type promotion would otherwise produce fp32 output from fp16 inputs, and the FusePatternsPass re-trace would propagate that incorrect dtype through the graph.

Authored by Claude.
ghstack-source-id: 364514329
@exported-using-ghexport

Differential Revision: D99841211

Summary

[PLEASE REMOVE] See CONTRIBUTING.md's Pull Requests for ExecuTorch PR guidelines.

[PLEASE REMOVE] If this PR closes an issue, please add a Fixes #<issue-id> line.

[PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: " label. For a list of available release notes labels, check out CONTRIBUTING.md's Pull Requests.

Test plan

[PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable.

Pull Request resolved: #18772

Fused RMSNorm operator that performs squaring, mean, rsqrt, and
weight scaling in a single shader dispatch. All accumulation is done
in fp32 regardless of input dtype, preventing fp16 overflow when
residual stream values exceed sqrt(65504) ≈ 256.

The Python reference impl (`rms_norm_impl`) must preserve the input
dtype — PyTorch type promotion would otherwise produce fp32 output
from fp16 inputs, and the FusePatternsPass re-trace would propagate
that incorrect dtype through the graph.

Authored by Claude.
ghstack-source-id: 364514329
@exported-using-ghexport

Differential Revision: [D99841211](https://our.internmc.facebook.com/intern/diff/D99841211/)
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 9, 2026

🔗 Helpful Links

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

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

⏳ No Failures, 34 Pending

As of commit ae17fd1 with merge base a231fbc (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 Apr 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

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.

@SS-JIA SS-JIA merged commit dbd7d7f into main Apr 9, 2026
164 of 169 checks passed
@SS-JIA SS-JIA deleted the etvk_manual_sync branch April 9, 2026 02:44
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