[GH-ISSUE #4148] Importing a Mistral finetune into Ollama fails with invalid file magic #2577

Open
opened 2026-04-12 12:55:18 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @BruceMacD on GitHub (May 4, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/4148

What is the issue?

Importing a custom Mistral-7B finetune into Ollama from safetensors fails with invalid file magic. Converting the same safetensors to gguf with llama.cpp works on import.

Steps to reproduce:

  • Finetune Mistral with MLX, fuse the lora to the model to get the resulting safetensors.
  • Create the modelfile:
FROM ./model
TEMPLATE """[INST] {{ .System }} {{ .Prompt }} [/INST]"""
PARAMETER stop "[INST]"
PARAMETER stop "[/INST]"
  • Import the model
❯ ollama create my-finetune -f ~/models/my-finetune/Modelfile
transferring model data 
unpacking model metadata 
processing tensors 
creating model layer 
Error: invalid file magic

This Modelfile works, after converting the safetensors with llama.cpp:

FROM ./ggml-model-Q4_K_M.gguf
TEMPLATE """[INST] {{ .System }} {{ .Prompt }} [/INST]"""
PARAMETER stop "[INST]"
PARAMETER stop "[/INST]"

OS

macOS

GPU

No response

CPU

No response

Ollama version

0.1.33

Originally created by @BruceMacD on GitHub (May 4, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/4148 ### What is the issue? Importing a custom Mistral-7B finetune into Ollama from safetensors fails with `invalid file magic`. Converting the same safetensors to gguf with llama.cpp works on import. Steps to reproduce: - Finetune Mistral with MLX, fuse the lora to the model to get the resulting safetensors. - Create the modelfile: ``` FROM ./model TEMPLATE """[INST] {{ .System }} {{ .Prompt }} [/INST]""" PARAMETER stop "[INST]" PARAMETER stop "[/INST]" ``` - Import the model ``` ❯ ollama create my-finetune -f ~/models/my-finetune/Modelfile transferring model data unpacking model metadata processing tensors creating model layer Error: invalid file magic ``` This Modelfile works, after converting the safetensors with llama.cpp: ``` FROM ./ggml-model-Q4_K_M.gguf TEMPLATE """[INST] {{ .System }} {{ .Prompt }} [/INST]""" PARAMETER stop "[INST]" PARAMETER stop "[/INST]" ``` ### OS macOS ### GPU _No response_ ### CPU _No response_ ### Ollama version 0.1.33
GiteaMirror added the bug label 2026-04-12 12:55:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#2577