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

added query-key norm to accomodate OLMo2 #1894

Merged
merged 6 commits into from
Jan 2, 2025

Conversation

ysjprojects
Copy link
Contributor

@ysjprojects ysjprojects commented Dec 28, 2024

query_states = self.q_norm(self.q_proj(hidden_states))
key_states = self.k_norm(self.k_proj(hidden_states))
value_states = self.v_proj(hidden_states)

https://github.com/huggingface/transformers/blob/main/src/transformers/models/olmo2/modeling_olmo2.py

OLMo2 applies RMSNorm to the q and k matrices in its attention layer, something that is not yet supported by litgpt's architecture.

To support the addition of OLMo2, this PR adds an option to norm the q and k matrices via the config.norm_qk option which defaults to False.

Currently, the method for qk norm is assumed to follow the overall norm class.

litgpt/model.py Outdated Show resolved Hide resolved
@Andrei-Aksionov
Copy link
Collaborator

Looks good now.
Thank you.

@Andrei-Aksionov Andrei-Aksionov merged commit 40c08dc into Lightning-AI:main Jan 2, 2025
8 of 9 checks passed
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