]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
convert : fix conversion for Mistral-Medium-3.5-128B (#24268)
authorDavid Friehs <redacted>
Sun, 7 Jun 2026 19:41:39 +0000 (21:41 +0200)
committerGitHub <redacted>
Sun, 7 Jun 2026 19:41:39 +0000 (21:41 +0200)
Mistral explicitly sets `moe` and `llama_4_scaling` to `null` in
params.json, breaking `key in dict` checks during conversion. Replace
with `dict.get(key) is not None` where this matters.

Fixes `convert-hf-to-gguf.py --mistral-format Mistral-Medium-3.5-128B`

conversion/mistral.py
convert_hf_to_gguf.py

index 7a7d6e03933b0a197454fa28bfccaa0e939bc904..aec22ca3877cb5cd09c99c2b4513da28b5d10ed0 100644 (file)
@@ -105,8 +105,9 @@ class MistralModel(LlamaModel):
             gguf_writer.add_rope_scaling_yarn_log_mul(mscale_all_dim)
             gguf_writer.add_rope_scaling_orig_ctx_len(yarn_params["original_max_position_embeddings"])
 
-        if "llama_4_scaling" in hparams:
-            gguf_writer.add_attn_temperature_scale(hparams["llama_4_scaling"]["beta"])
+        llama_4_scaling = hparams.get("llama_4_scaling")
+        if llama_4_scaling is not None:
+            gguf_writer.add_attn_temperature_scale(llama_4_scaling["beta"])
 
 
 class MistralMoeModel(DeepseekV2Model):
index cd19eebdfa342de0ec7aa624d0e32a34e45ebb81..a6192c039a0ab8482ee6bb9bc906830fde532c7a 100755 (executable)
@@ -238,7 +238,7 @@ def main() -> None:
             assert hparams.get("vision_encoder") is not None, "This model does not support multimodal"
             from conversion.pixtral import PixtralModel
             model_class = PixtralModel
-        elif "moe" in hparams:
+        elif hparams.get("moe") is not None:
             from conversion.mistral import MistralMoeModel
             model_class = MistralMoeModel
         else: