Skip to content

Is Llama4TextL2Norm meant to be RMS norm? #37934

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

Open
0x6b64 opened this issue May 2, 2025 · 1 comment
Open

Is Llama4TextL2Norm meant to be RMS norm? #37934

0x6b64 opened this issue May 2, 2025 · 1 comment

Comments

@0x6b64
Copy link

0x6b64 commented May 2, 2025

https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama4/modeling_llama4.py#L118

x * torch.rsqrt(x.pow(2).mean(-1, keepdim=True) + self.eps)

This is just the rms norm?

@Rocketknight1
Copy link
Member

That does look like the RMSNorm computation, yes. However, RMSNorm was only added to PyTorch in 2.3 or 2.4 I think, so we need to do it manually until our minimum supported torch version catches up!

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

No branches or pull requests

2 participants