Skip to content

Commit

Permalink
Add deprecation notice for lora_local_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffwan committed Jul 17, 2024
1 parent 8431063 commit d8e5a11
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
7 changes: 2 additions & 5 deletions tests/lora/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,17 @@ def dummy_model_gate_up() -> nn.Module:
return model


@pytest.fixture(scope="session")
def sql_lora_files():
return snapshot_download(repo_id="yard1/llama-2-7b-sql-lora-test")


@pytest.fixture(scope="session")
def sql_lora_huggingface_id():
# huggingface repo id is used to test lora runtime downloading.
return "yard1/llama-2-7b-sql-lora-test"


@pytest.fixture(scope="session")
def sql_lora_files(sql_lora_huggingface_id):
return snapshot_download(repo_id=sql_lora_huggingface_id)


@pytest.fixture(scope="session")
def mixtral_lora_files():
# Note: this module has incorrect adapter_config.json to test
Expand Down
42 changes: 39 additions & 3 deletions vllm/lora/request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass
import warnings
from dataclasses import dataclass, field
from typing import Optional

from vllm.adapter_commons.request import AdapterRequest
Expand All @@ -20,10 +21,25 @@ class LoRARequest(AdapterRequest):

lora_name: str
lora_int_id: int
lora_path: str
lora_path: str = ""
lora_local_path: Optional[str] = field(default=None, repr=False)
long_lora_max_len: Optional[int] = None
__hash__ = AdapterRequest.__hash__

def __post_init__(self):
if 'lora_local_path' in self.__dict__:
warnings.warn(
"The 'lora_local_path' attribute is deprecated "
"and will be removed in a future version. "
"Please use 'lora_path' instead.",
DeprecationWarning,
stacklevel=2)
if not self.lora_path:
self.lora_path = self.lora_local_path or ""

# Ensure lora_path is not empty
assert self.lora_path, "lora_path cannot be empty"

@property
def adapter_id(self):
return self.lora_int_id
Expand All @@ -32,6 +48,26 @@ def adapter_id(self):
def name(self):
return self.lora_name

@property
def path(self):
return self.lora_path

@property
def local_path(self):
return self.lora_local_path
warnings.warn(
"The 'local_path' attribute is deprecated "
"and will be removed in a future version. "
"Please use 'path' instead.",
DeprecationWarning,
stacklevel=2)
return self.lora_path

@local_path.setter
def local_path(self, value):
warnings.warn(
"The 'local_path' attribute is deprecated "
"and will be removed in a future version. "
"Please use 'path' instead.",
DeprecationWarning,
stacklevel=2)
self.lora_path = value

0 comments on commit d8e5a11

Please sign in to comment.