-
Notifications
You must be signed in to change notification settings - Fork 11
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
Makes Llama checkpoint convertion compatible with fused up/gate projection #26
base: main
Are you sure you want to change the base?
Conversation
Thanks @evellasques for the PR. Going over it! |
@@ -125,8 +126,7 @@ def convert_checkpoint(config_file, | |||
"self_attention.dense.weight": (1, "self_attn.o_proj.weight", 1, 0), | |||
"post_attention_layernorm.weight": (0, "post_attention_layernorm.weight", None, 0), | |||
"self_attention.core_attention.rotary_emb.inv_freq": (0, "self_attn.rotary_emb.inv_freq", None, 0), | |||
"mlp.dense_h_to_4h.weight": (1, "mlp.gate_proj.weight", 0, 0), | |||
"mlp.dense_h_to_4h_2.weight": (1, "mlp.up_proj.weight", 0, 0), | |||
"mlp.dense_h_to_4h.weight": (1, "mlp.gate_proj_up_proj.weight", 0, 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why considering "gate" and "up" proj to be fused for HF checkpoint? Shouldn't you split them from nemo checkpoint instead and then save as separate "gate" and "up" params for HF?
@@ -217,6 +217,13 @@ def convert_checkpoint(config_file, | |||
hf_model[hf_key_q], hf_model[hf_key_k], hf_model[hf_key_v] = torch.split(hf_model[hf_key], size_per_seg, dim=0) | |||
hf_model.pop(hf_key) | |||
|
|||
if "dense_h_to_4h" in k: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not accurate. "gate" and "proj" fusion is per tp rank in the nemo checkpoint. So, you can't first concatenate all tps and then split to "gate" and "proj". Instead you should split them for each tp rank.
Issue #, 24
Description of changes:
Recent merging of up/down projection in Llama requires the equivalent merging in the HF to NeMo conversion scripts (and subsequent splitting in the NeMo to HF script).
This change fixes that for the following converters:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.