Skip to content

Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook unsloth/gemma-3-1b-it-unsloth-bnb-4bit #2058

Closed

Description

@bx0-0

After fine-tuning unsloth/gemma-3-1b-it-unsloth-bnb-4bit on Kaggle, the GGUF conversion process completes successfully, but the model fails to upload to Hugging Face, throwing the following error:

RuntimeError: Unsloth: Failed to convert llama.cpp/unsloth_convert_hf_to_gguf.py to GGUF.

Console Output Before the Error

Unsloth: GGUF conversion: 100%
100/100 [00:08<00:00, 10.28it/s, 2.00G/2.00G]

Unsloth: GGUF conversion: 100%
100/100 [00:09<00:00, 10.51it/s, 2.00G/2.00G]

Even though the GGUF file is created successfully, the upload to Hugging Face fails when running:

model.push_to_hub_gguf(
    "gemma-3-finetune",
    quantization_type = "F16", # Only Q8_0, BF16, F16 supported
    repo_id = "",
    token = "your_hf_token",
)

Key Observations

  1. Conversion Completes, but Upload Fails

    • The GGUF file is visible in the output directory, but the push_to_hub_gguf() function fails.
  2. Potential Fix Needed

    • Running the following before GGUF conversion is mandatory, otherwise, another error appears:
    if True: # Change to True to save finetune!
        model.save_pretrained_merged("gemma-3-finetune", tokenizer)
    • If this step is skipped, an error occurs RuntimeError: Unsloth: gemma-3-finetune does not exist? when attempting to convert to GGUF.

✅ Is this an issue with push_to_hub_gguf(), or does Unsloth have specific upload limitations?
✅ Is there a manual way to upload the GGUF file to Hugging Face if push_to_hub_gguf() fails?

Reference Notebook:

[Kaggle Notebook for Fine-Tuning Gemma 3B](https://www.kaggle.com/notebooks/welcome?src=https://github.com/unslothai/notebooks/blob/main/nb/Kaggle-Gemma3_(4B).ipynb&accelerator=nvidiaTeslaT4)

Any insights or fixes would be greatly appreciated!

Activity

  1. changed the title [-]Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook[/-] [+]Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook `unsloth/gemma-3-1b-it-unsloth-bnb-4bit`[/+] on Mar 17, 2025
  2. changed the title [-]Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook `unsloth/gemma-3-1b-it-unsloth-bnb-4bit`[/-] [+]### **Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook** `unsloth/gemma-3-1b-it-unsloth-bnb-4bit`[/+] on Mar 17, 2025
  3. changed the title [-]### **Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook** `unsloth/gemma-3-1b-it-unsloth-bnb-4bit`[/-] [+]Error While Converting & Uploading GGUF Model After Fine-Tuning in Kaggle Notebook `unsloth/gemma-3-1b-it-unsloth-bnb-4bit`[/+] on Mar 17, 2025
  4. yungfu commented on Mar 17, 2025

    @yungfu

    I got a similar error on Gemma3(Cuda toolkit 12.4),
    when model.save_pretrained_gguf("./save_dir", tokenizer, quantization_type="f16"), got error

    TypeError: save_to_gguf_generic() got multiple values for argument 'quantization_type'

    When model.save_pretrained_gguf("./save_dir", tokenizer, ), use default qunatization_type, got error

    AssertionError:
    --> 595 assert(type(quantization_type) is str)

  5. bx0-0 commented on Mar 18, 2025

    @bx0-0
    Author

    @shimmyshimmer Is there any solution for this now?

  6. hcstubbe commented on Mar 28, 2025

    @hcstubbe

    I got a similar error on Gemma3(Cuda toolkit 12.4), when model.save_pretrained_gguf("./save_dir", tokenizer, quantization_type="f16"), got error

    TypeError: save_to_gguf_generic() got multiple values for argument 'quantization_type'

    When model.save_pretrained_gguf("./save_dir", tokenizer, ), use default qunatization_type, got error

    AssertionError:
    --> 595 assert(type(quantization_type) is str)

    You receive this error, because the save_to_gguf_generic receives quantization_type in the second positon, and then you add quantization_type="f16". You can fix this by removing the tokenizer like so: model.save_pretrained_gguf("./save_dir", quantization_type="f16"). The method has been updated and does not accept the tokenizer anymore.

  7. rolandtannous commented on Oct 15, 2025

    @rolandtannous
    Contributor

    @bx0-0 @yungfu

    We just pushed a major fix for llamacpp integration.

    1- Please make sure to update your local install of unsloth

    pip install --force-reinstall --no-deps unsloth-zoo 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_gguf to quantize and save to GGUF format:

    model.save_pretrained_gguf(
                save_directory,
                tokenizer=tokenizer,
                quantization_method=quantization_method,
            )
    

    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)

    This should now work.
    Let me know how it goes for you.

    Thanks!

  8. rolandtannous commented on Oct 23, 2025

    @rolandtannous
    Contributor

    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

  9. samanta-sc commented on Nov 8, 2025

    @samanta-sc

    For pushing push to Huggingface Hub, just removing repo_id arguments works totally fine.
    Like this:

    model.push_to_hub_gguf(
        "gemma-3-finetune",
        quantization_type = "F16", # Only Q8_0, BF16, F16 supported
        token = "your_hf_token",
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions