Skip to content

Error when saving finetuned Gemma3: save_to_gguf_generic() got an unexpected keyword argument 'quantization_method' #2209

Closed

Description

@phiwi

I don't know if this issue is specific to Gemma3:27b finetuning, but when running

    model.save_pretrained_gguf(
        f"{sft_model_path}.GGUF",
        tokenizer,
        quantization_method=["q4_k_m", "q8_0"]
    )

After finetuning, the script runs into save_to_gguf_generic() got an unexpected keyword argument 'quantization_method'.

Activity

  1. quissuiven commented on Mar 28, 2025

    @quissuiven

    I'm encountering the same error! I'm trying to convert my fine-tuned QwenVL 2.5 7B to gguf

  2. weoieoeo commented on Mar 28, 2025

    @weoieoeo

    This issue appears to be a duplicate of [(https://github.com//issues/1504)]. But thanks for reporting, that also Gemma3 is affected.

  3. ggeo commented on Apr 4, 2025

    @ggeo

    I got the exact same error using:

    model.save_pretrained_gguf("./data/model_final_4", tokenizer, quantization_method = "q4_k_m")

    I used gemma model for training:

    "unsloth/gemma-3-4b-it-unsloth-bnb-4bit"

  4. phiwi commented on Apr 7, 2025

    @phiwi
    Author

    Any fix/workaround for this?

  5. mischaelschill commented on Apr 9, 2025

    @mischaelschill

    For vision models, the actual function which is called with save_pretrained_gguf is the following:
    def save_to_gguf_generic(
    model,
    save_directory,
    quantization_type = "Q8_0",
    repo_id = None,
    token = None,
    )

    quantization_method becomes quantization_type, the tokenizer is not an argument.

  6. pySilver commented on Apr 9, 2025

    @pySilver

    @mischaelschill you got it working? I've tried to use save_to_gguf_generic but it complains RuntimeError: Unsloth: config.jsondoes not exist insidelora_model_v2. I assume I have to merge model first?

  7. mischaelschill commented on Apr 9, 2025

    @mischaelschill

    Yes. I just called model.save_pretrained_gguf(dir_path, quantization_type="f16")

    However, it only supports b/f16, f32, and q8_0, not q4_k_m, so the output is big. Also, it is split, so it needs to be merged before it can be used with ollama, and there is no Modelfile.

    I had the issue with mistral-smalll-3.1, I do not know whether it works with gemma-3

  8. fish4terrisa-MSDSM commented on Apr 10, 2025

    @fish4terrisa-MSDSM

    Yes. I just called model.save_pretrained_gguf(dir_path, quantization_type="f16")

    However, it only supports b/f16, f32, and q8_0, not q4_k_m, so the output is big. Also, it is split, so it needs to be merged before it can be used with ollama, and there is no Modelfile.

    I had the issue with mistral-smalll-3.1, I do not know whether it works with gemma-3

    Also got the the same error with olmo2.

  9. AbhayaHanuma commented on Apr 19, 2025

    @AbhayaHanuma

    @mischaelschill you got it working? I've tried to use save_to_gguf_generic but it complains RuntimeError: Unsloth: config.jsondoes not exist insidelora_model_v2. I assume I have to merge model first?

    Are you able to resolve this? I am facing the similar issue with qwen2

  10. fish4terrisa-MSDSM commented on Apr 19, 2025

    @fish4terrisa-MSDSM

    @mischaelschill you got it working? I've tried to use save_to_gguf_generic but it complains RuntimeError: Unsloth: config.jsondoes not exist insidelora_model_v2. I assume I have to merge model first?

    Are you able to resolve this? I am facing the similar issue with qwen2

    A quick fix:
    change these lines:

    unsloth/unsloth/save.py

    Lines 2503 to 2504 in 73d6fb2

    if not vision:
    if hasattr(model, "config"):

    to

        if True:
            if True:
    

    (At least it worked for me :))

  11. kholiavko-roman commented on Jun 27, 2025

    @kholiavko-roman

    Still having the same issue on

    unsloth/gemma-3-1b-it-unsloth-bnb-4bit

    TypeError: save_to_gguf_generic() got an unexpected keyword argument 'quantization_method'
    Traceback (most recent call last):
      File "/home/user/project/train/train.py", line 184, in <module>
        main()
      File "/home/user/project/train/train.py", line 168, in main
        model.push_to_hub_gguf(
      File "/home/user/.local/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
        return func(*args, **kwargs)
    TypeError: save_to_gguf_generic() got an unexpected keyword argument 'quantization_method'
    
  12. behroozazarkhalili commented on Jul 19, 2025

    @behroozazarkhalili

    The issue persists. Could you please reopen it and work towards a resolution?

    1. Did you update? Yes
    2. Colab or Kaggle or local / cloud: Remote Server
    3. Number GPUs used, use nvidia-smi: 1
    4. Which notebook? Gemini-1B-GRPO
    5. Which Unsloth version, TRL version, transformers version, PyTorch version?
    transformers: 4.53.2
    unsloth: 2025.7.3
    numpy: 1.26.4
    bitsandbytes: 0.46.1
    peft: 0.15.2
    vllm: 0.9.2
    
  13. rolandtannous commented on Oct 15, 2025

    @rolandtannous
    Contributor

    @FierceHero @chrisjohnson00 @ejektaflex @fish4terrisa-MSDSM @ggeo @kholiavko-roman @mischaelschill @phiwi @pySilver @quissuiven @weoieoeo @yaneivan

    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 solve your problems while saving to GGUF.
    Let me know how it goes for you.

    Thanks!

  14. 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

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

    bugfixed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions