[LoRA] Add support for pinning lora adapters in the LRU cache (#5603)

This commit is contained in:
rohithkrn
2024-06-21 15:42:46 -07:00
committed by GitHub
parent 7187507301
commit f5dda63eb5
13 changed files with 171 additions and 5 deletions
+5
View File
@@ -878,6 +878,11 @@ class ModelRunner:
raise RuntimeError("LoRA is not enabled.")
return self.lora_manager.remove_lora(lora_id)
def pin_lora(self, lora_id: int) -> bool:
if not self.lora_manager:
raise RuntimeError("LoRA is not enabled.")
return self.lora_manager.pin_lora(lora_id)
def list_loras(self) -> Set[int]:
if not self.lora_manager:
raise RuntimeError("LoRA is not enabled.")
+3
View File
@@ -333,6 +333,9 @@ class Worker(WorkerBase):
def remove_lora(self, lora_id: int) -> bool:
return self.model_runner.remove_lora(lora_id)
def pin_lora(self, lora_id: int) -> bool:
return self.model_runner.pin_lora(lora_id)
def list_loras(self) -> Set[int]:
return self.model_runner.list_loras()
+8
View File
@@ -70,6 +70,10 @@ class WorkerBase(ABC):
def remove_lora(self, lora_id: int) -> bool:
raise NotImplementedError
@abstractmethod
def pin_lora(self, lora_id: int) -> bool:
raise NotImplementedError
@abstractmethod
def list_loras(self) -> Set[int]:
raise NotImplementedError
@@ -86,6 +90,10 @@ class LoraNotSupportedWorkerBase(WorkerBase):
def remove_lora(self, lora_id: int) -> bool:
raise ValueError(f"{type(self)} does not support LoRA")
def pin_lora(self, lora_id: int) -> bool:
return ValueError(
f"{type(self)} does not support LoRA") # type: ignore
def list_loras(self) -> Set[int]:
raise ValueError(f"{type(self)} does not support LoRA")