Repository navigation
Description
@danielhanchen Hi Daniel, thanks for your work!
having an error just like in the issue #275, but this time while trying to save tuned version of unsloth/gemma-2-9b-it-bnb-4bit.
model.save_pretrained_gguf("gemma_gguf_4bit", tokenizer, quantization_method = "q4_k_m")
error:
Traceback (most recent call last):
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 3668, in
main()
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 3661, in main
model_instance.write()
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 400, in write
self.prepare_metadata(vocab_only=False)
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 393, in prepare_metadata
self.set_vocab()
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 2514, in set_vocab
self._set_vocab_sentencepiece()
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 683, in _set_vocab_sentencepiece
tokens, scores, toktypes = self._create_vocab_sentencepiece()
File "/content/gemma_gguf_4bit/llama.cpp/convert_hf_to_gguf.py", line 700, in _create_vocab_sentencepiece
raise FileNotFoundError(f"File not found: {tokenizer_path}")
FileNotFoundError: File not found: gemma_gguf_4bit/tokenizer.model
RuntimeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 model.save_pretrained_gguf("gemma_gguf_4bit", tokenizer, quantization_method = "q4_k_m")
1 frames
/usr/local/lib/python3.10/dist-packages/unsloth/save.py in save_to_gguf(model_type, model_dtype, is_sentencepiece, model_directory, quantization_method, first_conversion, _run_installer)
1110 )
1111 else:
-> 1112 raise RuntimeError(
1113 f"Unsloth: Quantization failed for {final_location}\n"
1114 "You might have to compile llama.cpp yourself, then run this again.\n"\
Activity
danielhanchen commentedon Jul 20, 2024
I'll investigate - thanks for reporting
eliasecchig commentedon Aug 22, 2024
+1 getting the same error with Gemma2 only models. This is not happening with LLama3
eliasecchig commentedon Aug 22, 2024
A workaround I found was to pull the tokenizer.model from HF https://huggingface.co/google/gemma-2b-it/blob/main/tokenizer.model
@danielhanchen
danielhanchen commentedon Aug 24, 2024
Will prioritize this!
kholiavko-roman commentedon Sep 13, 2024
I am having the same issue with gemma2.
Could you please clarify, do you mean to take original google model
google/gemma-2b-itas a base model?kholiavko-roman commentedon Sep 13, 2024
I am using gemma2 9b, and I tried to pull it from
google/gemma-2-9b-itbut still was not able to save fine-tuned model as GGUF.
kholiavko-roman commentedon Sep 20, 2024
@danielhanchen any chance that this could be fixed soon?
kupletist commentedon Sep 26, 2024
+1...
danielhanchen commentedon Oct 1, 2024
@kholiavko-roman @kupletist Apologies on the delay - I just tried saving to GGUF again via Colab for Gemma 2 and it functions fine - see https://colab.research.google.com/drive/1oImvTXhxHig-_6G2nq0qz7d7KScw_Lir?usp=sharing
kholiavko-roman commentedon Oct 10, 2024
It works, thank you!
kholiavko-roman commentedon Oct 14, 2024
Weird, I tried before with
google/gemma-2-9b-itas base model and it worked fine.Now my training has failed because I tried set the base model as
unsloth/gemma-2-9band I received an error while quantization:danielhanchen commentedon Oct 18, 2024
Oh so Gemma-2 Base does not work - weird I'll check
danielhanchen commentedon Oct 20, 2024
@kholiavko-roman Weird I just did Gemma 2 base, and it worked OK - https://huggingface.co/danielhanchen/gemma2_test
kholiavko-roman commentedon Oct 21, 2024
Yeah, yesterday I tried
unsloth/gemma-2b-it-bnb-4bitand it works okay.kholiavko-roman commentedon Oct 21, 2024
Something weird is going on, I just tried to run your example received an error
yesterday it worked fine.
kholiavko-roman commentedon Oct 21, 2024
I changed from
@nightlyunsloth version to!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"and the previous error disappeared, but I still failed to save guff files as in my previous message :(
init-22 commentedon Oct 22, 2024
Hey there
I tried running the above code provided by @danielhanchen in my local machine and it worked! is this problem related to colab only?
kholiavko-roman commentedon Oct 22, 2024
Hmmm.. probably, I just tried today but with @nightly unsloth I still not unable to run the training on the colab.
init-22 commentedon Oct 22, 2024
yes. tried the same on colab and got the TypeError: 'NoneType' object is not callable error! I think you mentioned this can be solved with Nightly, but since this error doesnt occure in local envs probably some of the dependencies is causing the issue!
Does it work after following the instruction in error?
git clone --recursive https://github.com/ggerganov/llama.cpp
cd llama.cpp && make clean && make all -j
kholiavko-roman commentedon Oct 23, 2024
Today I received an error
TypeError: 'NoneType' object is not callableeven with the regular, not nightly unsloth version, probably it was a new release today
!pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"It seems like something was broken in today's release.
I managed to run the notebook only with prev unsloth version:
!pip uninstall unsloth -y && pip install --upgrade --no-cache-dir "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git@1f52468"kholiavko-roman commentedon Oct 23, 2024
@init-22 I tried to run
As you suggested before saving the model, but the error is still the same, unfortunately.
kholiavko-roman commentedon Oct 24, 2024
Today with the latest version of unsloth I finally can save my model as guff. Thank you.
kholiavko-roman commentedon Oct 24, 2024
But after training on my custom dataset, which I loaded from a JSON file, it failed again to save guff. Do you have any idea why?
FileNotFoundError: File not found: username/gemma-test-gguf/tokenizer.modeldanielhanchen commentedon Oct 27, 2024
@init-22 @kholiavko-roman Apologies a lot on the delay - I fixed the NoneType issue - so please update Unsloth via
pip install --upgrade --no-cache-dir --no-deps unsloth@kholiavko-roman So it works on the first time, then fails the 2nd time for GGUF?
kholiavko-roman commentedon Oct 28, 2024
Thank you. I saw in Discord that the problem with NoneType was fixed.
Not exactly. I tried a lot of times because I could not save my test train, and I found out that it works okay when I use the alpaca prompt from example:
In this case, everything is fine, and I can save the guff.
But if am trying to use another chat template it fails to save the GGUF
The most interesting thing that if I ran the
alpaca_promptfirst, save the model, then I can go back and edit chat template to what I want and it would be possible to save GGUF without errors. But if I tried to run the second example with llama-3 chat template first it always failed with errorFileNotFoundError: File not found: username/gemma-test-gguf/tokenizer.modelI apologize if it seems confusing at first glance, but this is what I discovered.
It sounds like some kind of a glitch, but every time I tried on fresh instance of google colab.
rolandtannous commentedon Oct 15, 2025
@allohamora @elia-secchi @eliasecchig @init-22 @kholiavko-roman @kupletist
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 how this goes for you
Thanks!
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