make vllm-ascend work well in developer mode (#4179)
### What this PR does / why we need it?
we often install vllm-ascend in developer mode, which has no _build_info
module. it will raise error in `utils.is_310p` and
`utils.sleep_model_enabled`, then we need to modify these two function.
### Does this PR introduce _any_ user-facing change?
not involved
### How was this patch tested?
not involved
- vLLM version: v0.11.0
- vLLM main:
2918c1b49c
Signed-off-by: Ronald1995 <ronaldautomobile@163.com>
This commit is contained in:
46
setup.py
46
setup.py
@@ -69,6 +69,25 @@ envs = load_module_from_path("envs",
|
|||||||
os.path.join(ROOT_DIR, "vllm_ascend", "envs.py"))
|
os.path.join(ROOT_DIR, "vllm_ascend", "envs.py"))
|
||||||
|
|
||||||
|
|
||||||
|
def gen_build_info():
|
||||||
|
soc_version = envs.SOC_VERSION
|
||||||
|
if not soc_version:
|
||||||
|
raise ValueError(
|
||||||
|
"SOC version is not set. Please set SOC_VERSION environment variable."
|
||||||
|
)
|
||||||
|
if "310" in soc_version and not envs.COMPILE_CUSTOM_KERNELS:
|
||||||
|
raise ValueError(
|
||||||
|
"SOC version 310 only supports custom kernels. Please set COMPILE_CUSTOM_KERNELS=1 to enable custom kernels."
|
||||||
|
)
|
||||||
|
|
||||||
|
package_dir = os.path.join(ROOT_DIR, "vllm_ascend", "_build_info.py")
|
||||||
|
with open(package_dir, "w+") as f:
|
||||||
|
f.write('# Auto-generated file\n')
|
||||||
|
f.write(f"__soc_version__ = '{soc_version}'\n")
|
||||||
|
f.write(f"__sleep_mode_enabled__ = {envs.COMPILE_CUSTOM_KERNELS}\n")
|
||||||
|
logging.info(f"Generated _build_info.py with SOC version: {soc_version}")
|
||||||
|
|
||||||
|
|
||||||
class CMakeExtension(Extension):
|
class CMakeExtension(Extension):
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
@@ -79,27 +98,17 @@ class CMakeExtension(Extension):
|
|||||||
self.cmake_lists_dir = os.path.abspath(cmake_lists_dir)
|
self.cmake_lists_dir = os.path.abspath(cmake_lists_dir)
|
||||||
|
|
||||||
|
|
||||||
|
class custom_develop(develop):
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
gen_build_info()
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
class custom_build_info(build_py):
|
class custom_build_info(build_py):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
soc_version = envs.SOC_VERSION
|
gen_build_info()
|
||||||
if not soc_version:
|
|
||||||
raise ValueError(
|
|
||||||
"SOC version is not set. Please set SOC_VERSION environment variable."
|
|
||||||
)
|
|
||||||
if "310" in soc_version and not envs.COMPILE_CUSTOM_KERNELS:
|
|
||||||
raise ValueError(
|
|
||||||
"SOC version 310 only supports custom kernels. Please set COMPILE_CUSTOM_KERNELS=1 to enable custom kernels."
|
|
||||||
)
|
|
||||||
|
|
||||||
package_dir = os.path.join(ROOT_DIR, "vllm_ascend", "_build_info.py")
|
|
||||||
with open(package_dir, "w+") as f:
|
|
||||||
f.write('# Auto-generated file\n')
|
|
||||||
f.write(f"__soc_version__ = '{soc_version}'\n")
|
|
||||||
f.write(
|
|
||||||
f"__sleep_mode_enabled__ = {envs.COMPILE_CUSTOM_KERNELS}\n")
|
|
||||||
logging.info(
|
|
||||||
f"Generated _build_info.py with SOC version: {soc_version}")
|
|
||||||
super().run()
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
@@ -352,6 +361,7 @@ def get_requirements() -> List[str]:
|
|||||||
|
|
||||||
|
|
||||||
cmdclass = {
|
cmdclass = {
|
||||||
|
"develop": custom_develop,
|
||||||
"build_py": custom_build_info,
|
"build_py": custom_build_info,
|
||||||
"build_ext": cmake_build_ext,
|
"build_ext": cmake_build_ext,
|
||||||
"install": custom_install
|
"install": custom_install
|
||||||
|
|||||||
Reference in New Issue
Block a user