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

Refactor/fix Cohere2 #35594

Merged
merged 4 commits into from
Jan 9, 2025
Merged

Refactor/fix Cohere2 #35594

merged 4 commits into from
Jan 9, 2025

Conversation

Cyrilvallez
Copy link
Member

What does this PR do?

Refactor Cohere2 to meet recent standards, and fix #35547 at the same time

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Cyrilvallez
Copy link
Member Author

cc @ArthurZucker, and @alexrs-cohere if you want to have a look!

@@ -181,117 +175,29 @@ def apply_rotary_pos_emb(q, k, cos, sin, position_ids=None, unsqueeze_dim=1):


def eager_attention_forward(
config: Cohere2Config,
module: nn.Module,
Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @ydshieh 😉

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes!!!!!!!!!!

dropout: float = 0.0,
**kwargs,
):
key_states = repeat_kv(key, module.num_key_value_groups)
Copy link
Collaborator

Choose a reason for hiding this comment

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

can't we import it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh indeed, good point! More code cut 🤗

@Cyrilvallez Cyrilvallez merged commit 3a4ae6e into main Jan 9, 2025
17 checks passed
@Cyrilvallez Cyrilvallez deleted the cohere2 branch January 9, 2025 16:55
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.

FA2 broken for Cohere2 if Optional Mask is not passed in forward
4 participants