Skip to content

Commit b9d117e

Browse files
authored
Merge branch 'PaddlePaddle:develop' into adapter_aoa
2 parents d073767 + 7731d1c commit b9d117e

25 files changed

+1296
-583
lines changed

.github/workflows/Api-Benchmark-baseline.yml

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ on:
1818
- others
1919
schedule:
2020
- cron: '0 21 * * *'
21-
- cron: '0 22 * * 3'
2221

2322
permissions: read-all
2423

@@ -52,7 +51,7 @@ jobs:
5251
is_pr: 'false'
5352

5453
api-benchmark-baseline-schedule:
55-
name: Api benchmark baseline
54+
name: Api benchmark baseline with schedule
5655
strategy:
5756
matrix:
5857
run-labels: [api-bm-20, api-bm-27]
@@ -63,49 +62,26 @@ jobs:
6362
baseline: 'true'
6463
run-labels: ${{ matrix.run-labels }}
6564

66-
api-benchmark-baseline-pr:
67-
name: Api benchmark baseline
65+
api-benchmark-baseline-pr-20:
66+
name: Api benchmark baseline with PR on 20
6867
if: github.event_name == 'workflow_dispatch' && github.event.inputs.job-name == 'api-benchmark'
69-
strategy:
70-
matrix:
71-
run-labels: [api-bm-20, api-bm-27]
7268
uses: ./.github/workflows/_Api-Benchmark.yml
7369
needs: [clone, build-docker]
7470
with:
7571
docker_build_image: ${{ needs.build-docker.outputs.docker_build_image }}
7672
baseline: 'true'
7773
MANUALLY_PR_ID: ${{ inputs.PR_ID }}
7874
MANUALLY_COMMIT_ID: ${{ inputs.COMMIT_ID }}
79-
run-labels: ${{ matrix.run-labels }}
75+
run-labels: api-bm-20
8076

81-
test1:
82-
runs-on: ubuntu-latest
83-
if: github.event.schedule == '0 0 * * *'
84-
steps:
85-
- name: Test
86-
run: |
87-
echo "test1"
88-
89-
test2:
90-
runs-on: ubuntu-latest
91-
if: github.event.schedule == '0 21 * * *'
92-
steps:
93-
- name: Test
94-
run: |
95-
echo "test2"
96-
97-
test3:
98-
runs-on: ubuntu-latest
99-
if: github.event.schedule == '0 22 * * 3'
100-
steps:
101-
- name: Test
102-
run: |
103-
echo "test3"
104-
105-
test4:
106-
runs-on: ubuntu-latest
107-
if: github.event.schedule == '0 21 * * 1'
108-
steps:
109-
- name: Test
110-
run: |
111-
echo "test4"
77+
api-benchmark-baseline-pr-27:
78+
name: Api benchmark baseline with PR on 27
79+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.job-name == 'api-benchmark'
80+
uses: ./.github/workflows/_Api-Benchmark.yml
81+
needs: [clone, build-docker]
82+
with:
83+
docker_build_image: ${{ needs.build-docker.outputs.docker_build_image }}
84+
baseline: 'true'
85+
MANUALLY_PR_ID: ${{ inputs.PR_ID }}
86+
MANUALLY_COMMIT_ID: ${{ inputs.COMMIT_ID }}
87+
run-labels: api-bm-27

.github/workflows/_Api-Benchmark.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
PADDLE_ROOT: /paddle
3232
TASK: paddle-CI-${{ github.event.pull_request.number }}-api-benchmark
3333
ci_scripts: /paddle/ci
34-
BRANCH: ${{ github.event.pull_request.base.ref }}
34+
BRANCH: ${{ github.event.pull_request.base.ref || github.ref_name }}
3535
CI_name: api-benchmark
3636
no_proxy: "bcebos.com,apiin.im.baidu.com,gitee.com,aliyun.com,.baidu.com,.tuna.tsinghua.edu.cn"
3737

