[Bug Fix] prevent lora adapter from being loaded into LoRAManager if it is already loaded (#11365)
This commit is contained in:
@@ -156,6 +156,15 @@ class LoRAManager:
|
||||
Validate if an adapter can be loaded into the current LoRA memory pool and generate error if it is incompatible.
|
||||
"""
|
||||
|
||||
# Check if this LoRA adapter is already loaded
|
||||
if any(
|
||||
lora_ref.lora_name == existing_lora_ref.lora_name
|
||||
for existing_lora_ref in self.lora_refs.values()
|
||||
):
|
||||
raise ValueError(
|
||||
f"Failed to load LoRA adapter {lora_ref.lora_name} because it is already loaded"
|
||||
)
|
||||
|
||||
# Check if the LoRA adapter shape is compatible with the current LoRA memory pool configuration.
|
||||
memory_pool = getattr(self, "memory_pool", None)
|
||||
incompatible = memory_pool and not memory_pool.can_support(lora_config)
|
||||
|
||||
@@ -101,6 +101,19 @@ BASIC_TESTS = [
|
||||
},
|
||||
],
|
||||
op_sequence=[
|
||||
Operation(
|
||||
type=OperationType.LOAD,
|
||||
data="philschmid/code-llama-3-1-8b-text-to-sql-lora",
|
||||
expected_error="already loaded",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.UNLOAD,
|
||||
data="philschmid/code-llama-3-1-8b-text-to-sql-lora",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.LOAD,
|
||||
data="philschmid/code-llama-3-1-8b-text-to-sql-lora",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.FORWARD,
|
||||
data=create_batch_data(
|
||||
@@ -224,6 +237,19 @@ BASIC_TESTS = [
|
||||
type=OperationType.LOAD,
|
||||
data="pbevan11/llama-3.1-8b-ocr-correction",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.LOAD,
|
||||
data="philschmid/code-llama-3-1-8b-text-to-sql-lora",
|
||||
expected_error="already loaded",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.UNLOAD,
|
||||
data="philschmid/code-llama-3-1-8b-text-to-sql-lora",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.LOAD,
|
||||
data="philschmid/code-llama-3-1-8b-text-to-sql-lora",
|
||||
),
|
||||
Operation(
|
||||
type=OperationType.FORWARD,
|
||||
data=create_batch_data(
|
||||
|
||||
Reference in New Issue
Block a user