Skip to content

Commit

Permalink
convert : fix autoawq gemma (ggerganov#6704)
Browse files Browse the repository at this point in the history
* fix autoawq quantized gemma model convert error

using autoawq to quantize gemma model will include a lm_head.weight tensor in model-00001-of-00002.safetensors. it result in this situation that convert-hf-to-gguf.py can't map lm_head.weight. skip loading this tensor could prevent this error.

* change code to full string match and print necessary message

change code to full string match and print a short message to inform users that lm_head.weight has been skipped.

---------

Co-authored-by: Zheng.Deng <[email protected]>
  • Loading branch information
dengzheng-cloud and dengzheng-cloud authored Apr 16, 2024
1 parent 532c173 commit facb8b5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions convert-hf-to-gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,12 @@ def write_tensors(self):
tensor_map = gguf.get_tensor_name_map(self.model_arch, block_count)

for name, data_torch in self.get_tensors():
# lm_head is not used in llama.cpp, while autoawq will include this tensor in model
# To prevent errors, skip loading lm_head.weight.
if name == "lm_head.weight":
print(f"Skipping get tensor {name!r} in safetensors so that convert can end normally.")
continue

old_dtype = data_torch.dtype

# convert any unsupported data types to float32
Expand Down

0 comments on commit facb8b5

Please sign in to comment.