Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions benchmarks/backend_request_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
26 changes: 18 additions & 8 deletions vllm/lora/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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