### What this PR does / why we need it? This PR introduces support for adding custom CANN `aclnn` ops to `vllm-ascend`, allowing users to define and use their own custom operators. Key changes include: - Building and installing custom ops into the `vllm-ascend`-specified directory - Binding the `aclnn` op interface to the `torch.ops._C_ascend` module - Enabling invocation of these ops within `vllm-ascend` This PR includes a sample custom op: `aclnnGroupedMatmulSwigluQuantWeightNzTensorList`, which is adapted from the CANN operator [`aclnnGroupedMatmulSwigluQuantWeightNZ`](https://www.hiascend.com/document/detail/zh/canncommercial/83RC1/API/aolapi/context/aclnnGroupedMatmulSwigluQuantWeightNZ.md). Its input parameters `weight` and `weight_scale` now accept `list[torch.Tensor]` (i.e., `at::TensorList`). ### Does this PR introduce _any_ user-facing change? No. - vLLM version: v0.11.2 --------- Signed-off-by: QianChenxi <chenxi.qian.cq@outlook.com>
35 lines
1015 B
Bash
35 lines
1015 B
Bash
#!/bin/bash
|
|
|
|
ROOT_DIR=$1
|
|
SOC_VERSION=$2
|
|
|
|
if [[ "$SOC_VERSION" =~ ^ascend310 ]]; then
|
|
# ASCEND310P series
|
|
# currently, no custom aclnn ops for ASCEND310 series
|
|
# CUSTOM_OPS=""
|
|
# SOC_ARG="ascend310p"
|
|
exit 0
|
|
elif [[ "$SOC_VERSION" =~ ^ascend910b ]]; then
|
|
# ASCEND910B (A2) series
|
|
CUSTOM_OPS="grouped_matmul_swiglu_quant_weight_nz_tensor_list"
|
|
SOC_ARG="ascend910b"
|
|
elif [[ "$SOC_VERSION" =~ ^ascend910_93 ]]; then
|
|
# ASCEND910C (A3) series
|
|
CUSTOM_OPS="grouped_matmul_swiglu_quant_weight_nz_tensor_list"
|
|
SOC_ARG="ascend910_93"
|
|
else
|
|
# others
|
|
# currently, no custom aclnn ops for other series
|
|
exit 0
|
|
fi
|
|
|
|
# build custom ops
|
|
cd csrc
|
|
rm -rf build output
|
|
echo "building custom ops $CUSTOM_OPS for $SOC_VERSION"
|
|
bash build.sh -n $CUSTOM_OPS -c $SOC_ARG
|
|
|
|
# install custom ops to vllm_ascend/_cann_ops_custom
|
|
./output/CANN-custom_ops*.run --install-path=$ROOT_DIR/vllm_ascend/_cann_ops_custom
|
|
source $ROOT_DIR/vllm_ascend/_cann_ops_custom/vendors/customize/bin/set_env.bash
|