@@ -76,7 +76,7 @@ jobs:
7676
- name: Check docker image and run container
7777
env:
7878
python: "python3.10"
79-
GIT_PR_ID: ${{ github.event.pull_request.number }}
79+
GIT_PR_ID: ${{ github.event.pull_request.number || '0' }}
8080
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8181
RUN_ID: ${{ github.run_id }}
8282
wheel_link: https://paddle-github-action.bj.bcebos.com/PR/build/${{ github.event.pull_request.number }}/${{ github.event.pull_request.head.sha }}/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
@@ -134,13 +134,14 @@ jobs:
134134
cp /paddle/PTSTools/Uploader/apibm_config.yml .
135135
source ${{ github.workspace }}/../../../proxy
136136
if [[ "${{ inputs.baseline }}" == "true" ]];then
137+
set -e
137138
if [[ "${{ inputs.MANUALLY_PR_ID }}" == "" ]]; then
138-
export pr_wheel_link=https://paddle-github-action.bj.bcebos.com/PR/build/${{ github.event.pull_request.number }}/${{ github.event.pull_request.head.sha }}/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
139+
export pr_wheel_link=https://paddle-github-action.bj.bcebos.com/PR/build/$PR_ID/$COMMIT_ID/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
139140
else
140141
export pr_wheel_link=https://paddle-github-action.bj.bcebos.com/PR/build/${{ inputs.MANUALLY_PR_ID }}/${{ inputs.MANUALLY_COMMIT_ID }}/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl
141142
fi
142143
${python} -m pip install $pr_wheel_link
143-
${python} runner_ci_action.py --yaml ../yaml/api_benchmark_fp32.yml --baseline_whl_link $pr_wheel_link
144+
${python} runner_ci_multipro_action.py --yaml ../yaml/sort_api_benchmark_fp32.yml --core_index ${core_index} --baseline_whl_link $pr_wheel_link
144145
exit 0
145146
fi
146147
${python} -m pip install $wheel_link

