Skip to content

[BUG] GGUF files created from Gemma 3 models lose the 'vision' capability #2290

Closed

Description

@Mano-Wii
  1. Bug Description
    When using the colab notebook for Gemma3_(4B), notice that the model in the .gguf file, when used in ollama, does not have the 'vision' capability.

  2. Reproduction Steps:

  • Get model and tokenizer from unsloth:
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
    model_name = "unsloth/gemma-3-4b-it",
    max_seq_length = 2048, # Choose any for long context!
    load_in_4bit = True,  # 4 bit quantization to reduce memory
    load_in_8bit = False, # [NEW!] A bit more accurate, uses 2x memory
    full_finetuning = False, # [NEW!] We have full finetuning now!
    # token = "hf_...", # use one if using gated models
)

  • Save LoRA adapters (Pay attention to the directory, as you need to use the same directory to save the gguf file)
model.save_pretrained("mano-wii/gemma-3-finetune")  # Local saving
tokenizer.save_pretrained("mano-wii/gemma-3-finetune")

  • Save to GGUF
model.save_pretrained_gguf(
    "mano-wii/gemma-3-finetune",
    quantization_type = "Q8_0", # For now only Q8_0, BF16, F16 supported
)

  • Optionally send to huggingface:
from unsloth_zoo.saving_utils import prepare_saving
repo_id = "mano-wii/gemma-3-finetune-gguf"
prepare_saving(
    model,
    repo_id,
    push_to_hub = True,
    max_shard_size = "50GB",
    private = False,
    token = hf_token,
)

from huggingface_hub import HfApi
api = HfApi(token = hf_token)
api.upload_folder(
    folder_path = "mano-wii",
    repo_id = repo_id,
    repo_type = "model",
    allow_patterns = ["*.gguf"],
)
  1. Expected Behavior:
    When using the ollama show hf.co/mano-wii/gemma-3-finetune-gguf command, vision should be in Capabilities (as gemma3):
PS D:\> ollama show gemma3
  Model
    architecture        gemma3
    parameters          4.3B
    context length      8192
    embedding length    2560
    quantization        Q4_K_M

  Capabilities
    completion
    vision

  Parameters
    stop           "<end_of_turn>"
    temperature    0.1
  1. Actual Behavior:
    Note no vision in Capabilities when using ollama show hf.co/mano-wii/gemma-3-finetune-gguf:
PS D:\> ollama show hf.co/mano-wii/gemma-3-finetune-gguf
  Model
    architecture        gemma3
    parameters          3.9B
    context length      131072
    embedding length    2560
    quantization        unknown

  Capabilities
    completion

  Parameters
    stop           "<end_of_turn>"
    temperature    0.1

