-
Notifications
You must be signed in to change notification settings - Fork 629
[Kernel] add custom op DispatchGmmCombineDecode #4139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+7,851
−27
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| # This file is a part of the CANN Open Software. | ||
| # Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). | ||
| # Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| # See LICENSE in the root of the software repository for the full text of the License. | ||
| # ====================================================================================================================== | ||
|
|
||
| set(_DISPATCH_GMM_INC_OPTS) | ||
| if (EXISTS ${CMAKE_SOURCE_DIR}/third_party/catlass/include) | ||
| list(APPEND _DISPATCH_GMM_INC_OPTS -I${CMAKE_SOURCE_DIR}/third_party/catlass/include) | ||
| else() | ||
| message(FATAL_ERROR "dependency catlass is missing, you can fetch it by running 'git submodule update --init --recursive'") | ||
| endif() | ||
|
|
||
| add_ops_compile_options( | ||
| OP_NAME DispatchGmmCombineDecode | ||
| OPTIONS --cce-auto-sync=off | ||
| -Wno-deprecated-declarations | ||
| -Werror | ||
| ${_DISPATCH_GMM_INC_OPTS} | ||
| ) | ||
|
|
||
| target_sources(op_host_aclnnInner PRIVATE | ||
| dispatch_gmm_combine_decode_def.cpp | ||
| ) | ||
|
|
||
| target_sources(opapi PRIVATE | ||
| aclnn_dispatch_gmm_combine_decode.cpp | ||
| ) | ||
|
|
||
| if (NOT BUILD_OPEN_PROJECT) | ||
| target_sources(aclnn_ops_train PRIVATE | ||
| aclnn_dispatch_gmm_combine_decode.cpp | ||
| ) | ||
|
|
||
| target_sources(aclnn_ops_infer PRIVATE | ||
| aclnn_dispatch_gmm_combine_decode.cpp | ||
| ) | ||
| endif () | ||
|
|
||
| target_sources(optiling PRIVATE | ||
| dispatch_gmm_combine_decode_tiling.cpp | ||
| ) | ||
|
|
||
| target_include_directories(optiling PRIVATE | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ) | ||
|
|
||
| target_sources(opsproto PRIVATE | ||
| dispatch_gmm_combine_decode_proto.cpp | ||
| ) | ||
|
|
||
| file(GLOB _GMM_Aclnn_header "${CMAKE_CURRENT_SOURCE_DIR}/aclnn_dispatch_gmm_combine_decode.h") | ||
|
|
||
| install(FILES ${_GMM_Aclnn_header} | ||
| DESTINATION ${ACLNN_INC_INSTALL_DIR} OPTIONAL | ||
| ) |
101 changes: 101 additions & 0 deletions
101
csrc/dispatch_gmm_combine_decode/op_host/aclnn_dispatch_gmm_combine_decode.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| /* | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| * This file is a part of the CANN Open Software. | ||
| * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). | ||
| * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| * See LICENSE in the root of the software repository for the full text of the License. | ||
| */ | ||
| #include <string.h> | ||
| #include "graph/types.h" | ||
| #include "aclnn/opdev/platform.h" | ||
| #include "aclnn_dispatch_gmm_combine_decode.h" | ||
|
|
||
| enum NnopbaseHcclServerType { | ||
| NNOPBASE_HCCL_SERVER_TYPE_AICPU = 0, | ||
| NNOPBASE_HCCL_SERVER_TYPE_MTE, | ||
| NNOPBASE_HCCL_SERVER_TYPE_END | ||
| }; | ||
| extern "C" void __attribute__((weak)) NnopbaseSetHcclServerType(void *executor, NnopbaseHcclServerType sType); | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| extern aclnnStatus aclnnInnerDispatchGmmCombineDecodeGetWorkspaceSize( | ||
| const aclTensor *x, | ||
| const aclTensor *expertIds, | ||
| const aclTensor *gmm1PermutedWeight, | ||
| const aclTensor *gmm1PermutedWeightScale, | ||
| const aclTensor *gmm2Weight, | ||
| const aclTensor *gmm2WeightScale, | ||
| const aclTensor *expertSmoothScalesOptional, | ||
| const aclTensor *expertScalesOptional, | ||
| char *groupEp, | ||
| int64_t epRankSize, | ||
| int64_t epRankId, | ||
| int64_t moeExpertNum, | ||
| int64_t shareExpertNum, | ||
| int64_t shareExpertRankNum, | ||
| int64_t quantMode, | ||
| int64_t globalBs, | ||
| const aclTensor *output, | ||
| const aclTensor *epRecvCount, | ||
| uint64_t *workspaceSize, | ||
| aclOpExecutor **executor); | ||
| extern aclnnStatus aclnnInnerDispatchGmmCombineDecode( | ||
| void *workspace, | ||
| uint64_t workspaceSize, | ||
| aclOpExecutor *executor, | ||
| aclrtStream stream); | ||
|
|
||
| aclnnStatus aclnnDispatchGmmCombineDecodeGetWorkspaceSize( | ||
| const aclTensor *x, | ||
| const aclTensor *expertIds, | ||
| const aclTensor *gmm1PermutedWeight, | ||
| const aclTensor *gmm1PermutedWeightScale, | ||
| const aclTensor *gmm2Weight, | ||
| const aclTensor *gmm2WeightScale, | ||
| const aclTensor *expertSmoothScalesOptional, | ||
| const aclTensor *expertScalesOptional, | ||
| char *groupEp, | ||
| int64_t epRankSize, | ||
| int64_t epRankId, | ||
| int64_t moeExpertNum, | ||
| int64_t shareExpertNum, | ||
| int64_t shareExpertRankNum, | ||
| int64_t quantMode, | ||
| int64_t globalBs, | ||
| const aclTensor *output, | ||
| const aclTensor *epRecvCount, | ||
| uint64_t *workspaceSize, | ||
| aclOpExecutor **executor) | ||
| { | ||
| return aclnnInnerDispatchGmmCombineDecodeGetWorkspaceSize(x, expertIds, gmm1PermutedWeight, gmm1PermutedWeightScale, | ||
| gmm2Weight, gmm2WeightScale, expertSmoothScalesOptional, expertScalesOptional, groupEp, epRankSize, | ||
| epRankId, moeExpertNum, shareExpertNum, shareExpertRankNum, quantMode, globalBs, | ||
| output, epRecvCount, workspaceSize, executor); | ||
| } | ||
|
|
||
| aclnnStatus aclnnDispatchGmmCombineDecode( | ||
| void *workspace, | ||
| uint64_t workspaceSize, | ||
| aclOpExecutor *executor, | ||
| aclrtStream stream) | ||
| { | ||
| if (NnopbaseSetHcclServerType) { | ||
| if (op::GetCurrentPlatformInfo().GetSocVersion() == op::SocVersion::ASCEND910B) { | ||
| NnopbaseSetHcclServerType(executor, NNOPBASE_HCCL_SERVER_TYPE_AICPU); | ||
| } else { | ||
| NnopbaseSetHcclServerType(executor, NNOPBASE_HCCL_SERVER_TYPE_MTE); | ||
| } | ||
| } | ||
| return aclnnInnerDispatchGmmCombineDecode(workspace, workspaceSize, executor, stream); | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
|
|
51 changes: 51 additions & 0 deletions
51
csrc/dispatch_gmm_combine_decode/op_host/aclnn_dispatch_gmm_combine_decode.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Copyright (c) 2025 Huawei Technologies Co., Ltd. | ||
| * This file is a part of the CANN Open Software. | ||
| * Licensed under CANN Open Software License Agreement Version 1.0 (the "License"). | ||
| * Please refer to the License for details. You may not use this file except in compliance with the License. | ||
| * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, | ||
| * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. | ||
| * See LICENSE in the root of the software repository for the full text of the License. | ||
| */ | ||
| #ifndef DISPATCH_GMM_COMBINE_DECODE | ||
| #define DISPATCH_GMM_COMBINE_DECODE | ||
|
|
||
| #include "aclnn/acl_meta.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| __attribute__((visibility("default"))) aclnnStatus aclnnDispatchGmmCombineDecodeGetWorkspaceSize( | ||
| const aclTensor *x, | ||
| const aclTensor *expertIds, | ||
| const aclTensor *gmm1PermutedWeight, | ||
| const aclTensor *gmm1PermutedWeightScale, | ||
| const aclTensor *gmm2Weight, | ||
| const aclTensor *gmm2WeightScale, | ||
| const aclTensor *expertSmoothScalesOptional, | ||
| const aclTensor *expertScalesOptional, | ||
| char *groupEp, | ||
| int64_t epRankSize, | ||
| int64_t epRankId, | ||
| int64_t moeExpertNum, | ||
| int64_t shareExpertNum, | ||
| int64_t shareExpertRankNum, | ||
| int64_t quantMode, | ||
| int64_t globalBs, | ||
| const aclTensor *output, | ||
| const aclTensor *epRecvCount, | ||
| uint64_t *workspaceSize, | ||
| aclOpExecutor **executor); | ||
|
|
||
| __attribute__((visibility("default"))) aclnnStatus aclnnDispatchGmmCombineDecode( | ||
| void *workspace, | ||
| uint64_t workspaceSize, | ||
| aclOpExecutor *executor, | ||
| aclrtStream stream); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file is for model only, no need to add it here. @Potabk
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can add a new job for the ops at the end of https://github.com/vllm-project/vllm-ascend/blob/main/.github/workflows/vllm_ascend_test_nightly_a3.yaml , That's enough for your PR; I'll do a more detailed restructuring later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done