From 164c629182cf27f450373e834deceddd54f7ea48 Mon Sep 17 00:00:00 2001 From: mengfei25 Date: Thu, 12 Dec 2024 19:46:54 +0800 Subject: [PATCH] Optimize preci & ngihtly tests (#1162) 1. Additional PRs apply script for windows 2. Checkout the corresponding torch & torch-xpu-ops versions for wheel tests 3. Don't need source DL-Essential for nightly wheel tests --- .../actions/inductor-xpu-e2e-test/action.yml | 4 +- .github/scripts/apply_torch_pr.py | 2 +- .github/scripts/env.sh | 11 ++-- .github/workflows/_linux_ut.yml | 51 +++++++++++-------- .github/workflows/nightly_ondemand_whl.yml | 12 ++--- 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/.github/actions/inductor-xpu-e2e-test/action.yml b/.github/actions/inductor-xpu-e2e-test/action.yml index 4f81534fd..4e1fce079 100644 --- a/.github/actions/inductor-xpu-e2e-test/action.yml +++ b/.github/actions/inductor-xpu-e2e-test/action.yml @@ -51,7 +51,7 @@ runs: shell: bash run: | source activate e2e_ci - source .github/scripts/env.sh + source .github/scripts/env.sh ${{ inputs.pytorch }} if [[ ${{ inputs.suite }} == *"torchbench"* ]]; then if [ "${{ inputs.pytorch }}" != "nightly_wheel" ]; then cd ../ && rm -rf audio && git clone --single-branch -b main https://github.com/pytorch/audio.git @@ -94,7 +94,7 @@ runs: shell: bash run: | source activate e2e_ci - source .github/scripts/env.sh + source .github/scripts/env.sh ${{ inputs.pytorch }} cp .github/scripts/inductor_xpu_test.sh ../pytorch cd ../pytorch diff --git a/.github/scripts/apply_torch_pr.py b/.github/scripts/apply_torch_pr.py index d48121ff6..89fa32fdf 100644 --- a/.github/scripts/apply_torch_pr.py +++ b/.github/scripts/apply_torch_pr.py @@ -58,7 +58,7 @@ def appyly_pr(pr_info, re_apply_msg): pr_file = pr_info["diff_url"].split("/")[-1] urllib.request.urlretrieve(pr_info["diff_url"], pr_file) # apply diff - apply_cmd = "git apply --3way " + pr_file + " && rm -f " + pr_file + apply_cmd = "git apply --3way " + pr_file apply_info = subprocess.Popen(apply_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) apply_message = apply_info.communicate()[0].decode("utf-8") apply_status = apply_info.returncode diff --git a/.github/scripts/env.sh b/.github/scripts/env.sh index 56d8e3930..4fd192c06 100644 --- a/.github/scripts/env.sh +++ b/.github/scripts/env.sh @@ -1,4 +1,9 @@ #!/bin/bash -source /opt/intel/oneapi/compiler/latest/env/vars.sh -source /opt/intel/oneapi/umf/latest/env/vars.sh -source /opt/intel/oneapi/pti/latest/env/vars.sh + +if [ "$1" != "nightly_wheel" ];then + source /opt/intel/oneapi/compiler/latest/env/vars.sh + source /opt/intel/oneapi/umf/latest/env/vars.sh + source /opt/intel/oneapi/pti/latest/env/vars.sh +else + echo "Don't need to source DL-Essential for nightly wheel" +fi diff --git a/.github/workflows/_linux_ut.yml b/.github/workflows/_linux_ut.yml index d2f717230..b724d4259 100644 --- a/.github/workflows/_linux_ut.yml +++ b/.github/workflows/_linux_ut.yml @@ -65,19 +65,21 @@ jobs: conda create -n xpu_op_${ZE_AFFINITY_MASK} python=${{ inputs.python }} cmake ninja -y source activate xpu_op_${ZE_AFFINITY_MASK} cd ../ && rm -rf pytorch - git clone https://github.com/pytorch/pytorch pytorch - cd pytorch && git checkout $(echo ${{ inputs.pytorch }} |sed 's/^nightly_wheel$/nightly/') - # apply PRs for stock pytorch pip install requests - python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py - git status && git show -s - git submodule sync && git submodule update --init --recursive - if [[ ${{ inputs.keep_torch_xpu_ops }} == 'true' ]]; then - echo "Don't replace torch-xpu-ops!" - else - rm -rf third_party/torch-xpu-ops && cp -r ../torch-xpu-ops third_party/ - # Workaround for torch-xpu-ops ci test - sed -i "s/checkout --quiet \${TORCH_XPU_OPS_COMMIT}/log -n 1/g" caffe2/CMakeLists.txt + git clone https://github.com/pytorch/pytorch pytorch + if [ "${{ inputs.pytorch }}" != "nightly_wheel" ]; then + cd pytorch && git checkout $(echo ${{ inputs.pytorch }}) + # apply PRs for stock pytorch + python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py + git status && git show -s + git submodule sync && git submodule update --init --recursive + if [[ ${{ inputs.keep_torch_xpu_ops }} == 'true' ]]; then + echo "Don't replace torch-xpu-ops!" + else + rm -rf third_party/torch-xpu-ops && cp -r ../torch-xpu-ops third_party/ + # Workaround for torch-xpu-ops ci test + sed -i "s/checkout --quiet \${TORCH_XPU_OPS_COMMIT}/log -n 1/g" caffe2/CMakeLists.txt + fi fi - name: Triton Installation run: | @@ -96,15 +98,15 @@ jobs: - name: Build Pytorch XPU run: | source activate xpu_op_${ZE_AFFINITY_MASK} - source .github/scripts/env.sh + source .github/scripts/env.sh ${{ inputs.pytorch }} pip install mkl-static==2025.0.1 mkl-include==2025.0.1 - cd ../pytorch if [[ ${{ inputs.abi }} == '0' ]]; then export _GLIBCXX_USE_CXX11_ABI=0 else export _GLIBCXX_USE_CXX11_ABI=1 fi if [ "${{ inputs.pytorch }}" != "nightly_wheel" ]; then + cd ../pytorch export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:${CONDA_PREFIX:-"$(dirname $(which conda))/../"} pip install -r requirements.txt WERROR=1 python setup.py bdist_wheel @@ -112,12 +114,21 @@ jobs: git clone https://github.com/pytorch/vision && cd vision && python setup.py install && cd .. else pip install torch torchvision torchaudio --pre --index-url https://download.pytorch.org/whl/nightly/xpu + TORCH_COMMIT_ID=$(python -c 'import torch; print(torch.version.git_version)') + cd ../pytorch + git reset --hard && git checkout ${TORCH_COMMIT_ID} + TORCH_XPU_OPS_COMMIT=$(> "${GITHUB_ENV}" - echo "TORCH_COMMIT_ID=$(python -c 'import torch; print(torch.version.git_version)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" - source .github/scripts/env.sh + TORCH_COMMIT_ID=$(python -c 'import torch; print(torch.version.git_version)') + echo "TORCH_COMMIT_ID=${TORCH_COMMIT_ID}" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" cd ../ && rm -rf pytorch git clone https://github.com/pytorch/pytorch pytorch cd pytorch && git checkout ${TORCH_COMMIT_ID} # apply PRs for stock pytorch pip install requests - python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py + # python ../torch-xpu-ops/.github/scripts/apply_torch_pr.py git status && git show -s pip install -r requirements.txt - echo "TORCH_XPU_OPS_COMMIT=$(> "${GITHUB_ENV}" + TORCH_XPU_OPS_COMMIT=$(> "${GITHUB_ENV}" rm -rf third_party/torch-xpu-ops git clone https://github.com/intel/torch-xpu-ops.git third_party/torch-xpu-ops cd third_party/torch-xpu-ops @@ -127,7 +128,6 @@ jobs: id: pinned run: | source activate e2e_ci - source .github/scripts/env.sh echo "TORCHVISION_COMMIT_ID=$(python -c 'import torchvision; print(torchvision.version.git_version)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" echo "TORCHAUDIO_COMMIT_ID=$(python -c 'import torchaudio; print(torchaudio.version.git_version)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" echo "TRITON_COMMIT_ID=$(python -c 'import triton; print(triton.__version__)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" @@ -138,7 +138,7 @@ jobs: echo "MODEL_ONLY_NAME=${{ inputs.model }}" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" echo "DRIVER_VERSION=$(dkms status 2>&1 |grep 'intel-i915-dkms' |sed 's/.*\///;s/,.*//')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" echo "KERNEL_VERSION=$(uname -rv 2>&1)" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" - echo "BUNDLE_VERSION=$(dpcpp --version 2>&1 |grep 'DPC++/C++' |sed 's/.*(//;s/).*//')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" + echo "BUNDLE_VERSION=$(pip list |grep cmplr |head -n 1)" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" . /etc/os-release echo "OS_PRETTY_NAME=${PRETTY_NAME}" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}" echo "GCC_VERSION=$(gcc -dumpversion)" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}"