Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RMSNormToL2Norm graph surgeon #1594

Merged
merged 1 commit into from
Feb 4, 2025
Merged

Add RMSNormToL2Norm graph surgeon #1594

merged 1 commit into from
Feb 4, 2025

Conversation

jambayk
Copy link
Contributor

@jambayk jambayk commented Feb 4, 2025

Describe your changes

New graph surgeon to simplify RMSNorm subgraph using L2Norm subgraph.
rmsnorm = x/sqrt(mean(x**2)) = x/sqrt(1/N*sum(x**2)) = sqrt(N)*x/sqrt(sum(x**2)) = sqrt(N)*L2Norm

This is useful when quantizing the model for NPU since there are fewer activations to quantize.

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.
  • Is this PR including examples changes? If yes, please remember to update example documentation in a follow-up PR.

(Optional) Issue link

@jambayk jambayk force-pushed the jambayk/rmsnorm-l2norm branch from ab7bba0 to 1184ddf Compare February 4, 2025 08:28
@jambayk jambayk merged commit 29758a5 into main Feb 4, 2025
24 checks passed
@jambayk jambayk deleted the jambayk/rmsnorm-l2norm branch February 4, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants