### What this PR does / why we need it?
This PR supports W8A8C8 in dsv3.2/glm5 with lightning_indexer_quant ops
in pd-mix stage mainly.
Because the code for the current PD-disaggregated scenario is still
under refactoring and cleanup, this PR prioritizes ensuring the C8
functionality in the pd-mix scenario.
The next steps are planned in two parts:
① Once the optimized scatter operator is updated, we will replace the
original operator to improve the performance of storing k_scale.
② Once the code logic for the PD-disaggregated scenario becomes stable,
we will carry out more comprehensive validation and make appropriate
adaptations.
③ Because enabling C8 currently introduces several new operators whose
performance still needs improvement, performance may regress in some
scenarios. Therefore, only after all the operators are fully ready can
we ensure that this feature does not cause any performance degradation.
At that point, we will enable this feature by default and remove the
switch in `additional_config`.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
CI passed with new added/existing test.
- vLLM version: v0.16.0
- vLLM main:
4034c3d32e
---------
Signed-off-by: rjg-lyh <1318825571@qq.com>
89 lines
3.1 KiB
Bash
89 lines
3.1 KiB
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
|
|
# dependency: catlass
|
|
git config --global --add safe.directory "$ROOT_DIR"
|
|
CATLASS_PATH=${ROOT_DIR}/csrc/third_party/catlass/include
|
|
if [[ ! -d "${CATLASS_PATH}" ]]; then
|
|
echo "dependency catlass is missing, try to fetch it..."
|
|
if ! git submodule update --init --recursive; then
|
|
echo "fetch failed"
|
|
exit 1
|
|
fi
|
|
fi
|
|
ABSOLUTE_CATLASS_PATH=$(cd "${CATLASS_PATH}" && pwd)
|
|
export CPATH=${ABSOLUTE_CATLASS_PATH}:${CPATH}
|
|
|
|
|
|
CUSTOM_OPS="moe_grouped_matmul;grouped_matmul_swiglu_quant_weight_nz_tensor_list;lightning_indexer_vllm;sparse_flash_attention;matmul_allreduce_add_rmsnorm;moe_init_routing_custom;moe_gating_top_k;add_rms_norm_bias;apply_top_k_top_p_custom;transpose_kv_cache_by_block;copy_and_expand_eagle_inputs;causal_conv1d;lightning_indexer_quant;"
|
|
SOC_ARG="ascend910b"
|
|
elif [[ "$SOC_VERSION" =~ ^ascend910_93 ]]; then
|
|
# ASCEND910C (A3) series
|
|
# dependency: catlass
|
|
git config --global --add safe.directory "$ROOT_DIR"
|
|
CATLASS_PATH=${ROOT_DIR}/csrc/third_party/catlass/include
|
|
if [[ ! -d "${CATLASS_PATH}" ]]; then
|
|
echo "dependency catlass is missing, try to fetch it..."
|
|
if ! git submodule update --init --recursive; then
|
|
echo "fetch failed"
|
|
exit 1
|
|
fi
|
|
fi
|
|
# dependency: 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/utils/inc/kernel"
|
|
|
|
CUSTOM_OPS_ARRAY=(
|
|
"grouped_matmul_swiglu_quant_weight_nz_tensor_list"
|
|
"lightning_indexer_vllm"
|
|
"sparse_flash_attention"
|
|
"dispatch_ffn_combine"
|
|
"dispatch_ffn_combine_bf16"
|
|
"dispatch_gmm_combine_decode"
|
|
"moe_combine_normal"
|
|
"moe_dispatch_normal"
|
|
"dispatch_layout"
|
|
"notify_dispatch"
|
|
"moe_init_routing_custom"
|
|
"moe_gating_top_k"
|
|
"add_rms_norm_bias"
|
|
"apply_top_k_top_p_custom"
|
|
"transpose_kv_cache_by_block"
|
|
"copy_and_expand_eagle_inputs"
|
|
"causal_conv1d"
|
|
"moe_grouped_matmul"
|
|
"lightning_indexer_quant"
|
|
)
|
|
CUSTOM_OPS=$(IFS=';'; echo "${CUSTOM_OPS_ARRAY[*]}")
|
|
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
|