Skip to content

Commit 8a963fc

Browse files
authored
convert : fix conversion for Mistral-Medium-3.5-128B (#24268)
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`
1 parent 379ac66 commit 8a963fc

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

conversion/mistral.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ def set_mistral_config(gguf_writer: gguf.GGUFWriter, hparams: dict):
105105
gguf_writer.add_rope_scaling_yarn_log_mul(mscale_all_dim)
106106
gguf_writer.add_rope_scaling_orig_ctx_len(yarn_params["original_max_position_embeddings"])
107107

108-
if "llama_4_scaling" in hparams:
109-
gguf_writer.add_attn_temperature_scale(hparams["llama_4_scaling"]["beta"])
108+
llama_4_scaling = hparams.get("llama_4_scaling")
109+
if llama_4_scaling is not None:
110+
gguf_writer.add_attn_temperature_scale(llama_4_scaling["beta"])
110111

111112

112113
class MistralMoeModel(DeepseekV2Model):

convert_hf_to_gguf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def main() -> None:
238238
assert hparams.get("vision_encoder") is not None, "This model does not support multimodal"
239239
from conversion.pixtral import PixtralModel
240240
model_class = PixtralModel
241-
elif "moe" in hparams:
241+
elif hparams.get("moe") is not None:
242242
from conversion.mistral import MistralMoeModel
243243
model_class = MistralMoeModel
244244
else:

0 commit comments

Comments
 (0)