Skip to content

Commit 081596f

Browse files
Add Windows CI (#1028)
Add windows CI
1 parent d4432d0 commit 081596f

File tree

3 files changed

+271
-0
lines changed

3 files changed

+271
-0
lines changed

.github/scripts/install_xpu.bat

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
@echo on
2+
REM Description: Install Intel Support Packages on Windows
3+
REM BKM reference: https://www.intel.com/content/www/us/en/developer/articles/tool/pytorch-prerequisites-for-intel-gpus.html
4+
5+
set XPU_INSTALL_MODE=%~1
6+
if "%XPU_INSTALL_MODE%"=="" goto xpu_bundle_install_start
7+
if "%XPU_INSTALL_MODE%"=="bundle" goto xpu_bundle_install_start
8+
if "%XPU_INSTALL_MODE%"=="driver" goto xpu_driver_install_start
9+
if "%XPU_INSTALL_MODE%"=="all" goto xpu_driver_install_start
10+
11+
:arg_error
12+
13+
echo Illegal XPU installation mode. The value can be "bundle"/"driver"/"all"
14+
echo If keep the value as space, will use default "bundle" mode
15+
exit /b 1
16+
17+
:xpu_driver_install_start
18+
:: TODO Need more testing for driver installation
19+
set XPU_DRIVER_LINK=https://downloadmirror.intel.com/830975/gfx_win_101.5972.exe
20+
curl -o xpu_driver.exe --retry 3 --retry-all-errors -k %XPU_DRIVER_LINK%
21+
echo "XPU Driver installing..."
22+
start /wait "Intel XPU Driver Installer" "xpu_driver.exe"
23+
if errorlevel 1 exit /b 1
24+
del xpu_driver.exe
25+
if "%XPU_INSTALL_MODE%"=="driver" goto xpu_install_end
26+
27+
:xpu_bundle_install_start
28+
29+
set XPU_BUNDLE_PARENT_DIR=C:\Program Files (x86)\Intel\oneAPI
30+
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
31+
set XPU_BUNDLE_PRODUCT_NAME=intel.oneapi.win.intel-for-pytorch-gpu-dev.product
32+
set XPU_BUNDLE_VERSION=0.5.3+31
33+
set XPU_BUNDLE_INSTALLED=0
34+
set XPU_BUNDLE_UNINSTALL=0
35+
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
36+
set XPU_EXTRA_PRODUCT_NAME=intel.oneapi.win.intel-pti-dev.product
37+
set XPU_EXTRA_VERSION=0.9.0+36
38+
set XPU_EXTRA_INSTALLED=0
39+
set XPU_EXTRA_UNINSTALL=0
40+
41+
if not [%XPU_VERSION%]==[] if [%XPU_VERSION%]==[2025.0] (
42+
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
43+
set XPU_BUNDLE_PRODUCT_NAME=intel.oneapi.win.deep-learning-essentials.product
44+
set XPU_BUNDLE_VERSION=2025.0.0+335
45+
set XPU_BUNDLE_INSTALLED=0
46+
set XPU_BUNDLE_UNINSTALL=0
47+
set XPU_EXTRA_URL=NULL
48+
set XPU_EXTRA_PRODUCT_NAME=intel.oneapi.win.compiler.product
49+
set XPU_EXTRA_VERSION=2025.0.1+1226
50+
set XPU_EXTRA_INSTALLED=0
51+
set XPU_EXTRA_UNINSTALL=0
52+
)
53+
54+
:: Check if XPU bundle is target version or already installed
55+
if exist "%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" goto xpu_bundle_ver_check
56+
goto xpu_bundle_install
57+
58+
:xpu_bundle_ver_check
59+
60+
"%XPU_BUNDLE_PARENT_DIR%\Installer\installer.exe" --list-products > xpu_bundle_installed_ver.log
61+
62+
for /f "tokens=1,2" %%a in (xpu_bundle_installed_ver.log) do (
63+
if "%%a"=="%XPU_BUNDLE_PRODUCT_NAME%" (
64+
echo %%a Installed Version: %%b
65+
set XPU_BUNDLE_INSTALLED=1
66+
if not "%XPU_BUNDLE_VERSION%"=="%%b" (
67+
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
68+
set XPU_BUNDLE_UNINSTALL=1
69+
)
70+
)
71+
if "%%a"=="%XPU_EXTRA_PRODUCT_NAME%" (
72+
echo %%a Installed Version: %%b
73+
set XPU_EXTRA_INSTALLED=1
74+
if not "%XPU_EXTRA_VERSION%"=="%%b" (
75+
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
76+
set XPU_EXTRA_UNINSTALL=1
77+
)
78+
)
79+
if not "%%b" == "Version" if not [%%b]==[] if not "%%a"=="%XPU_BUNDLE_PRODUCT_NAME%" if not "%%a"=="%XPU_EXTRA_PRODUCT_NAME%" (
80+
echo "Uninstalling...."
81+
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
82+
)
83+
)
84+
if errorlevel 1 exit /b 1
85+
if exist xpu_bundle_installed_ver.log del xpu_bundle_installed_ver.log
86+
if exist uninstall_bundle rmdir /s /q uninstall_bundle
87+
if "%XPU_BUNDLE_INSTALLED%"=="0" goto xpu_bundle_install
88+
if "%XPU_BUNDLE_UNINSTALL%"=="1" goto xpu_bundle_install
89+
90+
:xpu_extra_check
91+
92+
if "%XPU_EXTRA_URL%"=="NULL" goto xpu_install_end
93+
if "%XPU_EXTRA_INSTALLED%"=="0" goto xpu_extra_install
94+
if "%XPU_EXTRA_UNINSTALL%"=="1" goto xpu_extra_install
95+
goto xpu_install_end
96+
97+
:xpu_bundle_install
98+
99+
curl -o xpu_bundle.exe --retry 3 --retry-all-errors -k %XPU_BUNDLE_URL%
100+
echo "XPU Bundle installing..."
101+
start /wait "Intel Pytorch Bundle Installer" "xpu_bundle.exe" --action=install --eula=accept --silent --log-dir install_bundle
102+
if errorlevel 1 exit /b 1
103+
del xpu_bundle.exe
104+
goto xpu_extra_check
105+
106+
:xpu_extra_install
107+
108+
curl -o xpu_extra.exe --retry 3 --retry-all-errors -k %XPU_EXTRA_URL%
109+
echo "Intel XPU EXTRA installing..."
110+
start /wait "Intel XPU EXTRA Installer" "xpu_extra.exe" --action=install --eula=accept --silent --log-dir install_bundle
111+
if errorlevel 1 exit /b 1
112+
del xpu_extra.exe
113+
114+
:xpu_install_end

.github/workflows/_windows_ut.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Windows Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
pytorch:
7+
required: false
8+
type: string
9+
default: 'main'
10+
description: Pytorch branch/commit
11+
keep_torch_xpu_ops:
12+
required: false
13+
type: string
14+
default: 'false'
15+
description: Keep torch-xpu-ops pin. `true` means use pined commit
16+
ut:
17+
required: true
18+
type: string
19+
default: ''
20+
description: UT scope. `op_regression,op_regression_dev1,op_extended,op_ut,torch_xpu` Delimiter is comma
21+
python:
22+
required: false
23+
type: string
24+
default: '3.10'
25+
description: Python version
26+
runner:
27+
required: true
28+
type: string
29+
default: 'Windows_CI'
30+
description: Runner label
31+
xpu_version:
32+
required: false
33+
type: string
34+
default: '2025.0'
35+
description: Python version
36+
37+
permissions: read-all
38+
39+
env:
40+
USE_XPU: 1
41+
42+
jobs:
43+
Torch-XPU-Windows-UT:
44+
runs-on: ${{ inputs.runner }}
45+
timeout-minutes: 900
46+
steps:
47+
- name: Checkout torch-xpu-ops
48+
uses: actions/checkout@v4
49+
- name: Install oneAPI
50+
shell: cmd
51+
run: |
52+
set XPU_VERSION=${{ inputs.xpu_version }}
53+
call .github\scripts\install_xpu.bat
54+
if errorlevel 1 exit /b 1
55+
- name: Prepare Stock Pytorch
56+
shell: cmd
57+
run: |
58+
echo "C:\ProgramData\miniforge3\Scripts" >> "$GITHUB_PATH"
59+
echo "C:\ProgramData\miniforge3\Library\bin" >> "$GITHUB_PATH"
60+
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
61+
call conda clean -ay
62+
call conda remove --all -y -n windows_ci
63+
call conda create -n windows_ci python=${{ inputs.python }} cmake ninja -y
64+
call conda activate windows_ci
65+
cd ..
66+
if exist "pytorch" (
67+
rmdir /s /q pytorch
68+
)
69+
git clone https://github.com/pytorch/pytorch pytorch
70+
cd pytorch && git checkout ${{ inputs.pytorch }}
71+
pip install pyyaml requests
72+
call conda install -y libuv
73+
call conda install -y rust
74+
git config --system core.longpaths true
75+
git status
76+
git show -s
77+
git submodule sync && git submodule update --init --recursive
78+
if ${{ inputs.keep_torch_xpu_ops }} == 'true' (
79+
echo "Don't replace torch-xpu-ops!"
80+
) else (
81+
echo "Replace torch-xpu-ops!"
82+
cd third_party
83+
if exist "torch-xpu-ops" (
84+
rmdir /s /q torch-xpu-ops
85+
)
86+
cd ..
87+
Xcopy ..\torch-xpu-ops third_party\torch-xpu-ops /E/H/Y/F/I
88+
powershell -Command "(Get-Content caffe2/CMakeLists.txt) -replace 'checkout --quiet \${TORCH_XPU_OPS_COMMIT}', 'log -n 1' | Set-Content caffe2/CMakeLists.txt"
89+
)
90+
- name: Build Pytorch XPU
91+
shell: cmd
92+
run: |
93+
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
94+
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
95+
call "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
96+
call "C:\Program Files (x86)\Intel\oneAPI\ocloc\latest\env\vars.bat"
97+
call conda activate windows_ci
98+
cd ../pytorch
99+
pip install -r requirements.txt
100+
pip install cmake setuptools==72.1.0 clang-format
101+
set USE_KINETO=0
102+
set CMAKE_SHARED_LINKER_FLAGS=/FORCE:MULTIPLE
103+
set CMAKE_MODULE_LINKER_FLAGS=/FORCE:MULTIPLE
104+
set CMAKE_EXE_LINKER_FLAGS=/FORCE:MULTIPLE
105+
python setup.py clean
106+
set MAX_JOBS=4
107+
python setup.py bdist_wheel > build_torch_wheel_log.log
108+
echo "[INFO] begin to install torch whls"
109+
for /r C:\runner\actions-runner\_work\torch-xpu-ops\pytorch\dist %%i in (torch*.whl) do (
110+
set TORCH_WHL=%%i
111+
)
112+
echo "[INFO] the torch version is %TORCH_WHL%"
113+
python -m pip install %TORCH_WHL%
114+
pip install -r .ci\docker\requirements-ci.txt
115+
- name: Torch Config
116+
shell: cmd
117+
run: |
118+
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
119+
call conda activate windows_ci
120+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
121+
python -c "import torch; print(torch.__config__.show())"
122+
python -c "import torch; print(torch.__config__.parallel_info())"
123+
python -c "import torch; print(torch.__config__.torch.xpu.device_count())"
124+
125+
- name: Upload Windows build log
126+
if: ${{ ! cancelled() }}
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: Torch-XPU-Windows-Log-${{ github.event.pull_request.number || github.sha }}
130+
path: 'C:\runner\actions-runner\_work\torch-xpu-ops\pytorch\build_torch_wheel_log.log'
131+
132+
- name: Upload Windows binary
133+
if: ${{ ! cancelled() }}
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: Torch-XPU-Windows-Binary-${{ github.event.pull_request.number || github.sha }}
137+
path: 'C:\runner\actions-runner\_work\torch-xpu-ops\pytorch\dist'
138+
139+
- name: Run XPU OP Extended UT
140+
if: contains(inputs.ut, 'op_extended') || github.event_name == 'schedule'
141+
shell: cmd
142+
run: |
143+
call "C:\ProgramData\miniforge3\Scripts\activate.bat"
144+
call conda activate windows_ci
145+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
146+
set PYTORCH_TEST_WITH_SLOW=1
147+
cd ../pytorch/third_party/torch-xpu-ops/test/xpu/extended/
148+
python run_test_with_skip_mtl.py

.github/workflows/pull.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- reopened
99
- converted_to_draft
1010
- ready_for_review
11+
- labeled
1112
branches:
1213
- main
1314
- release/*
@@ -35,6 +36,14 @@ jobs:
3536
abi: 0
3637
ut: op_extended
3738
runner: linux.idc.xpu
39+
40+
preci-windows:
41+
# Don't run on forked repos and draft PRs
42+
if: ${{ (github.repository_owner == 'intel') && (github.event.pull_request.draft == false) }} && contains(github.event.pull_request.labels.*.name, 'windows_ci')
43+
uses: ./.github/workflows/_windows_ut.yml
44+
with:
45+
ut: op_extended
46+
runner: Windows_CI
3847

3948
Inductor-XPU-E2E-CI-Tests:
4049
runs-on: pvc_e2e

0 commit comments

Comments
 (0)