init v0.23.0

Signed-off-by: Sun Ruoxi <sunruoxi@4paradigm.com>
This commit is contained in:
2026-08-27 15:11:51 +08:00
parent b582a8e7d1
commit 7f8a1b1f7a
2849 changed files with 712887 additions and 22001 deletions

View File

@@ -0,0 +1,128 @@
/**
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.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.
*/
/*!
* \file aclnn_vllm_quant_lightning_indexer_metadata.cpp
* \brief
*/
#include "aclnn_vllm_quant_lightning_indexer_metadata.h"
#include "aclnn/aclnn_base.h"
#include "aclnn_kernels/common/op_error_check.h"
#include "aclnn_kernels/contiguous.h"
#include "aclnn_kernels/reshape.h"
#include "l0_vllm_quant_lightning_indexer_metadata.h"
#include "opdev/common_types.h"
#include "opdev/data_type_utils.h"
#include "opdev/format_utils.h"
#include "opdev/make_op_executor.h"
#include "opdev/op_dfx.h"
#include "opdev/op_executor.h"
#include "opdev/op_log.h"
#include "opdev/tensor_view_utils.h"
#include "opdev/platform.h"
#ifdef __cplusplus
extern "C" {
#endif
static aclnnStatus ParamsCheck(
const aclTensor* actualSeqLengthsQueryOptional,
const aclTensor* actualSeqLengthsKeyOptional,
int64_t numHeadsQ,
int64_t numHeadsK,
int64_t headDim,
int64_t queryQuantMode,
int64_t keyQuantMode,
int64_t batchSizeOptional,
int64_t maxSeqlenQOptional,
int64_t maxSeqlenKOptional,
char* layoutQueryOptional,
char* layoutKeyOptional,
int64_t sparseCountOptional,
int64_t sparseModeOptional,
int64_t preTokensOptional,
int64_t nextTokensOptional,
int64_t cmpRatioOptional,
const aclTensor* metaData) {
return ACLNN_SUCCESS;
}
__attribute__((visibility("default")))
aclnnStatus aclnnVllmQuantLightningIndexerMetadataGetWorkspaceSize(
const aclTensor* actualSeqLengthsQueryOptional,
const aclTensor* actualSeqLengthsKeyOptional,
int64_t numHeadsQ,
int64_t numHeadsK,
int64_t headDim,
int64_t queryQuantMode,
int64_t keyQuantMode,
int64_t batchSizeOptional,
int64_t maxSeqlenQOptional,
int64_t maxSeqlenKOptional,
char* layoutQueryOptional,
char* layoutKeyOptional,
int64_t sparseCountOptional,
int64_t sparseModeOptional,
int64_t preTokensOptional,
int64_t nextTokensOptional,
int64_t cmpRatioOptional,
const aclTensor* metaData,
uint64_t* workspaceSize,
aclOpExecutor** executor) {
L2_DFX_PHASE_1(
aclnnVllmQuantLightningIndexerMetadata,
DFX_IN(actualSeqLengthsQueryOptional, actualSeqLengthsKeyOptional, numHeadsQ, numHeadsK, headDim, queryQuantMode,
keyQuantMode, batchSizeOptional, maxSeqlenQOptional, maxSeqlenKOptional, layoutQueryOptional, layoutKeyOptional,
sparseCountOptional, sparseModeOptional, preTokensOptional, nextTokensOptional, cmpRatioOptional),
DFX_OUT(metaData));
auto uniqueExecutor = CREATE_EXECUTOR();
CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);
auto ret = ParamsCheck(actualSeqLengthsQueryOptional, actualSeqLengthsKeyOptional, numHeadsQ, numHeadsK, headDim, queryQuantMode,
keyQuantMode, batchSizeOptional, maxSeqlenQOptional, maxSeqlenKOptional, layoutQueryOptional, layoutKeyOptional,
sparseCountOptional, sparseModeOptional, preTokensOptional, nextTokensOptional, cmpRatioOptional, metaData);
CHECK_RET(ret == ACLNN_SUCCESS, ret);
const op::PlatformInfo &npuInfo = op::GetCurrentPlatformInfo();
uint32_t aicCoreNum = npuInfo.GetCubeCoreNum();
uint32_t aivCoreNum = npuInfo.GetVectorCoreNum();
const char* socVersion = npuInfo.GetSocLongVersion().c_str();
auto actualSeqLengthsQueryOptionalContiguous = l0op::Contiguous(actualSeqLengthsQueryOptional, uniqueExecutor.get());
CHECK_RET(actualSeqLengthsQueryOptionalContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
auto actualSeqLengthsKeyOptionalContiguous = l0op::Contiguous(actualSeqLengthsKeyOptional, uniqueExecutor.get());
CHECK_RET(actualSeqLengthsKeyOptionalContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR);
auto output = l0op::VllmQuantLightningIndexerMetadata(
actualSeqLengthsQueryOptionalContiguous, actualSeqLengthsKeyOptionalContiguous, aicCoreNum, aivCoreNum, socVersion,
numHeadsQ, numHeadsK, headDim, queryQuantMode, keyQuantMode, batchSizeOptional, maxSeqlenQOptional,
maxSeqlenKOptional, layoutQueryOptional, layoutKeyOptional, sparseCountOptional, sparseModeOptional,
preTokensOptional, nextTokensOptional, cmpRatioOptional, metaData, uniqueExecutor.get());
CHECK_RET(output != nullptr, ACLNN_ERR_INNER_NULLPTR);
*workspaceSize = 0;
uniqueExecutor.ReleaseTo(executor);
return ACLNN_SUCCESS;
}
__attribute__((visibility("default"))) aclnnStatus
aclnnVllmQuantLightningIndexerMetadata(void* workspace,
uint64_t workspaceSize,
aclOpExecutor* executor,
aclrtStream stream) {
L2_DFX_PHASE_2(aclnnVllmQuantLightningIndexerMetadata);
return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);
}
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,83 @@
/**
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.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 ACLNN_QUANT_LIGHTNING_INDEXER_METADATA_AICPU_H
#define ACLNN_QUANT_LIGHTNING_INDEXER_METADATA_AICPU_H
#include "aclnn/aclnn_base.h"
#ifdef __cplusplus
extern "C" {
#endif
/* function: aclnnVllmQuantLightningIndexerMetadataGetWorkspaceSize
* parameters :
* actualSeqLengthsQuery : optional
* actualSeqLengthsKey : optional
* numHeadsQ : required
* numHeadsK : required
* headDim : required
* queryQuantMode : required
* keyQuantMode : required
* int64_t batchSize : optional
* int64_t maxSeqlenQ : optional
* int64_t maxSeqlenK : optional
* char* layoutQuery : optional
* char* layoutKey : optional
* int64_t sparseCount : optional
* int64_t sparseMode : optional
* int64_t preTokens : optional
* int64_t nextTokens : optional
* cmpRatio : optional
* out : required
* workspaceSize : size of workspace(output).
* executor : executor context(output).
*/
__attribute__((visibility("default"))) aclnnStatus
aclnnVllmQuantLightningIndexerMetadataGetWorkspaceSize(
const aclTensor* actualSeqLengthsQueryOptional,
const aclTensor* actualSeqLengthsKeyOptional,
int64_t numHeadsQ,
int64_t numHeadsK,
int64_t headDim,
int64_t queryQuantMode,
int64_t keyQuantMode,
int64_t batchSizeOptional,
int64_t maxSeqlenQOptional,
int64_t maxSeqlenKOptional,
char* layoutQueryOptional,
char* layoutKeyOptional,
int64_t sparseCountOptional,
int64_t sparseModeOptional,
int64_t preTokensOptional,
int64_t nextTokensOptional,
int64_t cmpRatioOptional,
const aclTensor* metaData,
uint64_t* workspaceSize,
aclOpExecutor** executor);
/* function: aclnnVllmQuantLightningIndexerMetadata
* parameters :
* workspace : workspace memory addr(input).
* workspaceSize : size of workspace(input).
* executor : executor context(input).
* stream : acl stream.
*/
__attribute__((visibility("default"))) aclnnStatus
aclnnVllmQuantLightningIndexerMetadata(void* workspace,
uint64_t workspaceSize,
aclOpExecutor* executor,
aclrtStream stream);
#ifdef __cplusplus
}
#endif
#endif // ACLNN_QUANT_LIGHTNING_INDEXER_METADATA_AICPU_H

