[MISC] Make vllm version configurable (#651)
Sometimes, user install a dev/editable version of vllm. In this case, we should make sure vllm-ascend works as well. This PR add a new env `VLLM_VERSION`. It's used for developers who edit vllm. In this case, developers should set thie env to make sure which vllm version is installed and used. Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#
|
||||
import torch
|
||||
import torch_npu # noqa: F401
|
||||
from packaging.version import Version
|
||||
from packaging.version import InvalidVersion, Version
|
||||
from vllm.logger import logger
|
||||
|
||||
import vllm_ascend.envs as envs
|
||||
@@ -86,6 +86,17 @@ def adapt_patch(is_global_patch: bool = False):
|
||||
from vllm_ascend.patch import worker # noqa: F401
|
||||
|
||||
|
||||
def vllm_version_is(version: str):
|
||||
import vllm
|
||||
return Version(vllm.__version__) == Version(version)
|
||||
def vllm_version_is(target_vllm_version: str):
|
||||
if envs.VLLM_VERSION is not None:
|
||||
vllm_version = envs.VLLM_VERSION
|
||||
else:
|
||||
import vllm
|
||||
vllm_version = vllm.__version__
|
||||
try:
|
||||
return Version(vllm_version) == Version(target_vllm_version)
|
||||
except InvalidVersion:
|
||||
raise ValueError(
|
||||
f"Invalid vllm version {vllm_version} found. A dev version of vllm "
|
||||
"is installed probably. Set the environment variable VLLM_VERSION "
|
||||
"to control it by hand. And please make sure the vaule follows the "
|
||||
"format of x.y.z.")
|
||||
|
||||
Reference in New Issue
Block a user