Improve error messages

Open Beginner friendly
#2,145 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python

Research direction

The error originates in _internals.py line 58. Look at the model loading logic before that line to see what can cause failure (e.g., file not found, permissions, or format issues). Improve the error message to include the specific reason, such as checking file existence or catching underlying exceptions. Test by running the provided Colab snippet after changes.

Written by the indexing model from the issue text.

Description

Repro steps:

  1. Go to https://huggingface.co/HauhauCS/Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive
  2. Click "use this model" -> colab
  3. Run code on colab

Generated code is:

from llama_cpp import Llama

llm = Llama.from_pretrained(
	repo_id="HauhauCS/Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive",
	filename="Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive-BF16.gguf",
)

which fails with:

ValueError                                Traceback (most recent call last)

[/tmp/ipykernel_1917/696730726.py](https://localhost:8080/#) in <cell line: 0>()
      3 from llama_cpp import Llama
      4 
----> 5 llm = Llama.from_pretrained(
      6         repo_id="HauhauCS/Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive",
      7         filename="Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive-BF16.gguf",

2 frames

[/usr/local/lib/python3.12/dist-packages/llama_cpp/_internals.py](https://localhost:8080/#) in __init__(self, path_model, params, verbose)
     56 
     57         if model is None:
---> 58             raise ValueError(f"Failed to load model from file: {path_model}")
     59 
     60         vocab = llama_cpp.llama_model_get_vocab(model)

ValueError: Failed to load model from file: /root/.cache/huggingface/hub/models--HauhauCS--Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive/snapshots/53367faad177ee6a23601983cdac4308b51393df/./Qwen3.5-35B-A3B-Uncensored-HauhauCS-Aggressive-BF16.gguf

This error message is not actionable as it doesn't say why it failed to load so the user can't do much about it.

Dominant language
Python
Stars
10.6k
Forks
1.5k
Avg merge
23m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from abetlen/llama-cpp-python

All issues in abetlen/llama-cpp-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.