Skip to content

Commit 5486458

Browse files
committed
custom op env fix
Signed-off-by: QianChenxi <chenxi.qian.cq@outlook.com>
1 parent fde66f3 commit 5486458

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ target_link_libraries(
131131
opapi
132132
)
133133

134-
target_link_options(vllm_ascend_C PRIVATE "-Wl,-rpath,$ORIGIN:$ORIGIN/lib")
134+
target_link_options(vllm_ascend_C PRIVATE "-Wl,-rpath,$ORIGIN:$ORIGIN/lib:$ORIGIN/_cann_ops_custom/vendors/vllm-ascend/op_api/lib")
135135

136136
install(TARGETS vllm_ascend_C vllm_ascend_kernels DESTINATION ${VLLM_ASCEND_INSTALL_PATH})

csrc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ option(BUILD_OPEN_PROJECT "Build open ascend ops project." ON)
1515
option(ENABLE_CCACHE "Enable ccache capability" ON)
1616
set(ASCEND_COMPUTE_UNIT "ascend910b" CACHE STRING "soc that need to be compiled")
1717
set(ASCEND_OP_NAME "ALL" CACHE STRING "operators that need to be compiled")
18-
set(VENDOR_NAME "customize" CACHE STRING "vendor name")
18+
set(VENDOR_NAME "vllm-ascend" CACHE STRING "vendor name")
1919

2020
include(cmake/config.cmake)
2121
include(cmake/func.cmake)

csrc/build_aclnn.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ bash build.sh -n $CUSTOM_OPS -c $SOC_ARG
3131

3232
# install custom ops to vllm_ascend/_cann_ops_custom
3333
./output/CANN-custom_ops*.run --install-path=$ROOT_DIR/vllm_ascend/_cann_ops_custom
34-
source $ROOT_DIR/vllm_ascend/_cann_ops_custom/vendors/customize/bin/set_env.bash

vllm_ascend/platform.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,6 @@
3838
prefill_context_parallel_enable, update_aclgraph_sizes,
3939
update_cudagraph_capture_sizes, update_default_aclgraph_sizes)
4040

41-
# set custom ops path
42-
CUR_DIR = os.path.dirname(os.path.realpath(__file__))
43-
CUSTOM_OPP_PATH = os.path.join(CUR_DIR, "vllm_ascend", "_cann_ops_custom",
44-
"vendors", "customize")
45-
CUSTOM_LIB_PATH = os.path.join(CUSTOM_OPP_PATH, "op_api", "lib")
46-
47-
if os.path.exists(CUSTOM_OPP_PATH):
48-
current_cust_opp_path = os.environ.get("ASCEND_CUSTOM_OPP_PATH", "")
49-
if current_cust_opp_path:
50-
os.environ[
51-
"ASCEND_CUSTOM_OPP_PATH"] = f"{CUSTOM_OPP_PATH}:{current_cust_opp_path}"
52-
else:
53-
os.environ["ASCEND_CUSTOM_OPP_PATH"] = CUSTOM_OPP_PATH
54-
55-
if os.path.exists(CUSTOM_LIB_PATH):
56-
current_lib_path = os.environ.get("LD_LIBRARY_PATH", "")
57-
if current_lib_path:
58-
os.environ["LD_LIBRARY_PATH"] = f"{CUSTOM_LIB_PATH}:{current_lib_path}"
59-
else:
60-
os.environ["LD_LIBRARY_PATH"] = CUSTOM_LIB_PATH
61-
6241
if TYPE_CHECKING:
6342
from vllm.config import ModelConfig, VllmConfig
6443
from vllm.utils import FlexibleArgumentParser

vllm_ascend/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,19 @@ def enable_custom_op():
247247
Ensure that ASCEND_RT_VISIBLE_DEVICES can be dynamically modified before torch.npu.set_device().
248248
"""
249249
global _CUSTOM_OP_ENABLED
250+
251+
# set custom ops path
252+
CUR_DIR = os.path.dirname(os.path.realpath(__file__))
253+
CUSTOM_OPP_PATH = os.path.join(CUR_DIR, "_cann_ops_custom", "vendors",
254+
"vllm-ascend")
255+
if os.path.exists(CUSTOM_OPP_PATH):
256+
current_cust_opp_path = os.environ.get("ASCEND_CUSTOM_OPP_PATH", "")
257+
if current_cust_opp_path:
258+
os.environ[
259+
"ASCEND_CUSTOM_OPP_PATH"] = f"{CUSTOM_OPP_PATH}:{current_cust_opp_path}"
260+
else:
261+
os.environ["ASCEND_CUSTOM_OPP_PATH"] = CUSTOM_OPP_PATH
262+
250263
if _CUSTOM_OP_ENABLED is not None:
251264
return _CUSTOM_OP_ENABLED
252265
try:

0 commit comments

Comments
 (0)