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

llama : make loras compatible with repacking #12593

Merged
merged 3 commits into from
Mar 27, 2025
Merged

Conversation

ggerganov
Copy link
Member

fix #12587
ref #12181 (comment)

When a LoRA adapter requires to be loaded to an extra buffer type (such as repacked bufts), load in to the default CPU buffer type instead.

@ggerganov
Copy link
Member Author

@giladgd @amakropoulos Could you test if this change fixes the LoRA usage with Q4_K?

@amakropoulos
Copy link
Contributor

@ggerganov yes that fixed it!

I get these warnings but otherwise works as expected:

llama_adapter_lora_init_impl: loading lora adapter from '/home/benuix/.config/LLMUnity/models/Qwen2-0.5B-Instruct-ru-lora.gguf' ...
llama_adapter_lora_init_impl: lora for 'blk.11.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.12.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.14.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.15.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.17.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.18.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.2.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.20.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.22.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.23.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.4.ffn_down.weight' cannot use buft 'CPU_AARCH64'
llama_adapter_lora_init_impl: lora for 'blk.5.ffn_down.weight' cannot use buft 'CPU_AARCH64'

@ggerganov
Copy link
Member Author

Yes, the warnings are expected.

@ggerganov ggerganov requested a review from slaren March 26, 2025 16:30
@giladgd
Copy link
Contributor

giladgd commented Mar 26, 2025

@ggerganov I've run some tests and this seems to solve the issue.

Copy link
Member

@slaren slaren left a comment

Choose a reason for hiding this comment

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

This should work for now. Ideally we would use the same process as the model weights to determine the buffer type. I think this could be done by extracting to a function the relevant parts of the create_tensor lambda in llama_model::load_tensors, and keeping a mapping of each weight to its LLM_TN_IMPL object in llama_model.

@ggerganov ggerganov merged commit f28bc4c into master Mar 27, 2025
1 check passed
@ggerganov ggerganov deleted the gg/lora-with-repack branch March 27, 2025 06:24
@amakropoulos
Copy link
Contributor

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Misc. bug: Server crash with use of lora on CPU
4 participants