Skip to content

Commit daad812

Browse files
authored
Add Windows build workflow in the CI. (#4041)
1. Adds a workflow to trigger windows build in the CI similar to the existing one for Linux to address the build CI request captured in #3985 2. Only non-python based LIT unit tests are enabled in the workflow due to failures reported in #4040 3. The CI is only run against `torch-nightly` since python based tests are disabled. My understanding is that without the python based tests there's no need to run against the `stable` version too. If that's not the case, will enable `stable` as well. Tested that both `nightly` and `stable` versions work fine: https://github.com/sahas3/torch-mlir/actions/runs/13477124004
1 parent 596b58e commit daad812

File tree

6 files changed

+163
-50
lines changed

6 files changed

+163
-50
lines changed

.github/workflows/ci_windows.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# yamllint disable rule:line-length
2+
name: CI_WINDOWS
3+
4+
on:
5+
workflow_dispatch:
6+
workflow_call:
7+
push:
8+
branches: [main]
9+
10+
concurrency:
11+
# A PR number if a pull request and otherwise the commit hash. This cancels
12+
# queued and in-progress runs for the same PR (presubmit) or commit
13+
# (postsubmit).
14+
group: ci-build-test-cpp-windows-${{ github.event.number || github.sha }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
19+
build-test-windows:
20+
strategy:
21+
fail-fast: true
22+
matrix:
23+
torch-version: [nightly]
24+
name: Build (Windows, torch-${{ matrix.torch-version }})
25+
runs-on: windows-latest
26+
defaults:
27+
run:
28+
shell: bash
29+
env:
30+
CACHE_DIR: ${{ github.workspace }}\.container-cache
31+
steps:
32+
- name: "Checking out repository"
33+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
with:
35+
submodules: true
36+
37+
- name: Setup workspace
38+
uses: ./.github/actions/setup-build
39+
40+
- name: Enable cache
41+
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
42+
with:
43+
path: ${{ env.CACHE_DIR }}
44+
# Use as cache key a PR number if a pull request and otherwise the commit hash. This reuses the cache for a PR irrespective of the commit hash. Otherwise, it uses commit hash for merges into the main branch
45+
key: build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-${{ github.event.number || github.sha }}
46+
restore-keys: |
47+
build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-
48+
49+
- name: "Configuring MSVC"
50+
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
51+
52+
- name: Install python deps (torch-${{ matrix.torch-version }})
53+
run: |
54+
./build_tools/ci/install_python_deps.sh ${{ matrix.torch-version }}
55+
56+
- name: ccache
57+
uses: hendrikmuhs/ccache-action@53911442209d5c18de8a31615e0923161e435875 # v1.2.16
58+
with:
59+
key: ${{ github.job }}-${{ matrix.torch-version }}
60+
save: ${{ needs.setup.outputs.write-caches == 1 }}
61+
62+
- name: Build project
63+
run: |
64+
cache_dir="${{ env.CACHE_DIR }}" \
65+
./build_tools/python_deploy/build_windows_ci.sh
66+
67+
- name: Save cache
68+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
69+
if: ${{ !cancelled() }}
70+
with:
71+
path: ${{ env.CACHE_DIR }}
72+
key: build-test-cpp-asserts-windows-${{ matrix.torch-version }}-v2-${{ github.event.number || github.sha }}
73+
74+
# todo: enable when use of `signal` for timeout is enhanced to be platform-agnostic
75+
# - name: Integration tests (torch-${{ matrix.torch-version }})
76+
# run: |
77+
# ./build_tools/ci/test_posix.sh ${{ matrix.torch-version }}

build_tools/python_deploy/build_windows_ci.sh

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
#!/usr/bin/env bash
2-
set -eo pipefail
2+
set -eu -o errtrace
33

44
echo "Building torch-mlir"
55

6+
cache_dir="${cache_dir:-}"
7+
this_dir="$(cd $(dirname $0) && pwd)"
8+
repo_root="$(cd ${this_dir}/../.. && pwd)"
9+
10+
# Setup cache dir.
11+
if [ -z "${cache_dir}" ]; then
12+
cache_dir="${repo_root}/.build-cache"
13+
mkdir -p "${cache_dir}"
14+
cache_dir="$(cd ${cache_dir} && pwd)"
15+
fi
16+
17+
echo "Caching to ${cache_dir}"
18+
mkdir -p "${cache_dir}/ccache"
19+
mkdir -p "${cache_dir}/pip"
20+
21+
export CCACHE_DIR="${cache_dir}/ccache"
22+
export CCACHE_MAXSIZE="350M"
23+
24+
# Clear ccache stats.
25+
ccache -z
26+
27+
echo "::group::CMake configure"
628
cmake -GNinja -Bbuild \
729
-DCMAKE_BUILD_TYPE=Release \
830
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
@@ -14,9 +36,23 @@ cmake -GNinja -Bbuild \
1436
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
1537
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
1638
-DPython3_EXECUTABLE="$(which python)" \
39+
-DPython_EXECUTABLE="$(which python)" \
1740
-DTORCH_MLIR_ENABLE_STABLEHLO=OFF \
18-
$GITHUB_WORKSPACE/externals/llvm-project/llvm
41+
-DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS=ON \
42+
-DTORCH_MLIR_ENABLE_LTC=OFF \
43+
-DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
44+
${repo_root}/externals/llvm-project/llvm
45+
echo "::endgroup::"
1946

20-
cmake --build build --config Release
47+
echo "::group::Build"
48+
cmake --build ${repo_root}/build --target tools/torch-mlir/all -- -k 0
49+
echo "::endgroup::"
2150

2251
echo "Build completed successfully"
52+
53+
echo "::group::Unit tests"
54+
cmake --build ${repo_root}/build --target check-torch-mlir
55+
echo "::endgroup::"
56+
57+
# Show ccache stats.
58+
ccache --show-stats

0 commit comments

Comments
 (0)