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 model_glm code #11883

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

add model_glm code #11883

wants to merge 1 commit into from

Conversation

zhipuch
Copy link

@zhipuch zhipuch commented Jan 9, 2025

The full glm model code eliminates formatting and logic issues during inference using the inherited llama method.

Copy link

github-actions bot commented Jan 9, 2025

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@Isotr0py
Copy link
Collaborator

Isotr0py commented Jan 9, 2025

@zhipuch Could you elaborate about the logic issues?

Since the hf-format glm model is a llama-style one, I don't think we should copy most of code from llama.py, this will increase the difficulty of maintaining.

@zhipuch
Copy link
Author

zhipuch commented Jan 12, 2025

@zhipuch Could you elaborate about the logic issues?

Since the hf-format glm model is a llama-style one, I don't think we should copy most of code from llama.py, this will increase the difficulty of maintaining.

OK, I revisited the issue and found the main bug now:

  1. layer.self_attn.rotary_emb.rotary_dim //= 2,lead to rotary_dim is 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, .....
  2. if layer.self_attn.rotary_emb.rotary_dim = self.config.head_dim / 2, since the get_rope function has already been initialized, this statement will simply change its parameters.
    So,I tried the following code and it worked. If you have better ideas, please share them with me:
    layer.self_attn.rotary_emb = get_rope(
    self.config.head_dim,
    rotary_dim=self.config.head_dim / 2,
    max_position=self.config.max_position_embeddings,
    base=self.config.rope_theta,
    rope_scaling=None,
    is_neox_style=False,
    )
    layer.self_attn.o_proj.bias = None
    layer.self_attn.o_proj.skip_bias_add = True

@Isotr0py
Copy link
Collaborator

Isotr0py commented Jan 12, 2025

Oh, my bad, rotary_dim is used to calculate inverse frequency and cos sin cache in initialization, I didn't realize this before. 😂

I‘m fine to use get_rope to re-initialize rotary_embedding if it's compatible with torch.compile.

Copy link

mergify bot commented Feb 8, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @zhipuch.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants