Skip to content

Commit

Permalink
Add Windows CI (#1028)
Browse files Browse the repository at this point in the history
Add windows CI
  • Loading branch information
RUIJIEZHONG66166 authored Jan 6, 2025
1 parent d4432d0 commit 081596f
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 0 deletions.
114 changes: 114 additions & 0 deletions .github/scripts/install_xpu.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
@echo on
REM Description: Install Intel Support Packages on Windows
REM BKM reference: https://www.intel.com/content/www/us/en/developer/articles/tool/pytorch-prerequisites-for-intel-gpus.html

set XPU_INSTALL_MODE=%~1
if "%XPU_INSTALL_MODE%"=="" goto xpu_bundle_install_start
if "%XPU_INSTALL_MODE%"=="bundle" goto xpu_bundle_install_start
if "%XPU_INSTALL_MODE%"=="driver" goto xpu_driver_install_start
if "%XPU_INSTALL_MODE%"=="all" goto xpu_driver_install_start

:arg_error

echo Illegal XPU installation mode. The value can be "bundle"/"driver"/"all"
echo If keep the value as space, will use default "bundle" mode
exit /b 1

:xpu_driver_install_start
:: TODO Need more testing for driver installation
set XPU_DRIVER_LINK=https://downloadmirror.intel.com/830975/gfx_win_101.5972.exe
curl -o xpu_driver.exe --retry 3 --retry-all-errors -k %XPU_DRIVER_LINK%
echo "XPU Driver installing..."
start /wait "Intel XPU Driver Installer" "xpu_driver.exe"
if errorlevel 1 exit /b 1
del xpu_driver.exe
if "%XPU_INSTALL_MODE%"=="driver" goto xpu_install_end

:xpu_bundle_install_start

set XPU_BUNDLE_PARENT_DIR=C:\Program Files (x86)\Intel\oneAPI
set XPU_BUNDLE_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/9d1a91e2-e8b8-40a5-8c7f-5db768a6a60c/w_intel-for-pytorch-gpu-dev_p_0.5.3.37_offline.exe
set XPU_BUNDLE_PRODUCT_NAME=intel.oneapi.win.intel-for-pytorch-gpu-dev.product
set XPU_BUNDLE_VERSION=0.5.3+31
set XPU_BUNDLE_INSTALLED=0
set XPU_BUNDLE_UNINSTALL=0
set XPU_EXTRA_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/9d1a91e2-e8b8-40a5-8c7f-5db768a6a60c/w_intel-pti-dev_p_0.9.0.37_offline.exe
set XPU_EXTRA_PRODUCT_NAME=intel.oneapi.win.intel-pti-dev.product
set XPU_EXTRA_VERSION=0.9.0+36
set XPU_EXTRA_INSTALLED=0
set XPU_EXTRA_UNINSTALL=0

if not [%XPU_VERSION%]==[] if [%XPU_VERSION%]==[2025.0] (
set XPU_BUNDLE_URL=https://registrationcenter-download.intel.com/akdlm/IRC_NAS/efc86abd-cb77-452e-a03f-a741895b8ece/intel-deep-learning-essentials-2025.0.0.336_offline.exe
set XPU_BUNDLE_PRODUCT_NAME=intel.oneapi.win.deep-learning-essentials.product
set XPU_BUNDLE_VERSION=2025.0.0+335
set XPU_BUNDLE_INSTALLED=0
set XPU_BUNDLE_UNINSTALL=0
set XPU_EXTRA_URL=NULL
set XPU_EXTRA_PRODUCT_NAME=intel.oneapi.win.compiler.product
set XPU_EXTRA_VERSION=2025.0.1+1226
set XPU_EXTRA_INSTALLED=0
set XPU_EXTRA_UNINSTALL=0
)

:: Check if XPU bundle is target version or already installed
if exist "%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" goto xpu_bundle_ver_check
goto xpu_bundle_install

:xpu_bundle_ver_check

"%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" --list-products > xpu_bundle_installed_ver.log

for /f "tokens=1,2" %%a in (xpu_bundle_installed_ver.log) do (
if "%%a"=="%XPU_BUNDLE_PRODUCT_NAME%" (
echo %%a Installed Version: %%b
set XPU_BUNDLE_INSTALLED=1
if not "%XPU_BUNDLE_VERSION%"=="%%b" (
start /wait "Installer Title" "%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" --action=remove --eula=accept --silent --product-id %%a --product-ver %%b --log-dir uninstall_bundle
set XPU_BUNDLE_UNINSTALL=1
)
)
if "%%a"=="%XPU_EXTRA_PRODUCT_NAME%" (
echo %%a Installed Version: %%b
set XPU_EXTRA_INSTALLED=1
if not "%XPU_EXTRA_VERSION%"=="%%b" (
start /wait "Installer Title" "%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" --action=remove --eula=accept --silent --product-id %%a --product-ver %%b --log-dir uninstall_bundle
set XPU_EXTRA_UNINSTALL=1
)
)
if not "%%b" == "Version" if not [%%b]==[] if not "%%a"=="%XPU_BUNDLE_PRODUCT_NAME%" if not "%%a"=="%XPU_EXTRA_PRODUCT_NAME%" (
echo "Uninstalling...."
start /wait "Installer Title" "%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" --action=remove --eula=accept --silent --product-id %%a --product-ver %%b --log-dir uninstall_bundle
)
)
if errorlevel 1 exit /b 1
if exist xpu_bundle_installed_ver.log del xpu_bundle_installed_ver.log
if exist uninstall_bundle rmdir /s /q uninstall_bundle
if "%XPU_BUNDLE_INSTALLED%"=="0" goto xpu_bundle_install
if "%XPU_BUNDLE_UNINSTALL%"=="1" goto xpu_bundle_install

:xpu_extra_check

if "%XPU_EXTRA_URL%"=="NULL" goto xpu_install_end
if "%XPU_EXTRA_INSTALLED%"=="0" goto xpu_extra_install
if "%XPU_EXTRA_UNINSTALL%"=="1" goto xpu_extra_install
goto xpu_install_end

:xpu_bundle_install

curl -o xpu_bundle.exe --retry 3 --retry-all-errors -k %XPU_BUNDLE_URL%
echo "XPU Bundle installing..."
start /wait "Intel Pytorch Bundle Installer" "xpu_bundle.exe" --action=install --eula=accept --silent --log-dir install_bundle
if errorlevel 1 exit /b 1
del xpu_bundle.exe
goto xpu_extra_check

:xpu_extra_install

curl -o xpu_extra.exe --retry 3 --retry-all-errors -k %XPU_EXTRA_URL%
echo "Intel XPU EXTRA installing..."
start /wait "Intel XPU EXTRA Installer" "xpu_extra.exe" --action=install --eula=accept --silent --log-dir install_bundle
if errorlevel 1 exit /b 1
del xpu_extra.exe

:xpu_install_end
148 changes: 148 additions & 0 deletions .github/workflows/_windows_ut.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Windows Test

on:
workflow_call:
inputs:
pytorch:
required: false
type: string
default: 'main'
description: Pytorch branch/commit
keep_torch_xpu_ops:
required: false
type: string
default: 'false'
description: Keep torch-xpu-ops pin. `true` means use pined commit
ut:
required: true
type: string
default: ''
description: UT scope. `op_regression,op_regression_dev1,op_extended,op_ut,torch_xpu` Delimiter is comma
python:
required: false
type: string
default: '3.10'
description: Python version
runner:
required: true
type: string
default: 'Windows_CI'
description: Runner label
xpu_version:
required: false
type: string
default: '2025.0'
description: Python version

permissions: read-all

env:
USE_XPU: 1

jobs:
Torch-XPU-Windows-UT:
runs-on: ${{ inputs.runner }}
timeout-minutes: 900
steps:
- name: Checkout torch-xpu-ops
uses: actions/checkout@v4
- name: Install oneAPI
shell: cmd
run: |
set XPU_VERSION=${{ inputs.xpu_version }}
call .github\scripts\install_xpu.bat
if errorlevel 1 exit /b 1
- name: Prepare Stock Pytorch
shell: cmd
run: |
echo "C:\ProgramData\miniforge3\Scripts" >> "$GITHUB_PATH"
echo "C:\ProgramData\miniforge3\Library\bin" >> "$GITHUB_PATH"
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
call conda clean -ay
call conda remove --all -y -n windows_ci
call conda create -n windows_ci python=${{ inputs.python }} cmake ninja -y
call conda activate windows_ci
cd ..
if exist "pytorch" (
rmdir /s /q pytorch
)
git clone https://github.com/pytorch/pytorch pytorch
cd pytorch && git checkout ${{ inputs.pytorch }}
pip install pyyaml requests
call conda install -y libuv
call conda install -y rust
git config --system core.longpaths true
git status
git show -s
git submodule sync && git submodule update --init --recursive
if ${{ inputs.keep_torch_xpu_ops }} == 'true' (
echo "Don't replace torch-xpu-ops!"
) else (
echo "Replace torch-xpu-ops!"
cd third_party
if exist "torch-xpu-ops" (
rmdir /s /q torch-xpu-ops
)
cd ..
Xcopy ..\torch-xpu-ops third_party\torch-xpu-ops /E/H/Y/F/I
powershell -Command "(Get-Content caffe2/CMakeLists.txt) -replace 'checkout --quiet \${TORCH_XPU_OPS_COMMIT}', 'log -n 1' | Set-Content caffe2/CMakeLists.txt"
)
- name: Build Pytorch XPU
shell: cmd
run: |
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
call "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
call "C:\Program Files (x86)\Intel\oneAPI\ocloc\latest\env\vars.bat"
call conda activate windows_ci
cd ../pytorch
pip install -r requirements.txt
pip install cmake setuptools==72.1.0 clang-format
set USE_KINETO=0
set CMAKE_SHARED_LINKER_FLAGS=/FORCE:MULTIPLE
set CMAKE_MODULE_LINKER_FLAGS=/FORCE:MULTIPLE
set CMAKE_EXE_LINKER_FLAGS=/FORCE:MULTIPLE
python setup.py clean
set MAX_JOBS=4
python setup.py bdist_wheel > build_torch_wheel_log.log
echo "[INFO] begin to install torch whls"
for /r C:\runner\actions-runner\_work\torch-xpu-ops\pytorch\dist %%i in (torch*.whl) do (
set TORCH_WHL=%%i
)
echo "[INFO] the torch version is %TORCH_WHL%"
python -m pip install %TORCH_WHL%
pip install -r .ci\docker\requirements-ci.txt
- name: Torch Config
shell: cmd
run: |
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
call conda activate windows_ci
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
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())"
- name: Upload Windows build log
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@v4
with:
name: Torch-XPU-Windows-Log-${{ github.event.pull_request.number || github.sha }}
path: 'C:\runner\actions-runner\_work\torch-xpu-ops\pytorch\build_torch_wheel_log.log'

- name: Upload Windows binary
if: ${{ ! cancelled() }}
uses: actions/upload-artifact@v4
with:
name: Torch-XPU-Windows-Binary-${{ github.event.pull_request.number || github.sha }}
path: 'C:\runner\actions-runner\_work\torch-xpu-ops\pytorch\dist'

- name: Run XPU OP Extended UT
if: contains(inputs.ut, 'op_extended') || github.event_name == 'schedule'
shell: cmd
run: |
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
call conda activate windows_ci
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
set PYTORCH_TEST_WITH_SLOW=1
cd ../pytorch/third_party/torch-xpu-ops/test/xpu/extended/
python run_test_with_skip_mtl.py
9 changes: 9 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- reopened
- converted_to_draft
- ready_for_review
- labeled
branches:
- main
- release/*
Expand Down Expand Up @@ -35,6 +36,14 @@ jobs:
abi: 0
ut: op_extended
runner: linux.idc.xpu

preci-windows:
# Don't run on forked repos and draft PRs
if: ${{ (github.repository_owner == 'intel') && (github.event.pull_request.draft == false) }} && contains(github.event.pull_request.labels.*.name, 'windows_ci')
uses: ./.github/workflows/_windows_ut.yml
with:
ut: op_extended
runner: Windows_CI

Inductor-XPU-E2E-CI-Tests:
runs-on: pvc_e2e
Expand Down

0 comments on commit 081596f

Please sign in to comment.