Skip to content

[Bug] save_pretrained_gguf() fails on Kaggle: ModuleNotFoundError: No module named 'conversion' (unsloth 2026.5.2) #5495

@rajasingh012

Description

@rajasingh012
  1. Did you update? pip install --upgrade unsloth unsloth_zoo

    Yes. Notebook installs latest at runtime:
    Successfully installed unsloth-2026.5.2 unsloth_zoo-2026.5.1

  2. Colab or Kaggle or local / cloud

    Kaggle (T4 GPU, 6hr timeout)

  3. Number GPUs used, use nvidia-smi

    1× T4 (15 GB VRAM, CUDA 12.8)

  4. Which notebook? Please link!

    Reproducer (no training, ~8 min): https://www.kaggle.com/code/rajasinghg/gguf-export-test-gemma-4-e2b-lora

    Logs showing full traceback: https://www.kaggle.com/code/rajasinghg/gguf-export-test-gemma-4-e2b-lora/log

    1. Which Unsloth version, TRL version, transformers version, PyTorch version?
    • unsloth: 2026.5.2
    • unsloth-zoo: 2026.5.1
    • transformers: 5.5.0
    • torch: 2.10.0+cu128
    • TRL: not involved (error is in GGUF export, not training)
    1. Which trainer?

    None — error is in save_pretrained_gguf(), not training.

    
    from unsloth import FastLanguageModel
    import os
    
    model, tokenizer = FastLanguageModel.from_pretrained(
        "unsloth/gemma-4-E2B-it-unsloth-bnb-4bit",
        max_seq_length=2048,
        load_in_4bit=True,
    )
    
    model = FastLanguageModel.get_peft_model(
        model, r=32, lora_alpha=32, lora_dropout=0,
        finetune_language_layers=True,
        finetune_attention_modules=True,
        finetune_mlp_modules=True,
    )
    
    model.save_pretrained_gguf(
        "/kaggle/working/out",
        tokenizer,
        quantization_method="q4_k_m",
    )
    
    
    
    Error:
    
    Unsloth: Merge process complete. Saved to /kaggle/working/out
    Unsloth: Installing llama.cpp... Successfully installed!
    Unsloth: Preparing converter script...
    
    ModuleNotFoundError: No module named 'conversion'
    
    File "/root/.unsloth/llama.cpp/original_gguf_<hash>.py", line 18
        from conversion import (
    
    
    Root cause: _download_convert_hf_to_gguf_cached() in unsloth_zoo/llama_cpp.py writes llama.cpp's convert_hf_to_gguf.py to a temp file at ~/.unsloth/llama.cpp/original_gguf_<hash>.py, then imports it via _load_module_from_path(). The llama.cpp script does from conversion import ... but Python can't resolve conversion.py because the temp file's directory is not in sys.path.
    
    Suggested fix — in _load_module_from_path(), add the script's dir to sys.path before exec_module():
script_dir = os.path.dirname(filepath)
if script_dir not in sys.path:
    sys.path.insert(0, script_dir)
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions