Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Missing Sanity Check in convert_hf_to_gguf.py #9245

Closed
mesibo opened this issue Aug 29, 2024 · 2 comments · Fixed by #9397
Closed

Bug: Missing Sanity Check in convert_hf_to_gguf.py #9245

mesibo opened this issue Aug 29, 2024 · 2 comments · Fixed by #9397
Labels
bug Something isn't working low severity Used to report low severity bugs in llama.cpp (e.g. cosmetic issues, non critical UI glitches)

Comments

@mesibo
Copy link

mesibo commented Aug 29, 2024

What happened?

The script convert_hf_to_gguf.py does not perform a sanity check on the completeness of the model files. We encountered an issue where one of the models we downloaded was incomplete (specifically, a safesensors file was missing). Despite this, convert_hf_to_gguf.py proceeded with the conversion without generating any errors or warnings.

Expected Behavior: The script should validate that all required files are present before converting. Since Hugging Face downloads are organized with sequence and total files (e.g., model-00001-of-00002), it should be easy to validate.

Steps to Reproduce:

  1. Download a model from HF and delete one of the safesensors file.
  2. Run convert_hf_to_gguf.py on the incomplete set.
  3. the script completes without any indication of missing files.

Name and Version

version: 3631 (7d787ed)
built with cc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22) for x86_64-redhat-linux

What operating system are you seeing the problem on?

Linux

Relevant log output

No response

@mesibo mesibo added bug-unconfirmed low severity Used to report low severity bugs in llama.cpp (e.g. cosmetic issues, non critical UI glitches) labels Aug 29, 2024
@compilade
Copy link
Collaborator

compilade commented Sep 2, 2024

Steps to Reproduce:

  1. Download a model from HF and delete one of the safesensors file.
  2. Run convert_hf_to_gguf.py on the incomplete set.
  3. the script completes without any indication of missing files.

@mesibo

I tried, but I can't reproduce not getting an error. (tried on version 8f1d81a, but the following sanity check has been in convert_hf_to_gguf.py since #7075, which was merged almost 4 months ago)

I get

ValueError: Mismatch between weight map and model parts for tensor names:

and then a big list of missing tensors.

This comes from

https://github.com/ggerganov/llama.cpp/blob/8f1d81a0b6f50b9bad72db0b6fcd299ad9ecd48c/convert_hf_to_gguf.py#L174-L176

@compilade
Copy link
Collaborator

compilade commented Sep 2, 2024

@mesibo

I just now realized that you're right, when there's only one .safetensors detected there is no sanity check, even when there still is a model.safetensors.index.json.

So what you're describing can be reproduced by having only a single .safetensors of the model when it should have been multi-part. In my previous test I used a model with 4 parts and removed one, so it wasn't enough to reproduce the problem.

This could be improved by cross-checking the index files when present even when only a single model file is detected.

@compilade compilade added bug Something isn't working and removed bug-unconfirmed labels Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low severity Used to report low severity bugs in llama.cpp (e.g. cosmetic issues, non critical UI glitches)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants