@@ -938,7 +938,7 @@ void llama_model::load_hparams(llama_model_loader & ml) {
938
938
break;
939
939
case LLM_ARCH_LLADA_MOE:
940
940
{
941
- ml.get_key(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp, false);
941
+ ml.get_key(LLM_KV_EXPERT_FEED_FORWARD_LENGTH, hparams.n_ff_exp, false);
942
942
943
943
ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps);
944
944
// diffusion language model uses non-causal attention
@@ -2407,6 +2407,9 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
2407
2407
output_norm = create_tensor(tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd}, 0);
2408
2408
output = create_tensor(tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, 0);
2409
2409
2410
+ GGML_ASSERT(n_expert > 0 && "n_expert must be > 0 for llada-moe");
2411
+ GGML_ASSERT(n_expert_used > 0 && "n_expert_used must be > 0 for llada-moe");
2412
+
2410
2413
for (int i = 0; i < n_layer; ++i) {
2411
2414
auto & layer = layers[i];
2412
2415
@@ -2423,13 +2426,6 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
2423
2426
2424
2427
layer.ffn_gate_inp = create_tensor(tn(LLM_TENSOR_FFN_GATE_INP, "weight", i), {n_embd, n_expert}, 0);
2425
2428
2426
- if (n_expert == 0) {
2427
- throw std::runtime_error("n_expert must be > 0");
2428
- }
2429
- if (n_expert_used == 0) {
2430
- throw std::runtime_error("n_expert_used must be > 0");
2431
- }
2432
-
2433
2429
const int64_t n_ff_exp = hparams.n_ff_exp ? hparams.n_ff_exp : n_ff / n_expert_used;
2434
2430
2435
2431
layer.ffn_gate_exps = create_tensor(tn(LLM_TENSOR_FFN_GATE_EXPS, "weight", i), { n_embd, n_ff_exp, n_expert}, 0);
@@ -12535,15 +12531,15 @@ struct llm_build_llada_moe : public llm_graph_context {
12535
12531
cb(Vcur, "Vcur", il);
12536
12532
12537
12533
Qcur = ggml_reshape_3d(ctx0, Qcur, n_embd_head, n_head, n_tokens);
12534
+ Kcur = ggml_reshape_3d(ctx0, Kcur, n_embd_head, n_head_kv, n_tokens);
12535
+ Vcur = ggml_reshape_3d(ctx0, Vcur, n_embd_head, n_head_kv, n_tokens);
12536
+
12538
12537
Qcur = build_norm(Qcur, model.layers[il].attn_q_norm, NULL, LLM_NORM_RMS, il);
12539
12538
cb(Qcur, "Qcur_normed", il);
12540
12539
12541
- Kcur = ggml_reshape_3d(ctx0, Kcur, n_embd_head, n_head_kv, n_tokens);
12542
12540
Kcur = build_norm(Kcur, model.layers[il].attn_k_norm, NULL, LLM_NORM_RMS, il);
12543
12541
cb(Kcur, "Kcur_normed", il);
12544
12542
12545
- Vcur = ggml_reshape_3d(ctx0, Vcur, n_embd_head, n_head_kv, n_tokens);
12546
-
12547
12543
Qcur = ggml_rope_ext(
12548
12544
ctx0, Qcur, inp_pos, nullptr,
12549
12545
n_rot, rope_type, n_ctx_orig, freq_base, freq_scale,
0 commit comments