Skip to content

Commit ce77eb9

Browse files
authored
[Bugfix] Fix VLLM_USE_MODELSCOPE issue (#13384)
1 parent 30513d1 commit ce77eb9

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

vllm/transformers_utils/config.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ def list_repo_files(
117117

118118
def lookup_files():
119119
try:
120+
if VLLM_USE_MODELSCOPE:
121+
from vllm.transformers_utils.utils import (
122+
modelscope_list_repo_files)
123+
return modelscope_list_repo_files(repo_id,
124+
revision=revision,
125+
token=token)
120126
return hf_list_repo_files(repo_id,
121127
revision=revision,
122128
repo_type=repo_type,
@@ -382,17 +388,17 @@ def get_hf_file_to_dict(file_name: str,
382388
@cache
383389
def get_pooling_config(model: str, revision: Optional[str] = 'main'):
384390
"""
385-
This function gets the pooling and normalize
386-
config from the model - only applies to
387-
sentence-transformers models.
391+
This function gets the pooling and normalize
392+
config from the model - only applies to
393+
sentence-transformers models.
388394
389395
Args:
390396
model (str): The name of the Hugging Face model.
391-
revision (str, optional): The specific version
397+
revision (str, optional): The specific version
392398
of the model to use. Defaults to 'main'.
393399
394400
Returns:
395-
dict: A dictionary containing the pooling
401+
dict: A dictionary containing the pooling
396402
type and whether normalization is used.
397403
"""
398404

@@ -499,7 +505,7 @@ def get_sentence_transformer_tokenizer_config(model: str,
499505
revision=revision,
500506
token=HF_TOKEN)
501507
except Exception as e:
502-
logger.debug("Error getting repo files", e)
508+
logger.error("Error getting repo files", e)
503509
repo_files = []
504510

505511
for config_name in sentence_transformer_config_files:

vllm/transformers_utils/utils.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from os import PathLike
44
from pathlib import Path
5-
from typing import Union
5+
from typing import List, Optional, Union
66

77

88
def is_s3(model_or_path: str) -> bool:
@@ -20,3 +20,22 @@ def check_gguf_file(model: Union[str, PathLike]) -> bool:
2020
with open(model, "rb") as f:
2121
header = f.read(4)
2222
return header == b"GGUF"
23+
24+
25+
def modelscope_list_repo_files(
26+
repo_id: str,
27+
revision: Optional[str] = None,
28+
token: Union[str, bool, None] = None,
29+
) -> List[str]:
30+
"""List files in a modelscope repo."""
31+
from modelscope.hub.api import HubApi
32+
from modelscope.utils.hf_util import _try_login
33+
_try_login(token)
34+
api = HubApi()
35+
# same as huggingface_hub.list_repo_files
36+
files = [
37+
file['Path'] for file in api.get_model_files(
38+
model_id=repo_id, revision=revision, recursive=True)
39+
if file['Type'] == 'blob'
40+
]
41+
return files

0 commit comments

Comments
 (0)