-
Notifications
You must be signed in to change notification settings - Fork 14.2k
model: support GLM4V vision encoder #18042
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
Changes from 22 commits
b24d366
7b13c8e
f3f8fb4
4e81ab4
306f342
6a6e301
c78c2e3
037e76e
b4e65dc
7d6a1e0
5047d8e
ad85426
f00127e
1514734
cadaedb
4a0b89a
d00d11e
f8aad31
8700158
33fb59a
c8fd94f
785ccf4
7d53c0f
b81c03c
dd66aba
35ad5a5
f969d4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1685,7 +1685,8 @@ void llama_model::load_hparams(llama_model_loader & ml) { | |
| } break; | ||
| case LLM_ARCH_GLM4: | ||
| { | ||
| ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps); | ||
| ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps); | ||
| ml.get_key_or_arr(LLM_KV_ROPE_DIMENSION_SECTIONS, hparams.rope_sections, 4, false); | ||
| switch (hparams.n_layer) { | ||
| case 40: type = LLM_TYPE_9B; break; | ||
| case 61: type = LLM_TYPE_32B; break; | ||
|
|
@@ -1694,8 +1695,9 @@ void llama_model::load_hparams(llama_model_loader & ml) { | |
| } break; | ||
| case LLM_ARCH_GLM4_MOE: | ||
| { | ||
| ml.get_key(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp); | ||
| ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps); | ||
| ml.get_key(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp); | ||
| ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps); | ||
| ml.get_key_or_arr(LLM_KV_ROPE_DIMENSION_SECTIONS, hparams.rope_sections, 4, false); | ||
|
|
||
| // MoE parameters | ||
| ml.get_key(LLM_KV_EXPERT_COUNT, hparams.n_expert); | ||
|
|
@@ -7758,7 +7760,6 @@ llama_rope_type llama_model_rope_type(const llama_model * model) { | |
| case LLM_ARCH_DEEPSEEK2: | ||
| case LLM_ARCH_PLM: | ||
| case LLM_ARCH_CHATGLM: | ||
| case LLM_ARCH_GLM4: | ||
| case LLM_ARCH_GRANITE: | ||
| case LLM_ARCH_GRANITE_MOE: | ||
| case LLM_ARCH_GRANITE_HYBRID: | ||
|
|
@@ -7820,7 +7821,6 @@ llama_rope_type llama_model_rope_type(const llama_model * model) { | |
| case LLM_ARCH_LFM2: | ||
| case LLM_ARCH_LFM2MOE: | ||
| case LLM_ARCH_SMALLTHINKER: | ||
| case LLM_ARCH_GLM4_MOE: | ||
| case LLM_ARCH_SEED_OSS: | ||
| case LLM_ARCH_GROVEMOE: | ||
| case LLM_ARCH_APERTUS: | ||
|
|
@@ -7837,6 +7837,11 @@ llama_rope_type llama_model_rope_type(const llama_model * model) { | |
| case LLM_ARCH_QWEN3VLMOE: | ||
| return LLAMA_ROPE_TYPE_IMROPE; | ||
|
|
||
| case LLM_ARCH_GLM4: | ||
| return model->hparams.use_mrope() ? LLAMA_ROPE_TYPE_MROPE : LLAMA_ROPE_TYPE_NORM; | ||
| case LLM_ARCH_GLM4_MOE: | ||
| return model->hparams.use_mrope() ? LLAMA_ROPE_TYPE_MROPE : LLAMA_ROPE_TYPE_NEOX; | ||
|
Comment on lines
+7843
to
+7846
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the 2 models (vision and non-vision) are mostly the same, except for the rope mode, so I was quite lazy not to duplicate it into a new arch (which adds involves quite a lot of copy-paste code) I hope that we can somewhat allow de-duplicating some code via #18051 In the meantime, lmk if you're OK with keeping this hack, or a new arch is still preferable @ggerganov @CISC |
||
|
|
||
| // all model arches should be listed explicitly here | ||
| case LLM_ARCH_UNKNOWN: | ||
| GGML_ABORT("unknown architecture"); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.