Skip to content

Commit 52d2ed6

Browse files
committed
fix: Avoid architecture-specific checks for Granite MoE Shared
This is a cleaner way that will allow more flexibility in architecture strings going forward. Branch: GraniteMoEShared Signed-off-by: Gabe Goodhart <[email protected]>
1 parent 9763c9a commit 52d2ed6

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/llama-model.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,9 +1388,7 @@ void llama_model::load_hparams(llama_model_loader & ml) {
13881388
}
13891389

13901390
// For Granite MoE Shared
1391-
if (arch == LLM_ARCH_GRANITE_MOE_SHARED) {
1392-
ml.get_key(LLM_KV_EXPERT_SHARED_FEED_FORWARD_LENGTH, hparams.n_ff_shexp);
1393-
}
1391+
ml.get_key(LLM_KV_EXPERT_SHARED_FEED_FORWARD_LENGTH, hparams.n_ff_shexp, /* required */ false);
13941392
} break;
13951393
case LLM_ARCH_CHAMELEON:
13961394
{
@@ -1777,7 +1775,7 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
17771775
layer.ffn_up_exps = create_tensor(tn(LLM_TENSOR_FFN_UP_EXPS, "weight", i), {n_embd, n_ff, n_expert}, 0);
17781776

17791777
// For Granite MoE Shared
1780-
if (arch == LLM_ARCH_GRANITE_MOE_SHARED) {
1778+
if (hparams.n_ff_shexp > 0) {
17811779
layer.ffn_gate_shexp = create_tensor(tn(LLM_TENSOR_FFN_GATE_SHEXP, "weight", i), {n_embd, hparams.n_ff_shexp}, 0);
17821780
layer.ffn_up_shexp = create_tensor(tn(LLM_TENSOR_FFN_UP_SHEXP, "weight", i), {n_embd, hparams.n_ff_shexp}, 0);
17831781
layer.ffn_down_shexp = create_tensor(tn(LLM_TENSOR_FFN_DOWN_SHEXP, "weight", i), {hparams.n_ff_shexp, n_embd}, 0);
@@ -4688,7 +4686,7 @@ struct llm_build_llama : public llm_graph_context {
46884686
cb(moe_out, "ffn_moe_out", il);
46894687

46904688
// For Granite MoE Shared
4691-
if (model.arch == LLM_ARCH_GRANITE_MOE_SHARED) {
4689+
if (hparams.n_ff_shexp > 0) {
46924690
ggml_tensor * ffn_shexp = build_ffn(cur,
46934691
model.layers[il].ffn_up_shexp, NULL, NULL,
46944692
model.layers[il].ffn_gate_shexp, NULL, NULL,

0 commit comments

Comments
 (0)