From b5e9737b374333484c3c76e048c6f52be1856988 Mon Sep 17 00:00:00 2001 From: Jiaxin Shan Date: Tue, 9 Jul 2024 00:09:31 -0700 Subject: [PATCH] Address some feedback from reviewer --- tests/lora/test_utils.py | 28 ++++++++++++++-------------- vllm/lora/utils.py | 4 ++-- vllm/lora/worker_manager.py | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/lora/test_utils.py b/tests/lora/test_utils.py index 5a9b60d23d5f9..db02bacdb6439 100644 --- a/tests/lora/test_utils.py +++ b/tests/lora/test_utils.py @@ -5,7 +5,7 @@ from huggingface_hub.utils import HfHubHTTPError from torch import nn -from vllm.lora.utils import (get_lora_absolute_path, +from vllm.lora.utils import (get_adapter_absolute_path, parse_fine_tuned_lora_name, replace_submodule) from vllm.utils import LRUCache @@ -187,53 +187,53 @@ def test_lru_cache(): assert 6 in cache -# Unit tests for get_lora_absolute_path +# Unit tests for get_adapter_absolute_path @patch('os.path.isabs') -def test_get_lora_absolute_path_absolute(mock_isabs): +def test_get_adapter_absolute_path_absolute(mock_isabs): path = '/absolute/path/to/lora' mock_isabs.return_value = True - assert get_lora_absolute_path(path) == path + assert get_adapter_absolute_path(path) == path @patch('os.path.expanduser') -def test_get_lora_absolute_path_expanduser(mock_expanduser): +def test_get_adapter_absolute_path_expanduser(mock_expanduser): # Path with ~ that needs to be expanded path = '~/relative/path/to/lora' absolute_path = '/home/user/relative/path/to/lora' mock_expanduser.return_value = absolute_path - assert get_lora_absolute_path(path) == absolute_path + assert get_adapter_absolute_path(path) == absolute_path @patch('os.path.exists') @patch('os.path.abspath') -def test_get_lora_absolute_path_local_existing(mock_abspath, mock_exist): +def test_get_adapter_absolute_path_local_existing(mock_abspath, mock_exist): # Relative path that exists locally path = 'relative/path/to/lora' absolute_path = '/absolute/path/to/lora' mock_exist.return_value = True mock_abspath.return_value = absolute_path - assert get_lora_absolute_path(path) == absolute_path + assert get_adapter_absolute_path(path) == absolute_path @patch('huggingface_hub.snapshot_download') @patch('os.path.exists') -def test_get_lora_absolute_path_huggingface(mock_exist, - mock_snapshot_download): +def test_get_adapter_absolute_path_huggingface(mock_exist, + mock_snapshot_download): # Hugging Face model identifier path = 'org/repo' absolute_path = '/mock/snapshot/path' mock_exist.return_value = False mock_snapshot_download.return_value = absolute_path - assert get_lora_absolute_path(path) == absolute_path + assert get_adapter_absolute_path(path) == absolute_path @patch('huggingface_hub.snapshot_download') @patch('os.path.exists') -def test_get_lora_absolute_path_huggingface_error(mock_exist, - mock_snapshot_download): +def test_get_adapter_absolute_path_huggingface_error(mock_exist, + mock_snapshot_download): # Hugging Face model identifier with download error path = 'org/repo' mock_exist.return_value = False mock_snapshot_download.side_effect = HfHubHTTPError( "failed to query model info") - assert get_lora_absolute_path(path) == path + assert get_adapter_absolute_path(path) == path diff --git a/vllm/lora/utils.py b/vllm/lora/utils.py index 2735014090b21..4513337299e16 100644 --- a/vllm/lora/utils.py +++ b/vllm/lora/utils.py @@ -145,10 +145,10 @@ def get_adapter_absolute_path(lora_path: str) -> str: local_snapshot_path = huggingface_hub.snapshot_download( repo_id=lora_path) except (HfHubHTTPError, RepositoryNotFoundError, EntryNotFoundError, - HFValidationError) as e: + HFValidationError): # Handle errors that may occur during the download # Return original path instead instead of throwing error here - print(f"Error downloading the Hugging Face model: {e}") + logger.exception("Error downloading the HuggingFace model") return lora_path return local_snapshot_path diff --git a/vllm/lora/worker_manager.py b/vllm/lora/worker_manager.py index fdb69a9ef0ec2..724c308a07a27 100644 --- a/vllm/lora/worker_manager.py +++ b/vllm/lora/worker_manager.py @@ -13,7 +13,7 @@ from vllm.lora.models import (LoRAModel, LoRAModelManager, LRUCacheLoRAModelManager, create_lora_manager) from vllm.lora.request import LoRARequest -from vllm.lora.utils import get_lora_absolute_path +from vllm.lora.utils import get_adapter_absolute_path logger = init_logger(__name__) @@ -90,7 +90,7 @@ def _load_adapter(self, lora_request: LoRARequest) -> LoRAModel: packed_modules_mapping[module]) else: expected_lora_modules.append(module) - lora_path = get_lora_absolute_path(lora_request.lora_path) + lora_path = get_adapter_absolute_path(lora_request.lora_path) lora = self._lora_model_cls.from_local_checkpoint( lora_path, expected_lora_modules,