Activity

  1. shimmyshimmer commented on Apr 6, 2025

    @shimmyshimmer
    Member

    Can you try running them in llama.cpp and see if the vision component works there? Or try LM STudio

  2. Mano-Wii commented on Apr 6, 2025

    @Mano-Wii
    Author

    Hi @shimmyshimmer,

    I couldn't test running llama.cpp or LM STudio directly, but I was able to further understand the problem.
    I started noticing that in the process of saving to GGUF, there is this message:
    Image

    Searching the source of this message I found these other logs in llama.cpp/convert_hf_to_gguf.py:

        def write(self):
            super().write()
            if self.has_vision:
                logger.info("NOTE: this script only convert the language model to GGUF")
                logger.info("      for the vision model, please use gemma3_convert_encoder_to_gguf.py")

    So, (also following the assistance of @rolandtannous from the unsloth's help forum) I ran this command:

    !python llama.cpp/examples/llava/gemma3_convert_encoder_to_gguf.py path/to/model
    

    This generated another .gguf file of 851MB called mmproj.gguf.
    This mmproj.gguf file is the model's vision projector file, and it has to be in the same directory as the model.
    That looked promising, however, the model continued to lack vision capability.
    The only difference is that there is an error message when trying to "view" an image:

    PS D:\> ollama run hf.co/mano-wii/gemma-3-finetune-gguf
    >>> "C:\Users\Bruce\Downloads\Wayne.png"
    Added image 'C:\Users\Bruce\Downloads\Wayne.png'
    Error: Failed to create new sequence: failed to process inputs: this model is missing data required for image input
    

    I don't know exactly where the problem is. Multiple .gguf files? Some misconfiguration?
    Quantizing directly via ollama create --quantize q5_K_M $MODEL_NAME -f "$REPO_DIR/Modelfile" works.

  3. xyehya commented on Apr 14, 2025

    @xyehya

    Same issue, also if you try to load the saved 16bit MERGED fine-tuned model using FastModel, you will get a warning: Some weights of the model checkpoint at ./gemma-3-finetune were not used when initializing Gemma3ForCausalLM: ['multi_modal_projector.mm_input_projection_weight', 'multi_modal_projector.mm_soft_emb_norm.weight', 'vision_tower.vision_model.embeddings.patch_embedding.bias', 'vision_tower.vision_model.embeddings.patch_embedding.weight', 'vision_tower.vision_model.embeddings.position_embedding.weight', 'vision_tower.vision_model.encoder.layers.0.layer_norm1.bias', 'vision_tower.vision_model.encoder.layers.0.layer_norm1.weight', 'vision_tower.vision_model.encoder.layers.0.layer_norm2.bias' etc.....

    I think the problem is not in the GGUF conversion only but also in the model.save_pretrained_merged("gemma-3-finetune-full", tokenizer)

  4. histpay2 commented on May 8, 2025

    @histpay2

    I'm seeing exactly this same issue.

  5. eagle705 commented on May 8, 2025

    @eagle705

    I also encountered the same issue... what's going on..

  6. shivanis1406 commented on Jul 3, 2025

    @shivanis1406

    I am also encountering this issue with unsloth/gemma-3-12b-it-qat-GGUF:Q4_K_M used via Ollama

  7. rolandtannous commented on Jul 3, 2025

    @rolandtannous
    Contributor

    @xyehya the save_pretrained_merged has been fixed and the model retains its vision capabilities. That's no longer the issue.

    @histpay2 @eagle705 note that for llama.cpp, for now convert using the llama.cpp conversion script and beware taht you need to generate the mmproj file and the model files separately as documented here: https://github.com/ggml-org/llama.cpp/blob/master/docs/multimodal/gemma3.md

    @shivanis1406 nsloth/gemma-3-12b-it-qat-GGUF:Q4_K_M will not work with ollama because ollama requires the mmproj and model file to be fused into 1 single file, while in the repo the mmproj file is separate. This repo is intended for use with llama.cpp

  8. rolandtannous commented on Oct 15, 2025

    @rolandtannous
    Contributor

    @Mano-Wii @eagle705 @histpay2 @shivanis1406 @xyehya @younik

    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)
    Let me know how it goes for you.

    Thanks!

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

  10. youngs099 commented on Oct 24, 2025

    @youngs099

    Thanks for the update!

    I’m currently using llama.cpp to load the text model and the mmproj model separately for VQA.

    As mentioned in the July 3 comment,
    unsloth/gemma-3-12b-it-qat-GGUF:Q4_K_M cannot run on Ollama because it includes two separate GGUF files (mmproj and model), while Ollama requires them to be fused into a single GGUF file.

    I tried the updated conversion method to generate a Q4_K_M quantized version, but it still outputs two GGUF files.
    Even after quantization, Ollama still cannot perform VQA.

    Could I please ask if there is currently a way (or a planned option) to fuse the mmproj and model into a single GGUF file, so that the model can be used for VQA in Ollama?

    Thanks again for your great work!

  11. georgy7 commented on Apr 11, 2026

    @georgy7

    I have the same issue with https://huggingface.co/unsloth/Qwen3.5-27B-GGUF

    500: Failed to create new sequence: failed to process inputs: this model is missing data required for image input

    My Modelfile (modified ollama show qwen3.5:27b --modelfile):

    FROM ./Qwen3.5-27B-IQ4_XS.gguf
    TEMPLATE {{ .Prompt }}
    RENDERER qwen3.5
    PARSER qwen3.5
    PARAMETER presence_penalty 1.5
    PARAMETER temperature 1
    PARAMETER top_k 20
    PARAMETER top_p 0.95
    LICENSE """Apache License"""
    

    Output of ollama show qwen-27b-iq4xs:

      Model
        architecture        qwen35     
        parameters          26.9B      
        context length      262144     
        embedding length    5120       
        quantization        unknown    
    
      Capabilities
        completion    
        tools         
        thinking      
    
      Parameters
        presence_penalty    1.5     
        temperature         1       
        top_k               20      
        top_p               0.95    
    
      License
        Apache License    
    

    ollama version is 0.19.0

  12. xyehya commented on Apr 12, 2026

    @xyehya
  13. georgy7 commented on Apr 12, 2026

    @georgy7

    @xyehya It worked perfectly! The iq4_XS model is slightly larger after the fix, but it is still smaller than the official q4_K_M.

    ollama ps
    BEFORE                  25 GB    19%/81% CPU/GPU    131072     Forever
    AFTER                   28 GB    28%/72% CPU/GPU    131072     Forever
    qwen3.5:27b (Q4_K_M)    30 GB    31%/69% CPU/GPU    131072     Forever
    

    ollama show qwen27-iq4:

      Model
        architecture        qwen35     
        parameters          27.8B      
        context length      262144     
        embedding length    5120       
        quantization        unknown    
    
      Capabilities
        completion    
        vision        
        tools         
        thinking      
    
      Parameters
        min_p               0       
        presence_penalty    1.5     
        repeat_penalty      1       
        temperature         1       
        top_k               20      
        top_p               0.95    
    
      License
        Apache License    
    
  14. xyehya commented on Apr 12, 2026

    @xyehya

    @georgy7 glad to hear it worked!
    yes it is larger because the vision layers have been reinjected into the model. If you want to reduce VRAM usage, try setting kv cache to q8_0 in ollama configurations if not already or reduce the ctx size. having it fit 100% on GPU will make life much better!

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