| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | from vllm import envs |
| 5 | |
| 6 | if envs.VLLM_USE_MODELSCOPE: |
| 7 | try: |
| 8 | # Patch here, before each import happens |
| 9 | import modelscope |
| 10 | from packaging import version |
| 11 | |
| 12 | # patch_hub begins from modelscope>=1.18.1 |
| 13 | if version.parse(modelscope.__version__) <= version.parse("1.18.0"): |
| 14 | raise ImportError( |
| 15 | "Using vLLM with ModelScope needs modelscope>=1.18.1, please " |
| 16 | "install by `pip install modelscope -U`" |
| 17 | ) |
| 18 | from modelscope.utils.hf_util import patch_hub |
| 19 | |
| 20 | # Patch hub to download models from modelscope to speed up. |
| 21 | patch_hub() |
| 22 | except ImportError as err: |
| 23 | raise ImportError( |
| 24 | "Please install modelscope>=1.18.1 via " |
| 25 | "`pip install modelscope>=1.18.1` to use ModelScope." |
| 26 | ) from err |