ci/coverage_test.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ function is_run_distribute_in_op_test() {
2424
echo "export FLAGS_COVERAGE_RUN_AUTO_PARALLEL_IN_OP_TEST=1" >> "$HOME/.bashrc"
2525
fi
2626
done
27-
ALL_CHANGE_FILES=`git diff --numstat upstream/$BRANCH | awk '{print $3}' | grep ".py"|| true`
27+
ALL_CHANGE_FILES=$(git diff --name-only upstream/$BRANCH | grep ".py"|| true)
2828
echo ${ALL_CHANGE_FILES}
2929
for CHANGE_FILE in ${ALL_CHANGE_FILES}; do
30-
ALL_OPTEST_BAN_AUTO_PARALLEL_TEST=`git diff -U0 upstream/$BRANCH ${PADDLE_ROOT}/${CHANGE_FILE} | grep "+" | grep "check_auto_parallel=" || true`
30+
TARGET_FILE="${PADDLE_ROOT}/${CHANGE_FILE}"
31+
if [ ! -f "$TARGET_FILE" ]; then
32+
continue
33+
fi
34+
ALL_OPTEST_BAN_AUTO_PARALLEL_TEST=`git diff -U0 upstream/$BRANCH "TARGET_FILE" | grep "+" | grep "check_auto_parallel=" || true`
3135
if [ "${ALL_OPTEST_BAN_AUTO_PARALLEL_TEST}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then
3236
export FLAGS_COVERAGE_RUN_AUTO_PARALLEL_IN_OP_TEST=1
3337
echo "export FLAGS_COVERAGE_RUN_AUTO_PARALLEL_IN_OP_TEST=1" >> "$HOME/.bashrc"

paddle/fluid/eager/to_static/run_program_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ std::vector<paddle::Tensor> RunProgramImpl(
573573
#endif
574574

575575
auto passed_kernel_program = paddle::framework::ApplyIrPass(
576-
forward_program.get(), place, no_need_buffer_name_set);
576+
program.get(), place, no_need_buffer_name_set);
577577
const auto &new_block = passed_kernel_program->block();
578578
passed_kernel_program = paddle::framework::ApplyRemoveShadowFeedPass(
579579
std::move(passed_kernel_program), new_block, place, global_inner_scope);

paddle/fluid/pybind/eager_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ class TensorListBufferAllocator {
479479
bool is_available;
480480
std::vector<paddle::Tensor> buffer;
481481
TensorListBuffer() = default;
482-
explicit TensorListBuffer(ssize_t len) : buffer(len), is_available(true) {}
482+
explicit TensorListBuffer(ssize_t len) : is_available(true), buffer(len) {}
483483
};
484484

485485
using MapType =

paddle/fluid/pybind/slice_utils.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,43 @@ static paddle::Tensor getValueForBoolTensor(const paddle::Tensor& tensor,
820820
indices_int64.push_back(indice);
821821
}
822822

823+
// AMP Logic
824+
if (egr::Controller::Instance().GetAMPLevel() !=
825+
paddle::imperative::AmpLevel::O0) {
826+
auto op_name = phi::TransToFluidOpName("index_elementwise_get");
827+
paddle::small_vector<std::vector<paddle::Tensor>,
828+
egr::kSlotSmallVectorSize>
829+
amp_tensors_vector = {{self_tensor}};
830+
831+
auto amp_dst_dtype =
832+
paddle::imperative::GetAmpDestDtype(op_name, amp_tensors_vector);
833+
834+
auto new_self_tensor = paddle::imperative::AmpAutoCast(
835+
"self_tensor", self_tensor, amp_dst_dtype, op_name);
836+
auto new_tensor = paddle::imperative::AmpAutoCast(
837+
"tensor", tensor, amp_dst_dtype, op_name);
838+
839+
{
840+
paddle::imperative::AutoCastGuard guard(
841+
egr::Controller::Instance().GetCurrentAmpAttrs(),
842+
paddle::imperative::AmpLevel::O0);
843+
844+
AdvancedIndex ad = AdvancedIndex(new_tensor, indices_int64);
845+
const bool is_combined = false;
846+
const bool accumulate = false;
847+
848+
return index_elementwise_get_ad_func(new_self_tensor,
849+
ad.indices,
850+
ad.src_sizes,
851+
ad.src_strides,
852+
ad.indexed_sizes,
853+
ad.indexed_strides,
854+
slice_offset,
855+
accumulate,
856+
is_combined);
857+
}
858+
}
859+
823860
AdvancedIndex ad = AdvancedIndex(tensor, indices_int64);
824861
const bool is_combined = false;
825862
const bool accumulate = false;
@@ -1287,6 +1324,45 @@ static void ApplyGetitem(const int index_size,
12871324
transed_tensor,
12881325
&transed_index_int64);
12891326

1327+
// AMP Logic
1328+
if (egr::Controller::Instance().GetAMPLevel() !=
1329+
paddle::imperative::AmpLevel::O0) {
1330+
auto op_name = phi::TransToFluidOpName("index_elementwise_get");
1331+
paddle::small_vector<std::vector<paddle::Tensor>,
1332+
egr::kSlotSmallVectorSize>
1333+
amp_tensors_vector = {{*self_tensor}};
1334+
1335+
auto amp_dst_dtype =
1336+
paddle::imperative::GetAmpDestDtype(op_name, amp_tensors_vector);
1337+
1338+
auto new_self_tensor = paddle::imperative::AmpAutoCast(
1339+
"self_tensor", *self_tensor, amp_dst_dtype, op_name);
1340+
auto new_transed_tensor = paddle::imperative::AmpAutoCast(
1341+
"transed_tensor", *transed_tensor, amp_dst_dtype, op_name);
1342+
1343+
{
1344+
paddle::imperative::AutoCastGuard guard(
1345+
egr::Controller::Instance().GetCurrentAmpAttrs(),
1346+
paddle::imperative::AmpLevel::O0);
1347+
1348+
AdvancedIndex ad =
1349+
AdvancedIndex(new_transed_tensor, transed_index_int64);
1350+
1351+
const bool is_combined = (index_size == 1) ? false : true;
1352+
const bool accumulate = true;
1353+
*out = index_elementwise_get_ad_func(new_self_tensor,
1354+
ad.indices,
1355+
ad.src_sizes,
1356+
ad.src_strides,
1357+
ad.indexed_sizes,
1358+
ad.indexed_strides,
1359+
slice_offset,
1360+
accumulate,
1361+
is_combined);
1362+
}
1363+
return;
1364+
}
1365+
12901366
AdvancedIndex ad = AdvancedIndex(*transed_tensor, transed_index_int64);
12911367
// is_combined:
12921368
// Distinguishes between regular indexing (single index) and combined

paddle/phi/ops/yaml/ops.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,6 +2948,10 @@
29482948

29492949
- op : isfinite
29502950
args : (Tensor x)
2951+
python_api:
2952+
name : [paddle.isfinite, paddle.Tensor.isfinite]
2953+
args_alias:
2954+
use_default_mapping : True
29512955
output : Tensor(out)
29522956
infer_meta :
29532957
func : IsfiniteInferMeta
@@ -2959,6 +2963,10 @@
29592963

29602964
- op : isinf
29612965
args : (Tensor x)
2966+
python_api:
2967+
name : [paddle.isinf, paddle.Tensor.isinf]
2968+
args_alias:
2969+
use_default_mapping : True
29622970
output : Tensor(out)
29632971
infer_meta :
29642972
func : IsfiniteInferMeta
@@ -2970,6 +2978,10 @@
29702978

29712979
- op : isnan
29722980
args : (Tensor x)
2981+
python_api:
2982+
name : [paddle.isnan, paddle.Tensor.isnan]
2983+
args_alias:
2984+
use_default_mapping : True
29732985
output : Tensor(out)
29742986
infer_meta :
29752987
func : IsfiniteInferMeta

paddle/scripts/paddle_build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3288,10 +3288,14 @@ function is_run_distribute_in_op_test() {
32883288
export FLAGS_COVERAGE_RUN_AUTO_PARALLEL_IN_OP_TEST=1
32893289
fi
32903290
done
3291-
ALL_CHANGE_FILES=`git diff --numstat upstream/$BRANCH | awk '{print $3}' | grep ".py"|| true`
3291+
ALL_CHANGE_FILES=$(git diff --name-only upstream/$BRANCH | grep ".py"|| true)
32923292
echo ${ALL_CHANGE_FILES}
32933293
for CHANGE_FILE in ${ALL_CHANGE_FILES}; do
3294-
ALL_OPTEST_BAN_AUTO_PARALLEL_TEST=`git diff -U0 upstream/$BRANCH ${PADDLE_ROOT}/${CHANGE_FILE} | grep "+" | grep "check_auto_parallel=" || true`
3294+
TARGET_FILE="${PADDLE_ROOT}/${CHANGE_FILE}"
3295+
if [ ! -f "$TARGET_FILE" ]; then
3296+
continue
3297+
fi
3298+
ALL_OPTEST_BAN_AUTO_PARALLEL_TEST=`git diff -U0 upstream/$BRANCH "$TARGET_FILE" | grep "+" | grep "check_auto_parallel=" || true`
32953299
if [ "${ALL_OPTEST_BAN_AUTO_PARALLEL_TEST}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then
32963300
export FLAGS_COVERAGE_RUN_AUTO_PARALLEL_IN_OP_TEST=1
32973301
fi

python/paddle/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@
368368
row_stack,
369369
scatter,
370370
scatter_,
371+
scatter_add,
371372
scatter_nd,
372373
scatter_nd_add,
373374
scatter_reduce,
@@ -625,6 +626,9 @@
625626
where,
626627
where_,
627628
)
629+
from .tensor.softmax import (
630+
softmax,
631+
)
628632
from .tensor.stat import (
629633
mean,
630634
median,
@@ -1262,6 +1266,7 @@ def __dir__(self):
12621266
'take_along_axis',
12631267
'scatter_reduce',
12641268
'put_along_axis',
1269+
'scatter_add',
12651270
'select_scatter',
12661271
'multigammaln',
12671272
'multigammaln_',
@@ -1327,6 +1332,7 @@ def __dir__(self):
13271332
'get_autocast_dtype',
13281333
'get_autocast_cpu_dtype',
13291334
'get_autocast_gpu_dtype',
1335+
'softmax',
13301336
]
13311337
import os
13321338

0 commit comments

Comments
 (0)