Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: fix broken of download models from modelscope #5233

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 additions & 0 deletions tests/entrypoints/test_model_from_modelscope.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test isn't ran at the moment, and I would prefer this be put inside test_regression if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to test_regression.py

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from vllm import LLM, SamplingParams

# model: https://modelscope.cn/models/qwen/Qwen1.5-0.5B-Chat/summary
MODEL_NAME = "qwen/Qwen1.5-0.5B-Chat"


def test_offline_inference(monkeypatch):
monkeypatch.setenv("VLLM_USE_MODELSCOPE", "True")
llm = LLM(model=MODEL_NAME)

prompts = [
"Hello, my name is",
"The president of the United States is",
"The capital of France is",
"The future of AI is",
]
sampling_params = SamplingParams(temperature=0.8, top_p=0.95)

outputs = llm.generate(prompts, sampling_params)
assert len(outputs) == 4
6 changes: 5 additions & 1 deletion vllm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def __init__(
self.revision = revision
self.code_revision = code_revision
self.rope_scaling = rope_scaling
self.tokenizer_revision = tokenizer_revision
# The tokenizer version is consistent with the model version by default.
if tokenizer_revision is None:
self.tokenizer_revision = revision
else:
self.tokenizer_revision = tokenizer_revision
self.quantization = quantization
self.quantization_param_path = quantization_param_path
self.enforce_eager = enforce_eager
Expand Down
22 changes: 16 additions & 6 deletions vllm/transformers_utils/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Dict, Optional

from transformers import AutoConfig, PretrainedConfig
from transformers import PretrainedConfig

from vllm.envs import VLLM_USE_MODELSCOPE
from vllm.logger import init_logger
from vllm.transformers_utils.configs import (ChatGLMConfig, DbrxConfig,
JAISConfig, MPTConfig, RWConfig)
Expand All @@ -24,11 +25,20 @@ def get_config(model: str,
code_revision: Optional[str] = None,
rope_scaling: Optional[dict] = None) -> PretrainedConfig:
try:
config = AutoConfig.from_pretrained(
model,
trust_remote_code=trust_remote_code,
revision=revision,
code_revision=code_revision)
if VLLM_USE_MODELSCOPE:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the following pattern?

if VLLM_USE_MODELSCOPE:
    from modelscope import AutoConfig
    auto_cls = AutoConfig
else: 
    from transformers import AutoConfig
    auto_cls = AutoConfig

config = AutoConfig...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

from modelscope import AutoConfig
config = AutoConfig.from_pretrained(
model,
trust_remote_code=trust_remote_code,
revision=revision,
code_revision=code_revision)
else:
from transformers import AutoConfig
config = AutoConfig.from_pretrained(
model,
trust_remote_code=trust_remote_code,
revision=revision,
code_revision=code_revision)
except ValueError as e:
if (not trust_remote_code and
"requires you to execute the configuration file" in str(e)):
Expand Down
Loading