Skip to content

Add RMSNorm module - #121364

Closed
mikaylagawarecki wants to merge 15 commits into
gh/mikaylagawarecki/189/basefrom
gh/mikaylagawarecki/189/head
Closed

mikaylagawarecki wants to merge 15 commits into
gh/mikaylagawarecki/189/basefrom
gh/mikaylagawarecki/189/head

Conversation

@mikaylagawarecki

@mikaylagawarecki mikaylagawarecki commented Mar 7, 2024 •

Copy link
Copy Markdown
Contributor

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Mar 7, 2024 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 3 New Failures

As of commit dce5f7c with merge base 148a8de (image):

NEW FAILURES - The following jobs have failed:

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

@wanchaol

wanchaol commented Mar 7, 2024

Copy link
Copy Markdown
Collaborator

Yay love to see this!

@wanchaol

wanchaol commented Mar 7, 2024

Copy link
Copy Markdown
Collaborator

cc @stas00 finally your ask is here!

mikaylagawarecki added a commit that referenced this pull request Mar 7, 2024
ghstack-source-id: 136e6bb
Pull Request resolved: #121364
@stas00

stas00 commented Mar 7, 2024

Copy link
Copy Markdown
Contributor

thank you for the heads up, @wanchaol!

Do you know if it is on par with apex's version?

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds pretty good!
Feel free to keep autograd and more optimized kernels for the next PR if you want to keep this one simple.

Comment thread torch/nn/functional.py Outdated
return handle_torch_function(
rms_norm, (input, weight), input, normalized_shape, weight=weight, eps=eps
)
if input.shape[-len(normalized_shape):] != normalized_shape:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this error checking is here, does it mean that calling torch.rms_norm() without these will error out? Should we move these checks to c++ ?

Comment thread torch/nn/modules/normalization.py Outdated

If a single integer is used, it is treated as a singleton list, and this module will
normalize over the last dimension which is expected to be of that specific size.
eps: a value added to the denominator for numerical stability. Default: 1e-6

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have eps be dtype-dependent. I think it's an oversight on our older modules where we assume they would always run in fp32.
I think we should start using torch.finfo(x.dtype).eps here WDYT?
cc @ngimel

@wanchaol

wanchaol commented Mar 8, 2024

Copy link
Copy Markdown
Collaborator

Do you know if it is on par with apex's version?

@stas00 This seems to be the initial version adding the initial support of RMSNorm module that calls into basic aten op in C++, but looks like @mikaylagawarecki @albanD have plans to add more optimized kernels too!

@pytorch-bot pytorch-bot Bot added the release notes: fx release notes category label Mar 14, 2024
mikaylagawarecki added a commit that referenced this pull request Mar 15, 2024
ghstack-source-id: 08e9b5e
Pull Request resolved: #121364
@mikaylagawarecki mikaylagawarecki added release notes: nn release notes category topic: new features topic category and removed release notes: fx release notes category labels Mar 15, 2024
@jbschlosser

Copy link
Copy Markdown
Contributor

With the scaffolding in place, we'd accept a PR backing it with a fused implementation for perf when applicable.

@atalman

atalman commented Mar 28, 2024

Copy link
Copy Markdown
Collaborator

@pytorchmergebot revert -m "Broke internal tests" -c ghfirst

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

pytorchmergebot added a commit that referenced this pull request Mar 28, 2024
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@mikaylagawarecki your PR has been successfully reverted.

@mikaylagawarecki

Copy link
Copy Markdown
Contributor Author

@mikaylagawarecki has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mikaylagawarecki

Copy link
Copy Markdown
Contributor Author

@mikaylagawarecki has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mikaylagawarecki

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f "Landed internally"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

sanketpurandare pushed a commit to sanketpurandare/pytorch that referenced this pull request Apr 22, 2024
@github-actions
github-actions Bot deleted the gh/mikaylagawarecki/189/head branch April 29, 2024 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants