[Kernel] add custom op DispatchGmmCombineDecode (#4139)
#### What this PR does / why we need it? add custom opapi DispatchGmmCombineDecode for A3, include kernel inpl, python Api, pytest. vLLM version: v0.11.0 vLLM main:24d6314718- vLLM version: v0.12.0 - vLLM main:ad32e3e19cSigned-off-by: wangqiankun <wangqiankun13@huawei.com> Co-authored-by: wangqiankun <wangqiankun13@huawei.com> Co-authored-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
ROOT_DIR=$1
|
||||
SOC_VERSION=$2
|
||||
|
||||
git config --global --add safe.directory "$ROOT_DIR"
|
||||
|
||||
if [[ "$SOC_VERSION" =~ ^ascend310 ]]; then
|
||||
# ASCEND310P series
|
||||
# currently, no custom aclnn ops for ASCEND310 series
|
||||
@@ -13,11 +11,41 @@ if [[ "$SOC_VERSION" =~ ^ascend310 ]]; then
|
||||
exit 0
|
||||
elif [[ "$SOC_VERSION" =~ ^ascend910b ]]; then
|
||||
# ASCEND910B (A2) series
|
||||
CUSTOM_OPS="grouped_matmul_swiglu_quant_weight_nz_tensor_list;lightning_indexer;sparse_flash_attention;dispatch_ffn_combine"
|
||||
CUSTOM_OPS="grouped_matmul_swiglu_quant_weight_nz_tensor_list;lightning_indexer;sparse_flash_attention"
|
||||
SOC_ARG="ascend910b"
|
||||
elif [[ "$SOC_VERSION" =~ ^ascend910_93 ]]; then
|
||||
# ASCEND910C (A3) series
|
||||
CUSTOM_OPS="grouped_matmul_swiglu_quant_weight_nz_tensor_list;lightning_indexer;sparse_flash_attention;dispatch_ffn_combine"
|
||||
# depdendency: catlass
|
||||
git config --global --add safe.directory "$ROOT_DIR"
|
||||
CATLASS_PATH=${ROOT_DIR}/csrc/third_party/catlass/include
|
||||
if [[ ! -d "${CATLASS_PATH}" ]]; then
|
||||
echo "depdendency catlass is missing, try to fetch it..."
|
||||
if ! git submodule update --init --recursive; then
|
||||
echo "fetch failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# depdendency: cann-toolkit file moe_distribute_base.h
|
||||
HCCL_STRUCT_FILE_PATH=$(find -L "${ASCEND_TOOLKIT_HOME}" -name "moe_distribute_base.h" 2>/dev/null | head -n1)
|
||||
if [ -z "$HCCL_STRUCT_FILE_PATH" ]; then
|
||||
echo "cannot find moe_distribute_base.h file in CANN env"
|
||||
exit 1
|
||||
fi
|
||||
# for dispatch_gmm_combine_decode
|
||||
yes | cp "${HCCL_STRUCT_FILE_PATH}" "${ROOT_DIR}/csrc/dispatch_gmm_combine_decode/op_kernel"
|
||||
# for dispatch_ffn_combine
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
TARGET_DIR="$SCRIPT_DIR/dispatch_ffn_combine/op_kernel/utils/"
|
||||
TARGET_FILE="$TARGET_DIR/$(basename "$HCCL_STRUCT_FILE_PATH")"
|
||||
|
||||
echo "*************************************"
|
||||
echo $HCCL_STRUCT_FILE_PATH
|
||||
echo "$TARGET_DIR"
|
||||
cp "$HCCL_STRUCT_FILE_PATH" "$TARGET_DIR"
|
||||
|
||||
sed -i 's/struct HcclOpResParam {/struct HcclOpResParamCustom {/g' "$TARGET_FILE"
|
||||
sed -i 's/struct HcclRankRelationResV2 {/struct HcclRankRelationResV2Custom {/g' "$TARGET_FILE"
|
||||
CUSTOM_OPS="grouped_matmul_swiglu_quant_weight_nz_tensor_list;lightning_indexer;sparse_flash_attention;dispatch_ffn_combine;dispatch_gmm_combine_decode;"
|
||||
SOC_ARG="ascend910_93"
|
||||
else
|
||||
# others
|
||||
@@ -25,29 +53,6 @@ else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git submodule init
|
||||
git submodule update
|
||||
|
||||
|
||||
# For the compatibility of CANN8.5 and CANN8.3: copy and modify moe_distribute_base.h
|
||||
file_path=$(find /usr/local/Ascend/ascend-toolkit -name "moe_distribute_base.h" 2>/dev/null | head -n1)
|
||||
if [ -z "$file_path" ]; then
|
||||
echo "cannot find moe_distribute_base.h file in CANN env"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
TARGET_DIR="$SCRIPT_DIR/dispatch_ffn_combine/op_kernel/utils/"
|
||||
TARGET_FILE="$TARGET_DIR/$(basename "$file_path")"
|
||||
|
||||
echo "*************************************"
|
||||
echo $file_path
|
||||
echo "$TARGET_DIR"
|
||||
cp "$file_path" "$TARGET_DIR"
|
||||
|
||||
sed -i 's/struct HcclOpResParam {/struct HcclOpResParamCustom {/g' "$TARGET_FILE"
|
||||
sed -i 's/struct HcclRankRelationResV2 {/struct HcclRankRelationResV2Custom {/g' "$TARGET_FILE"
|
||||
|
||||
|
||||
# build custom ops
|
||||
cd csrc
|
||||
|
||||
Reference in New Issue
Block a user