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

[BugFix] Implement RoPE for GPT-J #941

Merged
merged 17 commits into from
Sep 6, 2023
Merged

[BugFix] Implement RoPE for GPT-J #941

merged 17 commits into from
Sep 6, 2023

Conversation

WoosukKwon
Copy link
Collaborator

Fixes #747 and fixes #590

This PR fixes a bug in the GPT-J model implementation. The GPT-J model uses a rotary embedding that is slightly different from the GPT-NeoX style rotary embedding (which is commonly used for LLaMA and recent models). The difference isn't considered in the vLLM's current implementation. The PR resolves this by adding a RoPE kernel for GPT-J. After this fix, I've checked that the outputs of GPT-J when using FP32 and argmax sampling match the HF's outputs.

NOTE: The PR should be merged after #938

Copy link
Member

@zhuohan123 zhuohan123 left a comment

Choose a reason for hiding this comment

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

LGTM! Left a small comment about an alternative coding style. Feel free to choose the one that you think is better.

@@ -253,8 +253,10 @@ def __init__(
max_position: int = 8192,
base: int = 10000,
num_kv_heads: Optional[int] = None,
is_neox_style: bool = True,
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Do you think this will be more clear?

Suggested change
is_neox_style: bool = True,
style: str = "neox", # Options: ["neox", "gptj"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To my knowledge, there are only two types of RoPE in terms of how they rotate the query and key vectors (To my understanding, the rope scaling stuffs use the GPT-NeoX RoPE). I think we can change the interface after we find more RoPEs to support.

hongxiayang pushed a commit to hongxiayang/vllm that referenced this pull request Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants