diff --git a/csrc/add_rms_norm_bias/op_host/add_rms_norm_bias_tiling.h b/csrc/add_rms_norm_bias/op_host/add_rms_norm_bias_tiling.h index 5619d79e..20c42023 100644 --- a/csrc/add_rms_norm_bias/op_host/add_rms_norm_bias_tiling.h +++ b/csrc/add_rms_norm_bias/op_host/add_rms_norm_bias_tiling.h @@ -44,7 +44,7 @@ END_TILING_DATA_DEF; struct AddRmsNormBiasCompileInfo { uint32_t totalCoreNum = 0; uint64_t totalUbSize = 0; - platform_ascendc::SocVersion socVersion = platform_ascendc::SocVersion::ASCEND910_95; + platform_ascendc::SocVersion socVersion = platform_ascendc::SocVersion::VLLM_ASCEND_950_SOC_ENUM; }; REGISTER_TILING_DATA_CLASS(AddRmsNormBias, AddRMSNormBiasTilingData) diff --git a/csrc/cmake/config.cmake b/csrc/cmake/config.cmake index 38553f82..b352a8bf 100644 --- a/csrc/cmake/config.cmake +++ b/csrc/cmake/config.cmake @@ -17,6 +17,7 @@ if ((NOT Python3_FOUND) OR (${Python3_EXECUTABLE} STREQUAL "")) message(FATAL_ERROR "Can't find python3.") endif () set(HI_PYTHON "${Python3_EXECUTABLE}" CACHE STRING "python executor") +include(CheckCXXSourceCompiles) # Get the base CANN path if (CUSTOM_ASCEND_CANN_PACKAGE_PATH) @@ -30,6 +31,52 @@ else() endif () message(STATUS "ASCEND_CANN_PACKAGE_PATH=${ASCEND_CANN_PACKAGE_PATH}") +# Detect A5-compatible SoC enum support from the CANN headers we are compiling against. +set(_saved_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") +set(CMAKE_REQUIRED_INCLUDES + ${ASCEND_CANN_PACKAGE_PATH}/include + ${ASCEND_CANN_PACKAGE_PATH}/include/external + ${ASCEND_CANN_PACKAGE_PATH}/include/experiment/platform + ${ASCEND_CANN_PACKAGE_PATH}/include/experiment/runtime +) + +check_cxx_source_compiles([[ + #include "tiling/platform/platform_ascendc.h" + int main() + { + auto soc = platform_ascendc::SocVersion::ASCEND950; + (void)soc; + return 0; + } +]] VLLM_ASCEND_HAS_SOC_ASCEND950) + +check_cxx_source_compiles([[ + #include "tiling/platform/platform_ascendc.h" + int main() + { + auto soc = platform_ascendc::SocVersion::ASCEND910_95; + (void)soc; + return 0; + } +]] VLLM_ASCEND_HAS_SOC_ASCEND910_95) + +if (VLLM_ASCEND_HAS_SOC_ASCEND950) + set(VLLM_ASCEND_950_SOC_ENUM "ASCEND950") + set(VLLM_ASCEND_950_SOC_CONFIG "ascend950") +elseif (VLLM_ASCEND_HAS_SOC_ASCEND910_95) + set(VLLM_ASCEND_950_SOC_ENUM "ASCEND910_95") + set(VLLM_ASCEND_950_SOC_CONFIG "ascend910_95") +else () + message(FATAL_ERROR + "Neither platform_ascendc::SocVersion::ASCEND950 nor ASCEND910_95 is available in CANN headers.") +endif () + +set(CMAKE_REQUIRED_INCLUDES "${_saved_CMAKE_REQUIRED_INCLUDES}") +unset(_saved_CMAKE_REQUIRED_INCLUDES) + +message(STATUS "VLLM_ASCEND_950_SOC_ENUM=${VLLM_ASCEND_950_SOC_ENUM}, " + "VLLM_ASCEND_950_SOC_CONFIG=${VLLM_ASCEND_950_SOC_CONFIG}") + ######################################################################################################################## # Common Configuration ######################################################################################################################## diff --git a/csrc/cmake/intf_pub.cmake b/csrc/cmake/intf_pub.cmake index 4856aeef..65f0522d 100644 --- a/csrc/cmake/intf_pub.cmake +++ b/csrc/cmake/intf_pub.cmake @@ -64,6 +64,8 @@ target_compile_definitions(intf_pub INTERFACE $<$:_GLIBCXX_USE_CXX11_ABI=0> $<$:_FORTIFY_SOURCE=2> + $<$:VLLM_ASCEND_950_SOC_ENUM=${VLLM_ASCEND_950_SOC_ENUM}> + $<$:VLLM_ASCEND_950_SOC_CONFIG=\"${VLLM_ASCEND_950_SOC_CONFIG}\"> ) target_link_options(intf_pub INTERFACE diff --git a/csrc/moe_gating_top_k/op_host/moe_gating_top_k_def.cpp b/csrc/moe_gating_top_k/op_host/moe_gating_top_k_def.cpp index 52ecf37d..d7b1909c 100644 --- a/csrc/moe_gating_top_k/op_host/moe_gating_top_k_def.cpp +++ b/csrc/moe_gating_top_k/op_host/moe_gating_top_k_def.cpp @@ -63,9 +63,9 @@ public: .DynamicRankSupportFlag(true) .DynamicShapeSupportFlag(true) .ExtendCfgInfo("opFile.value", "moe_gating_top_k_apt"); - this->AICore().AddConfig("ascend910_95", regbaseCfg); + this->AICore().AddConfig(VLLM_ASCEND_950_SOC_CONFIG, regbaseCfg); } }; OP_ADD(MoeGatingTopK); -} // namespace ops \ No newline at end of file +} // namespace ops diff --git a/csrc/moe_gating_top_k/op_host/moe_gating_top_k_tiling_arch35.cpp b/csrc/moe_gating_top_k/op_host/moe_gating_top_k_tiling_arch35.cpp index 803b3746..bdbf6b83 100644 --- a/csrc/moe_gating_top_k/op_host/moe_gating_top_k_tiling_arch35.cpp +++ b/csrc/moe_gating_top_k/op_host/moe_gating_top_k_tiling_arch35.cpp @@ -27,7 +27,7 @@ #define CEIL_DIV(a, b) (((a) + (b) - 1) / (b)) #endif namespace optiling { -const static uint64_t MOE_GATING_TOP_K_REGBASE_TILING_KEY = 10000; +const static uint64_t MOE_GATING_TOP_K_ASCEND_950_TILING_KEY = 10000; const static int64_t GROUP_SELECT_MODE_MAX = 0; const static int64_t GROUP_SELECT_MODE_SUM = 1; @@ -79,7 +79,7 @@ public: protected: bool IsCapable() override { - if (socVersion != platform_ascendc::SocVersion::ASCEND910_95) { + if (socVersion != platform_ascendc::SocVersion::VLLM_ASCEND_950_SOC_ENUM) { return false; } return true; @@ -508,7 +508,7 @@ ge::graphStatus MoeGatingTopKTilingRegbase::PostTiling() uint64_t MoeGatingTopKTilingRegbase::GetTilingKey() const { - return MOE_GATING_TOP_K_REGBASE_TILING_KEY; + return MOE_GATING_TOP_K_ASCEND_950_TILING_KEY; } void MoeGatingTopKTilingRegbase::Reset() diff --git a/csrc/moe_init_routing_custom/op_host/moe_init_routing_custom_tiling.cpp b/csrc/moe_init_routing_custom/op_host/moe_init_routing_custom_tiling.cpp index 608ee253..b487c3ad 100644 --- a/csrc/moe_init_routing_custom/op_host/moe_init_routing_custom_tiling.cpp +++ b/csrc/moe_init_routing_custom/op_host/moe_init_routing_custom_tiling.cpp @@ -1263,5 +1263,5 @@ void MoeInitRountingCustomTilingBase::Tiling4GatherOutCompute() lastCorePerLoopIndicesElements, lastCoreLastLoopIndicesElements); } -REGISTER_TILING_TEMPLATE("MoeInitRoutingCustom", MoeInitRountingCustomTilingBase, 10000); // If not 910_95, fallback to this. -} // namespace optiling \ No newline at end of file +REGISTER_TILING_TEMPLATE("MoeInitRoutingCustom", MoeInitRountingCustomTilingBase, 10000); // Fallback template for non-Ascend950 SoC. +} // namespace optiling