You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error when saving unsloth Llama 3.1 model to GGUF format #965
I'm encountering an error while trying to save the default unsloth Llama 3.1 model to GGUF format. The issue occurs when running the code on Google Colab with a T4 GPU.
Environment:
Google Colab
T4 GPU
Default unsloth Llama 3.1 code
Changes made:
Updated API key
Updated Hugging Face username
Code snippet:
# Save to q4_k_m GGUFifTrue: model.save_pretrained_gguf("model", tokenizer, quantization_method="q4_k_m")
ifTrue: model.push_to_hub_gguf("chukypedro/testing", tokenizer, quantization_method="q4_k_m", token="api_key")
# Save to multiple GGUF options - much faster if you want multiple!ifTrue:
model.push_to_hub_gguf(
"myname/testing", # Change hf to your username!tokenizer,
quantization_method= ["q4_k_m"],
token="", # Get a token at https://huggingface.co/settings/tokens
Error traceback:
RuntimeError Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/torch/serialization.py](https://localhost:8080/#) in __exit__(self, *args)
497
498 def __exit__(self, *args) -> None:
--> 499 self.file_like.write_end_of_file()
500 if self.file_stream is not None:
501 self.file_stream.close()
RuntimeError: [enforce fail at inline_container.cc:603] . unexpected pos 576 vs 470
Expected behavior:
The model should save successfully to GGUF format without any errors.
Actual behavior:
The saving process fails with a RuntimeError, indicating an unexpected position in the file.
For vision/multimodal models, use tokenizer=processor
3- You can pass it one or several quant methods (as a list):
quantization_method = "q8_0"
or
quantization_method = ["q8_0", "q4_k_m"]
We support all the quants mentioned in this page except the iq variants.
4- If the model is supported by Ollama, it will now also automatically create a Modelfile for you that you can use to create your model in ollama using:
ollama create model_name -f ./Modelfile
5- Use push_to_hub_gguf if you want to convert to gguf and push to Huggingface Hub instead.
6- Should work for all models supported by unsloth and ollama.
7- It now fully supports linux debian and RPM variants. We are still testing windows (if someone has a windows machine and is on our discord channel ping me to help debug)
Activity
3m1rc1kk commentedon Aug 30, 2024
I have the same error, I think the disk is filling up, so either use a smaller model or become a colab pro subscriber, so the disk space increases
Ammar-Alnagar commentedon Sep 5, 2024
The pos error is a storage error , since whe. Saving as qkm , it gets saved as two files one qkm and the other as F16 and that usually fills up the space if you had a big dataset for finetuning or ran it for too many epochs.
My advice is save it as merged 16 bit then on huggingface_hub use this space to get a qkm version of your model for free.
https://huggingface.co/spaces/ggml-org/gguf-my-repo
shimmyshimmer commentedon Oct 9, 2024
Thanks for helping out @circle-games and @Ammar-Alnagar
@okoliechykwuka hopefully your issue was solved?
rolandtannous commentedon Oct 15, 2025
@Ammar-Alnagar @circle-games @okoliechykwuka
We just pushed a major fix for llamacpp integration.
1- Please make sure to update your local install of unsloth
If you're using a notebook on kaggle or colab, it should pull the latest version automatically.
2- You can now use
save_pretrained_ggufto quantize and save to GGUF format:For vision/multimodal models, use
tokenizer=processor3- You can pass it one or several quant methods (as a list):
or
We support all the quants mentioned in this page except the iq variants.
4- If the model is supported by Ollama, it will now also automatically create a
Modelfilefor you that you can use to create your model in ollama using:5- Use
push_to_hub_ggufif you want to convert to gguf and push to Huggingface Hub instead.6- Should work for all models supported by unsloth and ollama.
7- It now fully supports linux debian and RPM variants. We are still testing windows (if someone has a windows machine and is on our discord channel ping me to help debug)
Let me know if it works out for you.
Thanks!
Ammar-Alnagar commentedon Oct 20, 2025
@rolandtannous I can confirm it's fixed and working
rolandtannous commentedon Oct 23, 2025
Will be closing this for now as the issue has been resolved. Please make sure to follow the instructions given in my last response.
Meanwhile , please feel free to respond if you're still having any issues.
Thank you