convert-hf : match model part name prefix and suffix #7687
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR This should fix conversion of https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3
(thanks to @teleprint-me for noticing this problem in #7379 (comment))
Before #7075,
convert-hf-to-gguf.py
checked for specific model part names according to the number of*.bin
files or*.safetensors
files.llama.cpp/convert-hf-to-gguf.py
Lines 224 to 232 in bc4bba3
But then, #7075, to fix the conversion of (some) models using
model-00001-of-00001.safetensors
instead ofmodel.safetensors
for a single model part, simply used the same logic as the part count to get the part names. That is, using only the suffix of the files.llama.cpp/convert-hf-to-gguf.py
Lines 285 to 293 in f98eb31
But this doesn't always work correctly, like when unusual additional model files like
consolidated.safetensors
in https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.3 are present.Note that the previous way it was done would still have failed, since the model count still only relied on the suffixes.
I think matching both the prefix and the suffix of the model part names should fix this problem without breaking any previously-supported upstream models.