Skip to content

Re-enable manual LoRA adapter free#19983

Open
PopFlamingo wants to merge 2 commits intoggml-org:masterfrom
PopFlamingo:fix/reenable-lora-free
Open

Re-enable manual LoRA adapter free#19983
PopFlamingo wants to merge 2 commits intoggml-org:masterfrom
PopFlamingo:fix/reenable-lora-free

Conversation

@PopFlamingo
Copy link

@PopFlamingo PopFlamingo commented Feb 28, 2026

This PR proposes re-enabling manual LoRA adapter free (the llama_adapter_lora_free function), that had been previously deprecated as part of #18490.

Motivation

After reading the discussion on why llama_adapter_lora_free was deprecated and made a no-op, my understanding is that it was considered that this had no real use case, however I am currently working on a project where having the ability to unload adapters is very important due to memory constraints (mobile devices).

Without llama_adapter_lora_free, we have to fully unload and re-load the model, as well as lose any contexts (and their cached tokens) associated with it, just to free the memory associated with those LoRAs. I am not aware of any other way to achieve this.

Summary of changes

The llama_adapter_lora_free function has been re-enabled and un-deprecated; calling llama_adapter_lora_free stays optional as the LoRA will still be freed if necessary when its parent model is released. Documentation comments have been updated to reflect this new behavior.

Concretely we make sure to remove the freed LoRA from the ownership list of its owning model to prevent double frees.

Other related issues

Issue #19153 would benefit from this change as well, since I don't think the requested feature would be implementable without llama_adapter_lora_free.

@PopFlamingo PopFlamingo requested a review from CISC as a code owner February 28, 2026 13:26
@CISC CISC requested a review from ggerganov February 28, 2026 14:42
@PopFlamingo PopFlamingo requested a review from ggerganov March 5, 2026 13:05
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.

2 participants