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

[bug] Incorrect exported config #102

Open
RaymondLi0 opened this issue Jan 2, 2025 · 1 comment
Open

[bug] Incorrect exported config #102

RaymondLi0 opened this issue Jan 2, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@RaymondLi0
Copy link
Contributor

RaymondLi0 commented Jan 2, 2025

🐞 Describe the Bug

Exporting a model where num_heads * kv_channels != hidden_size will raise an error like:
RuntimeError: Error(s) in loading state_dict for LlamaForCausalLM: size mismatch for model.layers.0.self_attn.q_proj.weight: copying a param with shape torch.Size([3072, 4096]) from checkpoint, the shape in current model is torch.Size([4080, 4096]). size mismatch for model.layers.0.self_attn.k_proj.weight: copying a param with shape torch.Size([1024, 4096]) from checkpoint, the shape in current model is torch.Size([1360, 4096]).
when loading that model with hf tranformers.
The exported configuration misses the head_dim field. (so it is set by default to hidden_size / num_heads)

cc @nitsanluke

We should handle the kv_channels->head_dim field when exporting configs.

🔄 Steps to Reproduce

Export a model with num_heads * kv_channels != hidden_size, reload it with hf transformers.

🎯 Expected Behavior

Re-load the exported model without error.

@RaymondLi0 RaymondLi0 added the bug Something isn't working label Jan 2, 2025
@RaymondLi0 RaymondLi0 changed the title [bug] Brief description of the issue [bug] Incorrect exported config Jan 2, 2025
@jlamypoirier
Copy link
Collaborator

Was this addressed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants