diff --git a/.github/workflows/_runs-on-nv-step1.yml b/.github/workflows/_runs-on-nv-step1.yml index 845288aa4..79b7ebc84 100644 --- a/.github/workflows/_runs-on-nv-step1.yml +++ b/.github/workflows/_runs-on-nv-step1.yml @@ -77,8 +77,6 @@ jobs: && source ${ENV_PATH}/pt2.0_diopi \ && python main.py --mode gen_data" \ || ( cd ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1} && git clean -xdf ${GEN_DATA} && exit 1 ) - source ~/Aoss_env.sh - ads-cli cp ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ elif [[ "${GETRUNNER}" == *diopi* ]];then ssh SH1424 """ set -e @@ -86,8 +84,6 @@ jobs: cd ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER} && cd ${BUILD_TEST1} && cd diopi_test/python && srun --job-name=${GITHUB_JOB} --partition=${SLURM_PAR_V100} --time=20 --gres=gpu:1 bash -c 'python main.py --mode gen_data' \ || ( cd ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1} && git clean -xdf ${GEN_DATA} && exit 1 ) - source ~/Aoss_env.sh - ads-cli cp ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ """ else ln -s ${GEN_DATA_PATH}/${GEN_DATA}/diopi ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ diff --git a/.github/workflows/data-cron.yml b/.github/workflows/data-cron.yml index 61b173e40..f86b695b6 100644 --- a/.github/workflows/data-cron.yml +++ b/.github/workflows/data-cron.yml @@ -93,6 +93,7 @@ jobs: mkdir -p ${DATA_DIR}/source/${GEN_DATA} rsync -a --delete ${CLUSTER_V100}:${DATA_DIR}/source/${GEN_DATA}/diopi/ ${DATA_DIR}/source/${GEN_DATA}/diopi/ """ +<<<<<<< HEAD # ssh ${CLUSTER_ASCEND_910B} """ # mkdir -p ${DATA_DIR}/source/${GEN_DATA} # rsync -a --delete ${CLUSTER_V100}:${DATA_DIR}/source/${GEN_DATA}/diopi/ ${DATA_DIR}/source/${GEN_DATA}/diopi/ @@ -114,4 +115,13 @@ jobs: run: | set -e source ~/Aoss_env.sh - ads-cli cp s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss-internal.cn-sh-01c.sensecoreapi-oss.cn${DATA_DIR}/source/${GEN_DATA}/diopi/ ${DATA_DIR}/source/${GEN_DATA}/diopi/ \ No newline at end of file + ads-cli cp s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss-internal.cn-sh-01c.sensecoreapi-oss.cn${DATA_DIR}/source/${GEN_DATA}/diopi/ ${DATA_DIR}/source/${GEN_DATA}/diopi/ +======= + ssh ${CLUSTER_ASCEND_910B} """ + mkdir -p ${DATA_DIR}/source/${GEN_DATA} + rsync -a --delete ${CLUSTER_V100}:${DATA_DIR}/source/${GEN_DATA}/diopi/ ${DATA_DIR}/source/${GEN_DATA}/diopi/ + """ + # ssh ${CLUSTER_SUPA} """ + # rsync -a ${CLUSTER_V100}:${DATA_DIR}/source/${GEN_DATA}/diopi/ ${DATA_DIR}/source/${GEN_DATA}/diopi/ + # """ +>>>>>>> 2b566db5 ([ci]fix Ascend CI (#1275)) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index beb3d2345..038a5a990 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -96,10 +96,8 @@ jobs: && rsync -a --delete ${GITHUB_WORKSPACE}/source/ ${CLUSTER_SUPA}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ || echo "failure to connect to supa" ssh ${CLUSTER_1424} "mkdir -p ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source" \ && rsync -a --delete ${GITHUB_WORKSPACE}/source/ ${CLUSTER_1424}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ || echo "failure to connect to sh1424" - # ssh ${CLUSTER_ASCEND_910B} "mkdir -p ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source" \ - # && rsync -a --delete ${GITHUB_WORKSPACE}/source/ ${CLUSTER_ASCEND_910B}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ || echo "failure to connect to ascend 910b" - source ~/Aoss_env.sh - ads-cli cp ${GITHUB_WORKSPACE}/source/ s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ + ssh ${CLUSTER_ASCEND_910B} "mkdir -p ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source" \ + && rsync -a --delete ${GITHUB_WORKSPACE}/source/ ${CLUSTER_ASCEND_910B}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ || echo "failure to connect to ascend 910b" # ssh ${CLUSTER_KLX} "mkdir -p ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source" \ # && rsync -a --delete ${GITHUB_WORKSPACE}/source/ ${CLUSTER_KLX}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ || echo "failure to connect to kunlunxin" @@ -295,12 +293,6 @@ jobs: needs: [Rsync] if: ${{ contains( needs.Rsync.outputs.output, 'ASCEND' ) }} steps: - - name: COPY Source - run: | - set -e - source ~/Aoss_env.sh - ads-cli cp s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss-internal.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ - ads-cli --dryrun --deleteSrc cp s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss-internal.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/source/ /dev/null 2>&1 >/dev/null - name: build run: | set -e @@ -327,10 +319,7 @@ jobs: set -e cd ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1} if [[ \"${{ needs.Rsync.outputs.output }}\" == *GENDATA* ]];then - # rsync -a ${CLUSTER_V100}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/${GEN_DATA}/diopi ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ - source ~/Aoss_env.sh - ads-cli cp s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss-internal.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ - ads-cli --dryrun --deleteSrc cp s3://${Platform_ci_aoss_name}:${Platform_ci_aoss_url}@platform.aoss-internal.cn-sh-01c.sensecoreapi-oss.cn${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ /dev/null 2>&1 >/dev/null + rsync -a ${CLUSTER_V100}:${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/${GEN_DATA}/diopi ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ else ln -s ${GEN_DATA_PATH}/${GEN_DATA}/diopi ${DEEPLINK_PATH}/${GITHUB_RUN_NUMBER}/${BUILD_TEST1}/diopi_test/python/cache/ fi diff --git a/impl/ascend/functions/index.cpp b/impl/ascend/functions/index.cpp new file mode 100644 index 000000000..a28b90c18 --- /dev/null +++ b/impl/ascend/functions/index.cpp @@ -0,0 +1,41 @@ +/** + * @file + * @author DeepLink + * @copyright (c) 2024, DeepLink. + */ + +#include "../aclnn/adaptor.hpp" + +namespace impl { +namespace ascend { + +diopiError_t diopiIndexBackward(diopiContextHandle_t ctx, diopiTensorHandle_t gradInput, diopiTensorHandle_t zerosLikeInput, diopiConstTensorHandle_t* indices, + int64_t nums, diopiConstTensorHandle_t gradOutput) { + AscendTensor gradInputTensor(gradInput); + AscendTensor gradOutputTensor(gradOutput); + if (gradInputTensor.numel() == 0 || gradOutputTensor.numel() == 0) { + return diopiSuccess; + } + + std::vector indicesVec; + indicesVec.reserve(nums); + + for (int i = 0; i < nums; i++) { + if (indices[i] != nullptr) { + indicesVec.emplace_back(indices[i]); + } else { + int64_t array[1] = {0}; + diopiSize_t size = {array, 1}; + diopiTensorHandle_t emptyTensor = nullptr; + diopiRequireTensor(ctx, &emptyTensor, &size, nullptr, gradOutputTensor.dtype(), diopi_device); + indicesVec.emplace_back(emptyTensor); + } + } + + DIOPI_ASCEND_CALL_ACLNN(aclnnInplaceCopy, ctx, gradInput, zerosLikeInput); + DIOPI_ASCEND_CALL_ACLNN(aclnnIndexPutImpl, ctx, gradInput, indicesVec, gradOutput, true, false); + return diopiSuccess; +} + +} // namespace ascend +} // namespace impl diff --git a/impl/ascend/functions/index_put.cpp b/impl/ascend/functions/index_put.cpp new file mode 100644 index 000000000..378dd73c5 --- /dev/null +++ b/impl/ascend/functions/index_put.cpp @@ -0,0 +1,68 @@ +/** + * @file + * @author DeepLink + * @copyright (c) 2024, DeepLink. + */ + +#include "../aclnn/adaptor.hpp" + +namespace impl { +namespace ascend { + +diopiError_t diopiIndexPut(diopiContextHandle_t ctx, diopiTensorHandle_t out, diopiConstTensorHandle_t input, diopiConstTensorHandle_t values, + diopiConstTensorHandle_t* indices, int64_t indicesCounts, bool accumulate) { + AscendTensor inputTensor(input); + AscendTensor valuesTensor(values); + if (inputTensor.numel() == 0 || valuesTensor.numel() == 0) { + return diopiSuccess; + } + + std::vector indicesVec; + indicesVec.reserve(indicesCounts); + + for (int i = 0; i < indicesCounts; i++) { + if (indices[i] != nullptr) { + indicesVec.emplace_back(indices[i]); + } else { + int64_t array[1] = {0}; + diopiSize_t size = {array, 1}; + diopiTensorHandle_t emptyTensor = nullptr; + diopiRequireTensor(ctx, &emptyTensor, &size, nullptr, inputTensor.dtype(), diopi_device); + indicesVec.emplace_back(emptyTensor); + } + } + + DIOPI_ASCEND_CALL_ACLNN(aclnnInplaceCopy, ctx, out, input); + DIOPI_ASCEND_CALL_ACLNN(aclnnIndexPutImpl, ctx, out, indicesVec, values, accumulate, false); + return diopiSuccess; +} + +diopiError_t diopiIndexPutInp(diopiContextHandle_t ctx, diopiTensorHandle_t input, diopiConstTensorHandle_t values, diopiConstTensorHandle_t* indices, + int64_t indicesCounts, bool accumulate) { + AscendTensor inputTensor(input); + AscendTensor valuesTensor(values); + if (inputTensor.numel() == 0 || valuesTensor.numel() == 0) { + return diopiSuccess; + } + + std::vector indicesVec; + indicesVec.reserve(indicesCounts); + + for (int i = 0; i < indicesCounts; i++) { + if (indices[i] != nullptr) { + indicesVec.emplace_back(indices[i]); + } else { + int64_t array[1] = {0}; + diopiSize_t size = {array, 1}; + diopiTensorHandle_t emptyTensor = nullptr; + diopiRequireTensor(ctx, &emptyTensor, &size, nullptr, inputTensor.dtype(), diopi_device); + indicesVec.emplace_back(emptyTensor); + } + } + + DIOPI_ASCEND_CALL_ACLNN(aclnnIndexPutImpl, ctx, input, indicesVec, values, accumulate, false); + return diopiSuccess; +} + +} // namespace ascend +} // namespace impl diff --git a/impl/ascend_npu/CMakeLists.txt b/impl/ascend_npu/CMakeLists.txt index c96ec54b0..f020f550a 100755 --- a/impl/ascend_npu/CMakeLists.txt +++ b/impl/ascend_npu/CMakeLists.txt @@ -174,6 +174,8 @@ set(OLD_IMPL_SRC ${OLD_IMPL_DIR}/functions/arange.cpp ${OLD_IMPL_DIR}/functions/gather.cpp ${OLD_IMPL_DIR}/functions/layer_norm.cpp + ${OLD_IMPL_DIR}/functions/index.cpp + ${OLD_IMPL_DIR}/functions/index_put.cpp ${OLD_IMPL_DIR}/functions/index_select.cpp ${OLD_IMPL_DIR}/functions/repeat.cpp ${OLD_IMPL_DIR}/functions/group_norm.cpp diff --git a/impl/ascend_npu/ascend_config.yaml b/impl/ascend_npu/ascend_config.yaml index 80fb671ea..67eb59db1 100755 --- a/impl/ascend_npu/ascend_config.yaml +++ b/impl/ascend_npu/ascend_config.yaml @@ -100,6 +100,9 @@ ascend: - diopiHardtanh - diopiHardtanhBackward - diopiHardtanhInp +- diopiIndexBackward +- diopiIndexPut +- diopiIndexPutInp - diopiIsNan - diopiIndexSelect - diopiIndexSelectBackward @@ -244,10 +247,7 @@ ascend: - diopiZeros ascend_npu: - diopiCopyInp -- diopiIndexPut -- diopiIndexPutInp - diopiIndex -- diopiIndexBackward - diopiDestIndexCopyKV - diopiTokenAttentionInference - diopiTokenSoftmaxReduceVInference