diff --git a/convert_hf_to_gguf.py b/convert_hf_to_gguf.py index 2e4645e81c73..ca03d09a8291 100755 --- a/convert_hf_to_gguf.py +++ b/convert_hf_to_gguf.py @@ -7388,6 +7388,8 @@ def set_gguf_parameters(self): rope_dim = int(self.hparams["head_dim"] * self.hparams["partial_rotary_factor"]) self.gguf_writer.add_rope_dimension_count(rope_dim) + self.gguf_writer.add_layer_norm_rms_eps(self.hparams.get("layernorm_epsilon", 1e-5)) + _experts: list[dict[str, Tensor]] | None = None def modify_tensors(self, data_torch, name, bid): @@ -7433,6 +7435,15 @@ def modify_tensors(self, data_torch, name, bid): return [] return [(self.map_tensor_name(name), data_torch)] + def prepare_tensors(self): + super().prepare_tensors() + + if self._experts is not None: + # flatten `list[dict[str, Tensor]]` into `list[str]` + experts = [k for d in self._experts for k in d.keys()] + if len(experts) > 0: + raise ValueError(f"Unprocessed experts: {experts}") + @ModelBase.register("PanguEmbeddedForCausalLM") class PanguEmbeddedModel(TextModel): diff --git a/src/llama-model.cpp b/src/llama-model.cpp index 1466283c74e0..a32e1c2806dd 100644 --- a/src/llama-model.cpp +++ b/src/llama-model.cpp @@ -2341,6 +2341,8 @@ void llama_model::load_hparams(llama_model_loader & ml) { } break; case LLM_ARCH_MIMO2: { + ml.get_key(LLM_KV_ATTENTION_LAYERNORM_RMS_EPS, hparams.f_norm_rms_eps); + hparams.swa_type = LLAMA_SWA_TYPE_STANDARD; hparams.rope_freq_base_train_swa = 10000.0f; diff --git a/src/models/mimo2-iswa.cpp b/src/models/mimo2-iswa.cpp index 3335fe841df8..edc87cc9f0d3 100644 --- a/src/models/mimo2-iswa.cpp +++ b/src/models/mimo2-iswa.cpp @@ -88,17 +88,10 @@ llm_build_mimo2_iswa::llm_build_mimo2_iswa(const llama_model & model, const llm_ cb(cur, "ffn_out", il); } else { // MoE branch - cur = build_moe_ffn(cur, - model.layers[il].ffn_gate_inp, - model.layers[il].ffn_up_exps, - model.layers[il].ffn_gate_exps, - model.layers[il].ffn_down_exps, - nullptr, - n_expert, n_expert_used, - LLM_FFN_SILU, true, - false, 0.0, - LLAMA_EXPERT_GATING_FUNC_TYPE_SIGMOID, - il); + cur = build_moe_ffn(cur, model.layers[il].ffn_gate_inp, model.layers[il].ffn_up_exps, + model.layers[il].ffn_gate_exps, model.layers[il].ffn_down_exps, + model.layers[il].ffn_exp_probs_b, n_expert, n_expert_used, LLM_FFN_SILU, true, false, + 0.0, LLAMA_EXPERT_GATING_FUNC_TYPE_SIGMOID, il); cb(cur, "ffn_moe_out", il); }