-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
update: support Qwen2-57B-A14B #7835
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
284cec4
update: convert-hf-to-gguf.py to support Qwen2-57B-A14B
legraphista aa8a7cd
fix: QWEN2MOE support for expert_feed_forward_length
legraphista 06531cb
update: convert-hf-to-gguf.py cleanup for Qwen2MoeForCausalLM
legraphista d945226
fix: QWEN2MOE support for expert_feed_forward_length
legraphista File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 was this removed?
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.
not removed, but cleaned up.
add_feed_forward_length
is called bysuper().set_gguf_parameters()
as it was before my PR.add_expert_feed_forward_length
is the only new thing that is added, and is the one taken into account here https://github.com/ggerganov/llama.cpp/pull/7835/files#diff-150dc86746a90bad4fc2c3334aeb9b5887b3adad3cc1459446717638605348efR5814 and here https://github.com/ggerganov/llama.cpp/pull/7835/files#diff-150dc86746a90bad4fc2c3334aeb9b5887b3adad3cc1459446717638605348efR5820since
LLM_KV_EXPERT_FEED_FORWARD_LENGTH
is the only one taken into account, if felt irrelevant to setLLM_KV_FEED_FORWARD_LENGTH
fromshared_expert_intermediate_size
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 see.
However, looking at
Qwen1.5-MoE-A2.7B
sconfig.json
:and
Qwen2-57B-A14B
has the following values:Although I'm still not sure what Qwen2's
intermediate_size
refers to, since we are now keeping that asfeed_forward_length
, would it not make sense to storeshared_expert_intermediate_size
also?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.
Not sure as what though, @ggerganov any thoughts?
Trying to see if there are any good docs on these values...
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'm unsure what
intermediate_size
is either. ForQwen1.5-MoE-A2.7B
the values look correct, that's why I'm inclined to say thatintermediate_size = 18944
could have been a mistake.As for storing
shared_expert_intermediate_size
, I see no specific slot for it, apart from overridingLLM_KV_FEED_FORWARD_LENGTH
which might not be the best option (even tho' it's unused)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.
@CISC What do you think the next steps should be?
We can leave this PR as is since it works, and then start a new one with a proper impl?
Otherwise, adding
mlp_only_layers: int[]
,shared_expert_intermediate_size: int
anddecoder_sparse_step: int
to the config (and converter) is probably out of scope.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 adding a
shared_expert_feed_forward_length
is within the scope of this PR.The sparse layer stuff should be another PR.
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.
Ok, would you like to simply override
LLM_KV_FEED_FORWARD_LENGTH
withshared_expert_intermediate_size
or create a new one, sayLLM_KV_SHARED_EXPERT_FEED_FORWARD_LENGTH
?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.
The latter since you need to keep the original value for the other PR. Or, well, at least it will make things a little less confusing.
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.
@legraphista I've had to deal with models which have both MoE layers and MLP-only layers in #7531 (Jamba). A new metadata key-value pair is not needed to identify these layers. The easy way is to check for the presence of
layers.ffn_gate_inp
, which is only there on MoE layers, and when building the compute graph,build_llama
can be a good inspiration for how to check this per-layer.