Skip to content

[Bug] Issue saving my vision model from a checkpoint. #3050

Closed

Description

@hansehart
  1. Did you update? pip install --upgrade unsloth unsloth_zoo Yes
  2. Colab or Kaggle or local / cloud Local
  3. Number GPUs used, use nvidia-smi 1
  4. Which notebook? Please link! None
  5. Which Unsloth version, TRL version, transformers version, PyTorch version?
    unsloth: 2025.7.9
    transofmers: 4.53.3
    torch: 2.7.1
  6. Which trainer? SFTTrainer, GRPOTrainer etc SFTTrainer

I get this error:

TypeError: Unsloth: quantization_method can only be a string or a list of strings

It is happening here in save.py:

    if quantization_method is not None:
        # Convert quantization_method to list
        if   isinstance(quantization_method, list):  pass
        elif isinstance(quantization_method, str):   quantization_method = [ quantization_method, ]
        elif isinstance(quantization_method, tuple): quantization_method = list(quantization_method)
        else:
            raise TypeError("Unsloth: quantization_method can only be a string or a list of strings")
        pass

However my quantization_method is an object:

quantization_method = PixtralProcessor:
- image_processor: PixtralImageProcessorFast

My code is:

# Load using Unsloth
model, tokenizer = FastLanguageModel.from_pretrained(
    model_name="outputs/checkpoint-120",
    max_seq_length=2048,
    dtype=torch.float16,
    load_in_4bit=True,
)

# Push to hub
model.save_pretrained_gguf(
    "Mistral-Small-3.2",
    tokenizer,)

I use unsloth/Mistral-Small-3.2-24B-Instruct-2506

Activity

  1. rolandtannous commented on Aug 14, 2025

    @rolandtannous
    Contributor

    Hello Hanse,

    We are currently dealing with some issues related to save_pretrained_gguf that we are working on resolving. Meanwhile there is some code that uses llama.cpp that you might be able to incorporate : https://colab.research.google.com/drive/1EevDuEa_CYZt59eMGl7acB6DhlApj61O?usp=sharing

    Please take note that for vision model you might have to adjust the code i linked above to align with the docs at llama.cpp as shown here:
    https://github.com/ggml-org/llama.cpp/tree/master/docs/multimodal

    Hopefully we'll be resolving the gguf saving issues soon

  2. Deng-Xian-Sheng commented on Oct 14, 2025

    @Deng-Xian-Sheng

    Has anyone tried saving the Qwen2.5-VL-3B-Instruct and SmolVLM2 series as GGUF?

    Is it theoretically possible?

    Because both are vision models.

    I don't see any code for saving as GGUF in https://colab.research.google.com/github/unslothai/notebooks/blob/main/nb/Qwen2.5_VL_(7B)-Vision.ipynb.

    thank you

  3. Deng-Xian-Sheng commented on Oct 14, 2025

    @Deng-Xian-Sheng

    Thanks, it seems to support: gptoss, llama3.1, llama3.2, Pixtral, Gemma3n, Gemma3, Gemma2, Qwen2, Qwen2.5, Qwen3, Mistral, Phi, gpt-oss-20

    Tell others who need it

  4. Bian-Xin-Yu commented on Oct 14, 2025

    @Bian-Xin-Yu

    Wow, that's awesome!

  5. rolandtannous commented on Oct 14, 2025

    @rolandtannous
    Contributor

    @hansehart
    @Deng-Xian-Sheng (for some reason I can't tag Bian)

    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)

    Have fun

  6. Deng-Xian-Sheng commented on Oct 14, 2025

    @Deng-Xian-Sheng

    @Bian-Xin-Yu Looks like it can be marked

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 - pending confirmation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions