[csrc][bugfix] Add compile-time Ascend950/910_95 compatibility for custom ops between CANN8.5 and 9.0 (#6936)
### What this PR does / why we need it?
Remove hardcoded ASCEND910_95 usage in csrc custom-op host/tiling code
and
select the SoC target at CMake configure time.
- Probe CANN headers with check_cxx_source_compiles:
prefer platform_ascendc::SocVersion::ASCEND950, fallback to
ASCEND910_95.
- Export the selected enum/config string via shared compile definitions
(VLLM_ASCEND_950_SOC_ENUM / VLLM_ASCEND_950_SOC_CONFIG).
- Apply the shared macros to affected paths (moe_gating_top_k,
add_rms_norm_bias) to avoid per-file hardcoding.
- Keep behavior unchanged; this is an internal build-compatibility fix
for CANN 8.5 and 9.x.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
- vLLM version: v0.16.0
- vLLM main:
15d76f74e2
---------
Signed-off-by: linfeng-yuan <1102311262@qq.com>
This commit is contained in:
@@ -44,7 +44,7 @@ END_TILING_DATA_DEF;
|
|||||||
struct AddRmsNormBiasCompileInfo {
|
struct AddRmsNormBiasCompileInfo {
|
||||||
uint32_t totalCoreNum = 0;
|
uint32_t totalCoreNum = 0;
|
||||||
uint64_t totalUbSize = 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)
|
REGISTER_TILING_DATA_CLASS(AddRmsNormBias, AddRMSNormBiasTilingData)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ if ((NOT Python3_FOUND) OR (${Python3_EXECUTABLE} STREQUAL ""))
|
|||||||
message(FATAL_ERROR "Can't find python3.")
|
message(FATAL_ERROR "Can't find python3.")
|
||||||
endif ()
|
endif ()
|
||||||
set(HI_PYTHON "${Python3_EXECUTABLE}" CACHE STRING "python executor")
|
set(HI_PYTHON "${Python3_EXECUTABLE}" CACHE STRING "python executor")
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
|
||||||
# Get the base CANN path
|
# Get the base CANN path
|
||||||
if (CUSTOM_ASCEND_CANN_PACKAGE_PATH)
|
if (CUSTOM_ASCEND_CANN_PACKAGE_PATH)
|
||||||
@@ -30,6 +31,52 @@ else()
|
|||||||
endif ()
|
endif ()
|
||||||
message(STATUS "ASCEND_CANN_PACKAGE_PATH=${ASCEND_CANN_PACKAGE_PATH}")
|
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
|
# Common Configuration
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ target_compile_definitions(intf_pub
|
|||||||
INTERFACE
|
INTERFACE
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:_GLIBCXX_USE_CXX11_ABI=0>
|
$<$<COMPILE_LANGUAGE:CXX>:_GLIBCXX_USE_CXX11_ABI=0>
|
||||||
$<$<CONFIG:Release>:_FORTIFY_SOURCE=2>
|
$<$<CONFIG:Release>:_FORTIFY_SOURCE=2>
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:VLLM_ASCEND_950_SOC_ENUM=${VLLM_ASCEND_950_SOC_ENUM}>
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:VLLM_ASCEND_950_SOC_CONFIG=\"${VLLM_ASCEND_950_SOC_CONFIG}\">
|
||||||
)
|
)
|
||||||
target_link_options(intf_pub
|
target_link_options(intf_pub
|
||||||
INTERFACE
|
INTERFACE
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ public:
|
|||||||
.DynamicRankSupportFlag(true)
|
.DynamicRankSupportFlag(true)
|
||||||
.DynamicShapeSupportFlag(true)
|
.DynamicShapeSupportFlag(true)
|
||||||
.ExtendCfgInfo("opFile.value", "moe_gating_top_k_apt");
|
.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);
|
OP_ADD(MoeGatingTopK);
|
||||||
} // namespace ops
|
} // namespace ops
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#define CEIL_DIV(a, b) (((a) + (b) - 1) / (b))
|
#define CEIL_DIV(a, b) (((a) + (b) - 1) / (b))
|
||||||
#endif
|
#endif
|
||||||
namespace optiling {
|
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_MAX = 0;
|
||||||
const static int64_t GROUP_SELECT_MODE_SUM = 1;
|
const static int64_t GROUP_SELECT_MODE_SUM = 1;
|
||||||
@@ -79,7 +79,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
bool IsCapable() override
|
bool IsCapable() override
|
||||||
{
|
{
|
||||||
if (socVersion != platform_ascendc::SocVersion::ASCEND910_95) {
|
if (socVersion != platform_ascendc::SocVersion::VLLM_ASCEND_950_SOC_ENUM) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -508,7 +508,7 @@ ge::graphStatus MoeGatingTopKTilingRegbase::PostTiling()
|
|||||||
|
|
||||||
uint64_t MoeGatingTopKTilingRegbase::GetTilingKey() const
|
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()
|
void MoeGatingTopKTilingRegbase::Reset()
|
||||||
|
|||||||
@@ -1263,5 +1263,5 @@ void MoeInitRountingCustomTilingBase::Tiling4GatherOutCompute()
|
|||||||
lastCorePerLoopIndicesElements, lastCoreLastLoopIndicesElements);
|
lastCorePerLoopIndicesElements, lastCoreLastLoopIndicesElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TILING_TEMPLATE("MoeInitRoutingCustom", MoeInitRountingCustomTilingBase, 10000); // If not 910_95, fallback to this.
|
REGISTER_TILING_TEMPLATE("MoeInitRoutingCustom", MoeInitRountingCustomTilingBase, 10000); // Fallback template for non-Ascend950 SoC.
|
||||||
} // namespace optiling
|
} // namespace optiling
|
||||||
|
|||||||
Reference in New Issue
Block a user