Skip to content

Commit ac6a6cd

Browse files
committed
[REFACTOR][CI] Clean up GitHub Actions platform build workflow
1 parent 8cb946e commit ac6a6cd

2 files changed

Lines changed: 101 additions & 96 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 101 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -35,70 +35,117 @@ concurrency:
3535
cancel-in-progress: true
3636

3737
jobs:
38-
MacOS:
38+
Platform:
3939
if: ${{ github.repository == 'apache/tvm' }}
40-
runs-on: macOS-latest
40+
strategy:
41+
matrix:
42+
include:
43+
- name: MacOS
44+
os: macOS-latest
45+
- name: Windows
46+
os: windows-latest
47+
runs-on: ${{ matrix.os }}
48+
name: ${{ matrix.name }}
49+
env:
50+
UV_PYTHON: ${{ matrix.os == 'windows-latest' && '.venv/Scripts/python.exe' || '.venv/bin/python' }}
4151
steps:
4252
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4353
with:
4454
submodules: 'recursive'
45-
- name: Set up environment
46-
uses: ./.github/actions/setup
47-
- name: Install LLVM dependencies
48-
shell: bash -l {0}
55+
- uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
56+
with:
57+
python-version: "3.10"
58+
enable-cache: true
59+
cache-python: true
60+
61+
- name: Create venv
62+
run: uv venv
63+
64+
- name: Install python dependencies
65+
run: uv pip install --verbose scikit-build-core
66+
67+
- name: Install LLVM dependencies (MacOS)
68+
if: matrix.os == 'macOS-latest'
69+
run: brew install llvm cmake ninja zlib
70+
71+
- name: Install dependencies (Windows)
72+
if: matrix.os == 'windows-latest'
73+
run: choco install llvm cmake ninja -y --no-progress
74+
75+
- name: Install LLVM (clang+llvm tarball) and patch diaguids path (Windows)
76+
if: matrix.os == 'windows-latest'
77+
id: install_llvm_windows
78+
shell: pwsh
4979
run: |
50-
conda install -c conda-forge llvmdev cmake ninja zlib
51-
- name: Build TVM wheel
52-
shell: bash -l {0}
80+
$ErrorActionPreference = "Stop"
81+
82+
$llvmVersion = "20.1.0"
83+
$base = "$env:RUNNER_TEMP\llvm"
84+
New-Item -ItemType Directory -Force -Path $base | Out-Null
85+
86+
$archive = "$base\clang+llvm.tar.xz"
87+
$url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang%2Bllvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz"
88+
Invoke-WebRequest -Uri $url -OutFile $archive
89+
90+
tar -xf $archive -C $base
91+
92+
$llvmRoot = Join-Path $base "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc"
93+
94+
# --- Patch diaguids.lib absolute path in LLVMExports.cmake ---
95+
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
96+
if (!(Test-Path $vswhere)) { throw "vswhere not found: $vswhere" }
97+
98+
$vsPath = & $vswhere -latest -property installationPath
99+
if (!$vsPath) { throw "Visual Studio installation path not found." }
100+
101+
$diaLib = Join-Path $vsPath "DIA SDK\lib\amd64\diaguids.lib"
102+
if (!(Test-Path $diaLib)) { throw "diaguids.lib not found: $diaLib" }
103+
104+
$diaLibPosix = $diaLib.Replace('\','/')
105+
106+
$llvmExports = Join-Path $llvmRoot "lib\cmake\llvm\LLVMExports.cmake"
107+
if (!(Test-Path $llvmExports)) { throw "LLVMExports.cmake not found: $llvmExports" }
108+
109+
$content = Get-Content $llvmExports -Raw
110+
$content = $content -replace 'C:/Program Files.*?/DIA SDK/lib/amd64/diaguids\.lib', $diaLibPosix
111+
Set-Content -Path $llvmExports -Value $content -NoNewline
112+
113+
# export PATH and LLVM_DIR for cmake find_package(LLVM)
114+
echo "$llvmRoot\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
115+
$llvmDir = (Join-Path $llvmRoot "lib\cmake\llvm").Replace('\','/')
116+
echo "LLVM_DIR=$llvmDir" | Out-File -FilePath $env:GITHUB_ENV -Append
117+
echo "llvm_dir=$llvmDir" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
118+
119+
- name: Build and Install tvm-ffi
120+
run: uv pip install --verbose ./3rdparty/tvm-ffi
121+
122+
- name: Build and Install TVM (MacOS)
123+
if: matrix.os == 'macOS-latest'
53124
run: |
54-
pip install scikit-build-core
55-
export CMAKE_ARGS="-DUSE_LLVM=ON -DBUILD_TESTING=OFF"
56-
pip wheel --no-deps -w dist . -v
57-
- name: Install TVM from wheel
58-
shell: bash -l {0}
125+
export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config' -DBUILD_TESTING=OFF"
126+
uv pip install --no-deps . --verbose
127+
128+
- name: Build and Install TVM (Windows)
129+
if: matrix.os == 'windows-latest'
59130
run: |
60-
pip install dist/*.whl
131+
$env:CMAKE_ARGS = "-G Ninja -DUSE_LLVM=ON -DBUILD_TESTING=OFF -DLLVM_DIR=${{ steps.install_llvm_windows.outputs.llvm_dir }}"
132+
uv pip install --no-deps . --verbose
133+
134+
- name: Install test dependencies
135+
run: uv pip install --verbose psutil cloudpickle ml_dtypes numpy packaging scipy tornado typing_extensions pytest
136+
137+
- name: Platform minimal test
138+
run: uv run pytest -v tests/python/all-platform-minimal-test
61139

62-
- name: Test
63-
shell: bash -l {0}
64-
run: >-
65-
python -m pytest -v tests/python/all-platform-minimal-test
66140
- name: Minimal Metal Compile-Only
67-
shell: bash -l {0}
141+
if: matrix.os == 'macOS-latest'
68142
run: |
69-
python -m pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum_compile'
70-
python -m pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py::test_func_with_trailing_pod_params'
71-
- name: Minimal Metal Compile-and-Run
72-
shell: bash -l {0}
73-
run: >-
74-
python -m pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py'
75-
python -m pytest -v -s 'tests/python/codegen/test_target_codegen_gpu_common.py'
76-
python -m pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum[dims0-metal]'
143+
uv run pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum_compile'
144+
uv run pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py::test_func_with_trailing_pod_params'
77145
78-
Windows:
79-
if: ${{ github.repository == 'apache/tvm' }}
80-
runs-on: windows-latest
81-
steps:
82-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
83-
with:
84-
submodules: 'recursive'
85-
- name: Set up environment
86-
uses: ./.github/actions/setup
87-
- name: Install LLVM dependencies
88-
shell: cmd /C call {0}
89-
run: |
90-
conda install -c conda-forge llvmdev cmake ninja zlib libxml2-devel
91-
- name: Install TVM
92-
shell: cmd /C call {0}
93-
run: |
94-
pip install scikit-build-core
95-
set CMAKE_ARGS=-DUSE_LLVM=ON -DBUILD_TESTING=OFF
96-
pip install --no-deps . -v
97-
- name: Install test dependencies
98-
shell: cmd /C call {0}
146+
- name: Minimal Metal Compile-and-Run
147+
if: matrix.os == 'macOS-latest'
99148
run: |
100-
pip install psutil cloudpickle ml_dtypes numpy packaging scipy tornado typing_extensions
101-
- name: Test
102-
shell: cmd /C call {0}
103-
run: >-
104-
python -m pytest -v tests/python/all-platform-minimal-test
149+
uv run pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py'
150+
uv run pytest -v -s 'tests/python/codegen/test_target_codegen_gpu_common.py'
151+
uv run pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum[dims0-metal]'

0 commit comments

Comments
 (0)