diff --git a/benchmarks/backend_request_func.py b/benchmarks/backend_request_func.py index c3fed56e8a95..36227ef251b1 100644 --- a/benchmarks/backend_request_func.py +++ b/benchmarks/backend_request_func.py @@ -399,6 +399,12 @@ async def async_request_openai_chat_completions( def get_model(pretrained_model_name_or_path: str) -> str: if os.getenv('VLLM_USE_MODELSCOPE', 'False').lower() == 'true': + if os.getenv('MODELSCOPE_ACCESS_TOKEN', ''): + from modelscope.hub.api import HubApi + access_token = os.getenv('MODELSCOPE_ACCESS_TOKEN') + api = HubApi() + api.login(access_token) + from modelscope import snapshot_download model_path = snapshot_download( diff --git a/vllm/lora/utils.py b/vllm/lora/utils.py index 5876494ce282..3871b2c784bd 100644 --- a/vllm/lora/utils.py +++ b/vllm/lora/utils.py @@ -3,8 +3,6 @@ from typing import List, Optional, Set, Tuple, Type, Union import huggingface_hub -from huggingface_hub.utils import (EntryNotFoundError, HfHubHTTPError, - HFValidationError, RepositoryNotFoundError) from torch import nn from transformers import PretrainedConfig @@ -178,15 +176,27 @@ def get_adapter_absolute_path(lora_path: str) -> str: if os.path.exists(lora_path): return os.path.abspath(lora_path) - # If the path does not exist locally, assume it's a Hugging Face repo. + # If the path does not exist locally, + # assume it's a Hugging Face repo or ModelScope repo. try: - local_snapshot_path = huggingface_hub.snapshot_download( - repo_id=lora_path) - except (HfHubHTTPError, RepositoryNotFoundError, EntryNotFoundError, - HFValidationError): + if os.getenv('VLLM_USE_MODELSCOPE', 'False').lower() == 'true': + if os.getenv('MODELSCOPE_ACCESS_TOKEN', ''): + from modelscope.hub.api import HubApi + access_token = os.getenv('MODELSCOPE_ACCESS_TOKEN') + api = HubApi() + api.login(access_token) + + from modelscope import snapshot_download + + local_snapshot_path = snapshot_download(model_id=lora_path) + else: + local_snapshot_path = huggingface_hub.snapshot_download( + repo_id=lora_path) + except Exception: # Handle errors that may occur during the download # Return original path instead instead of throwing error here - logger.exception("Error downloading the HuggingFace model") + logger.exception( + "Error downloading the HuggingFace or ModelScope model") return lora_path return local_snapshot_path