Skip to content

lora : fix llama conversion script with model having ROPE_FREQS#9117

Merged
ngxson merged 1 commit intoggml-org:masterfrom
ngxson:xsn/fix_llama_lora
Aug 23, 2024
Merged

lora : fix llama conversion script with model having ROPE_FREQS#9117
ngxson merged 1 commit intoggml-org:masterfrom
ngxson:xsn/fix_llama_lora

Conversation

@ngxson
Copy link
Copy Markdown
Contributor

@ngxson ngxson commented Aug 21, 2024

Resolve #9114


@ngxson ngxson requested a review from compilade August 21, 2024 12:55
@github-actions github-actions Bot added testing Everything test related python python script changes labels Aug 21, 2024
@Ujjawal-K-Panchal
Copy link
Copy Markdown
Contributor

This fixes the issue #9114 I raised. Please look at the final output log here.

Comment thread convert_hf_to_gguf.py
Comment on lines +1598 to +1599
if not self.is_lora:
self.gguf_writer.add_tensor(self.format_tensor_name(gguf.MODEL_TENSOR.ROPE_FREQS), np.array(rope_factors, dtype=np.float32))
Copy link
Copy Markdown
Collaborator

@compilade compilade Aug 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Phi-3, vocab-only conversion is also affected by these rope_freqs tensors, because this is in set_gguf_parameters. (which makes vocab-only Phi-3-128k models produce invalid GGUF files (this is already a problem on master))

A more general solution to both LoRA and vocab-only conversions should be possible.

Maybe some kind of self.generate_extra_tensors() which would be called by self.prepare_tensors() before it calls self.get_tensors(). And LoraModel could simply override generate_extra_tensors() to a no-op (and vocab-only conversion does not call prepare_tensors). It can be done in a follow-up PR, though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK I'll merge this now and will let you refactor this further in a follow-up PR.
Thank you for the help!

@ngxson ngxson merged commit 3ba780e into ggml-org:master Aug 23, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 15, 2024
arthw pushed a commit to arthw/llama.cpp that referenced this pull request Nov 18, 2024
Nexesenex pushed a commit to Nexesenex/croco.cpp that referenced this pull request Feb 25, 2025
Nexesenex pushed a commit to Nexesenex/croco.cpp that referenced this pull request Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python python script changes testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Converted HF LoRA adapter on Llama 3.1 not loading.

3 participants