From fc37187a51474b42c0b80cd672d3bdaacb0c026d Mon Sep 17 00:00:00 2001 From: Xu Jinyang <72930776+AuYang261@users.noreply.github.com> Date: Fri, 23 Jan 2026 00:33:21 +0800 Subject: [PATCH] [Bugfix] ModelScope is supported when downloading LORA models. (#32844) Signed-off-by: AuYang <459461160@qq.com> --- vllm/lora/utils.py | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/vllm/lora/utils.py b/vllm/lora/utils.py index 349e66ae13..510be672c4 100644 --- a/vllm/lora/utils.py +++ b/vllm/lora/utils.py @@ -9,6 +9,7 @@ from huggingface_hub.utils import HfHubHTTPError, HFValidationError from torch import nn from transformers import PretrainedConfig +from vllm import envs from vllm.config.lora import LoRAConfig from vllm.logger import init_logger @@ -235,13 +236,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. + if envs.VLLM_USE_MODELSCOPE: + # If using ModelScope, we assume the path is a ModelScope repo. + from modelscope.hub.snapshot_download import InvalidParameter, snapshot_download + from requests import HTTPError + + download_fn = lambda: snapshot_download(model_id=lora_path) + download_exceptions = (HTTPError, InvalidParameter) + error_log = "Error downloading the ModelScope model" + else: + # Otherwise, we assume the path is a Hugging Face Hub repo. + download_fn = lambda: huggingface_hub.snapshot_download(repo_id=lora_path) + download_exceptions = (HfHubHTTPError, HFValidationError) + error_log = "Error downloading the HuggingFace model" + try: - local_snapshot_path = huggingface_hub.snapshot_download(repo_id=lora_path) - except (HfHubHTTPError, HFValidationError): - # Handle errors that may occur during the download - # Return original path instead of throwing error here - logger.exception("Error downloading the HuggingFace model") + local_snapshot_path = download_fn() + except download_exceptions: + # Handle errors that may occur during the download. + # Return original path instead of throwing error here. + logger.exception(error_log) return lora_path return local_snapshot_path