View File

@@ -0,0 +1,75 @@
/**
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.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.
*/
/*!
* \file l0_vllm_quant_lightning_indexer_metadata.cpp
* \brief
*/
#include "l0_vllm_quant_lightning_indexer_metadata.h"
#include "opdev/aicpu/aicpu_task.h"
#include "opdev/make_op_executor.h"
#include "opdev/op_def.h"
#include "opdev/op_dfx.h"
#include "opdev/op_executor.h"
#include "opdev/op_log.h"
#include "opdev/shape_utils.h"
using namespace op;
namespace l0op {
OP_TYPE_REGISTER(VllmQuantLightningIndexerMetadata);
const aclTensor* VllmQuantLightningIndexerMetadata(
const aclTensor* actualSeqLengthsQueryOptional,
const aclTensor* actualSeqLengthsKeyOptional,
int64_t aicCoreNum,
int64_t aivCoreNum,
const char* socVersion,
int64_t numHeadsQ,
int64_t numHeadsK,
int64_t headDim,
int64_t queryQuantMode,
int64_t keyQuantMode,
int64_t batchSizeOptional,
int64_t maxSeqlenQOptional,
int64_t maxSeqlenKOptional,
char* layoutQueryOptional,
char* layoutKeyOptional,
int64_t sparseCountOptional,
int64_t sparseModeOptional,
int64_t preTokensOptional,
int64_t nextTokensOptional,
int64_t cmpRatioOptional,
const aclTensor* metaData,
aclOpExecutor* executor) {
L0_DFX(VllmQuantLightningIndexerMetadata, actualSeqLengthsQueryOptional, actualSeqLengthsKeyOptional, aicCoreNum, aivCoreNum, socVersion,
numHeadsQ, numHeadsK, headDim, queryQuantMode, keyQuantMode, batchSizeOptional, maxSeqlenQOptional,
maxSeqlenKOptional, layoutQueryOptional, layoutKeyOptional, sparseCountOptional, sparseModeOptional,
preTokensOptional, nextTokensOptional, cmpRatioOptional, metaData);
static internal::AicpuTaskSpace space("VllmQuantLightningIndexerMetadata");
auto ret = ADD_TO_LAUNCHER_LIST_AICPU(
VllmQuantLightningIndexerMetadata,
OP_ATTR_NAMES({"aic_core_num", "aiv_core_num", "soc_version", "num_heads_q", "num_heads_k", "head_dim", "query_quant_mode",
"key_quant_mode", "batch_size", "max_seqlen_q", "max_seqlen_k", "layout_query", "layout_key", "sparse_count",
"sparse_mode", "pre_tokens", "next_tokens", "cmp_ratio"}),
OP_INPUT(actualSeqLengthsQueryOptional, actualSeqLengthsKeyOptional), OP_OUTPUT(metaData),
OP_ATTR(aicCoreNum, aivCoreNum, socVersion, numHeadsQ, numHeadsK, headDim, queryQuantMode, keyQuantMode,
batchSizeOptional, maxSeqlenQOptional, maxSeqlenKOptional, layoutQueryOptional, layoutKeyOptional,
sparseCountOptional, sparseModeOptional, preTokensOptional, nextTokensOptional, cmpRatioOptional));
OP_CHECK(ret == ACL_SUCCESS,
OP_LOGE(ACLNN_ERR_INNER_NULLPTR,
"VllmQuantLightningIndexerMetadata"
" ADD_TO_LAUNCHER_LIST_AICPU failed."),
return nullptr);
return metaData;
}
} // namespace l0op

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2026 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.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 L0_QUANT_LIGHTNING_INDEXER_METADATA_AICPU_H
#define L0_QUANT_LIGHTNING_INDEXER_METADATA_AICPU_H
#include "opdev/op_executor.h"
namespace l0op {
const aclTensor* VllmQuantLightningIndexerMetadata(
const aclTensor* actualSeqLengthsQueryOptional,
const aclTensor* actualSeqLengthsKeyOptional,
int64_t aicCoreNum,
int64_t aivCoreNum,
const char* socVersion,
int64_t numHeadsQ,
int64_t numHeadsK,
int64_t headDim,
int64_t queryQuantMode,
int64_t keyQuantMode,
int64_t batchSizeOptional,
int64_t maxSeqlenQOptional,
int64_t maxSeqlenKOptional,
char* layoutQueryOptional,
char* layoutKeyOptional,
int64_t sparseCountOptional,
int64_t sparseModeOptional,
int64_t preTokensOptional,
int64_t nextTokensOptional,
int64_t cmpRatioOptional,
const aclTensor* metaData,
aclOpExecutor* executor);
} // namespace l0op
#endif