Getting KeyError: 'U8' error in the `convert.py`
I'm getting this error in llama.cpp conversion script:
$ python3 convert.py /content/yuna-finetune
Loading model file /content/yuna-funetune/model.safetensors
Traceback (most recent call last):
File "/content/llama.cpp/convert.py", line 1295, in <module>
main()
File "/content/llama.cpp/convert.py", line 1223, in main
model_plus = load_some_model(args.model)
File "/content/llama.cpp/convert.py", line 1142, in load_some_model
models_plus.append(lazy_load_file(path))
File "/content/llama.cpp/convert.py", line 797, in lazy_load_file
return lazy_load_safetensors_file(fp, path)
File "/content/llama.cpp/convert.py", line 776, in lazy_load_safetensors_file
model = {name: convert(info) for (name, info) in header.items() if name != '__metadata__'}
File "/content/llama.cpp/convert.py", line 776, in <dictcomp>
model = {name: convert(info) for (name, info) in header.items() if name != '__metadata__'}
File "/content/llama.cpp/convert.py", line 764, in convert
data_type = SAFETENSORS_DATA_TYPES[info['dtype']]
KeyError: 'U8'
I have tried to fine-tune the model cognitivecomputations/dolphin-llama2-7b using this script: https://github.com/yukiarimo/notebooks/blob/main/llama2-finetune-own-data.ipynb
And I also got the same KeyError: 'U8' in this script:
https://github.com/yukiarimo/notebooks/blob/main/gguf-export.ipynb
But the fine-tuning worked!
See this: https://github.com/ggerganov/llama.cpp/issues/4199
One more question. I have a trained model, and to do interference, I'm using this code:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
base_model_id = "cognitivecomputations/dolphin-llama2-7b"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id, # Llama 2 7B, same as before
quantization_config=bnb_config, # Same quantization config as before
device_map="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(base_model_id, add_bos_token=True, trust_remote_code=True)
from peft import PeftModel
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-500")
eval_prompt = " The following is a note by me: \nWho are you?\n"
model_input = tokenizer(eval_prompt, return_tensors="pt").to("cuda")
ft_model.eval()
with torch.no_grad():
print(tokenizer.decode(ft_model.generate(**model_input, max_new_tokens=300)[0], skip_special_tokens=True))
So, basically, I'm applying my LoRA on the base model. Is it possible to merge those to later quantize them into .gguf with Q4_K_S?
This issue is stale because it has been open for 30 days with no activity.
lol. I forgot to close this issue. It's working now :)
Hello @yukiarimo , I am facing the same issue how did you solve it ?
Hello @yukiarimo , I am facing the same issue how did you solve it ?
Please, see this: https://github.com/ggerganov/llama.cpp/issues/4199
You can only convert to GGUF format from models with data in float16, bfloat16 or float32 formats. You can't convert models that are already quantized to a non-GGML format.