From e5c5a5f1605fd491f6e4ce50084a0e6b5961c8bc Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 1/7] [REFACTOR][CI] Clean up GitHub Actions platform build workflow --- .github/workflows/main.yml | 155 ++++++++++++++++++++++++------------- 1 file changed, 101 insertions(+), 54 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a30bbc342133..e43f092144db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,70 +35,117 @@ concurrency: cancel-in-progress: true jobs: - MacOS: + Platform: if: ${{ github.repository == 'apache/tvm' }} - runs-on: macOS-latest + strategy: + matrix: + include: + - name: MacOS + os: macOS-latest + - name: Windows + os: windows-latest + runs-on: ${{ matrix.os }} + name: ${{ matrix.name }} + env: + UV_PYTHON: ${{ matrix.os == 'windows-latest' && '.venv/Scripts/python.exe' || '.venv/bin/python' }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: submodules: 'recursive' - - name: Set up environment - uses: ./.github/actions/setup - - name: Install LLVM dependencies - shell: bash -l {0} + - uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0 + with: + python-version: "3.10" + enable-cache: true + cache-python: true + + - name: Create venv + run: uv venv + + - name: Install python dependencies + run: uv pip install --verbose scikit-build-core + + - name: Install LLVM dependencies (MacOS) + if: matrix.os == 'macOS-latest' + run: brew install llvm cmake ninja zlib + + - name: Install dependencies (Windows) + if: matrix.os == 'windows-latest' + run: choco install llvm cmake ninja -y --no-progress + + - name: Install LLVM (clang+llvm tarball) and patch diaguids path (Windows) + if: matrix.os == 'windows-latest' + id: install_llvm_windows + shell: pwsh run: | - conda install -c conda-forge llvmdev cmake ninja zlib - - name: Build TVM wheel - shell: bash -l {0} + $ErrorActionPreference = "Stop" + + $llvmVersion = "20.1.0" + $base = "$env:RUNNER_TEMP\llvm" + New-Item -ItemType Directory -Force -Path $base | Out-Null + + $archive = "$base\clang+llvm.tar.xz" + $url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang%2Bllvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz" + Invoke-WebRequest -Uri $url -OutFile $archive + + tar -xf $archive -C $base + + $llvmRoot = Join-Path $base "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc" + + # --- Patch diaguids.lib absolute path in LLVMExports.cmake --- + $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" + if (!(Test-Path $vswhere)) { throw "vswhere not found: $vswhere" } + + $vsPath = & $vswhere -latest -property installationPath + if (!$vsPath) { throw "Visual Studio installation path not found." } + + $diaLib = Join-Path $vsPath "DIA SDK\lib\amd64\diaguids.lib" + if (!(Test-Path $diaLib)) { throw "diaguids.lib not found: $diaLib" } + + $diaLibPosix = $diaLib.Replace('\','/') + + $llvmExports = Join-Path $llvmRoot "lib\cmake\llvm\LLVMExports.cmake" + if (!(Test-Path $llvmExports)) { throw "LLVMExports.cmake not found: $llvmExports" } + + $content = Get-Content $llvmExports -Raw + $content = $content -replace 'C:/Program Files.*?/DIA SDK/lib/amd64/diaguids\.lib', $diaLibPosix + Set-Content -Path $llvmExports -Value $content -NoNewline + + # export PATH and LLVM_DIR for cmake find_package(LLVM) + echo "$llvmRoot\bin" | Out-File -FilePath $env:GITHUB_PATH -Append + $llvmDir = (Join-Path $llvmRoot "lib\cmake\llvm").Replace('\','/') + echo "LLVM_DIR=$llvmDir" | Out-File -FilePath $env:GITHUB_ENV -Append + echo "llvm_dir=$llvmDir" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + + - name: Build and Install tvm-ffi + run: uv pip install --verbose ./3rdparty/tvm-ffi + + - name: Build and Install TVM (MacOS) + if: matrix.os == 'macOS-latest' run: | - pip install scikit-build-core - export CMAKE_ARGS="-DUSE_LLVM=ON -DBUILD_TESTING=OFF" - pip wheel --no-deps -w dist . -v - - name: Install TVM from wheel - shell: bash -l {0} + export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config' -DBUILD_TESTING=OFF" + uv pip install --no-deps . --verbose + + - name: Build and Install TVM (Windows) + if: matrix.os == 'windows-latest' run: | - pip install dist/*.whl + $env:CMAKE_ARGS = "-G Ninja -DUSE_LLVM=ON -DBUILD_TESTING=OFF -DLLVM_DIR=${{ steps.install_llvm_windows.outputs.llvm_dir }}" + uv pip install --no-deps . --verbose + + - name: Install test dependencies + run: uv pip install --verbose psutil cloudpickle ml_dtypes numpy packaging scipy tornado typing_extensions pytest + + - name: Platform minimal test + run: uv run pytest -v tests/python/all-platform-minimal-test - - name: Test - shell: bash -l {0} - run: >- - python -m pytest -v tests/python/all-platform-minimal-test - name: Minimal Metal Compile-Only - shell: bash -l {0} + if: matrix.os == 'macOS-latest' run: | - python -m pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum_compile' - python -m pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py::test_func_with_trailing_pod_params' - - name: Minimal Metal Compile-and-Run - shell: bash -l {0} - run: >- - python -m pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py' - python -m pytest -v -s 'tests/python/codegen/test_target_codegen_gpu_common.py' - python -m pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum[dims0-metal]' + uv run pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum_compile' + uv run pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py::test_func_with_trailing_pod_params' - Windows: - if: ${{ github.repository == 'apache/tvm' }} - runs-on: windows-latest - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - submodules: 'recursive' - - name: Set up environment - uses: ./.github/actions/setup - - name: Install LLVM dependencies - shell: cmd /C call {0} - run: | - conda install -c conda-forge llvmdev cmake ninja zlib libxml2-devel - - name: Install TVM - shell: cmd /C call {0} - run: | - pip install scikit-build-core - set CMAKE_ARGS=-DUSE_LLVM=ON -DBUILD_TESTING=OFF - pip install --no-deps . -v - - name: Install test dependencies - shell: cmd /C call {0} + - name: Minimal Metal Compile-and-Run + if: matrix.os == 'macOS-latest' run: | - pip install psutil cloudpickle ml_dtypes numpy packaging scipy tornado typing_extensions - - name: Test - shell: cmd /C call {0} - run: >- - python -m pytest -v tests/python/all-platform-minimal-test + uv run pytest -v -s 'tests/python/codegen/test_target_codegen_metal.py' + uv run pytest -v -s 'tests/python/codegen/test_target_codegen_gpu_common.py' + uv run pytest -v -s 'tests/python/codegen/test_gpu_codegen_allreduce.py::test_allreduce_sum[dims0-metal]' From a3e13f20cb0cd389e8f0d5073b85560628baf465 Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 2/7] update --- .github/workflows/main.yml | 69 ++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e43f092144db..a207e8f3aa86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,8 +58,13 @@ jobs: enable-cache: true cache-python: true + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x64 + - name: Create venv - run: uv venv + run: | + uv venv .venv - name: Install python dependencies run: uv pip install --verbose scikit-build-core @@ -72,49 +77,47 @@ jobs: if: matrix.os == 'windows-latest' run: choco install llvm cmake ninja -y --no-progress - - name: Install LLVM (clang+llvm tarball) and patch diaguids path (Windows) + - name: Install LLVM + provide libxml2s.lib (Windows) if: matrix.os == 'windows-latest' - id: install_llvm_windows shell: pwsh run: | - $ErrorActionPreference = "Stop" + $ErrorActionPreference = 'Stop' + # ---- LLVM (official release tarball) ---- $llvmVersion = "20.1.0" - $base = "$env:RUNNER_TEMP\llvm" - New-Item -ItemType Directory -Force -Path $base | Out-Null - - $archive = "$base\clang+llvm.tar.xz" - $url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang%2Bllvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz" - Invoke-WebRequest -Uri $url -OutFile $archive - - tar -xf $archive -C $base - - $llvmRoot = Join-Path $base "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc" + $llvmBase = Join-Path $env:RUNNER_TEMP "llvm" + New-Item -ItemType Directory -Force -Path $llvmBase | Out-Null - # --- Patch diaguids.lib absolute path in LLVMExports.cmake --- - $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - if (!(Test-Path $vswhere)) { throw "vswhere not found: $vswhere" } + $llvmArchive = Join-Path $llvmBase "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz" + Invoke-WebRequest ` + -Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang%2Bllvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz" ` + -OutFile $llvmArchive + tar -xf $llvmArchive -C $llvmBase - $vsPath = & $vswhere -latest -property installationPath - if (!$vsPath) { throw "Visual Studio installation path not found." } + $llvmRoot = Join-Path $llvmBase "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc" + $llvmConfig = Join-Path $llvmRoot "bin\llvm-config.exe" + $llvmLibDir = & $llvmConfig --libdir - $diaLib = Join-Path $vsPath "DIA SDK\lib\amd64\diaguids.lib" - if (!(Test-Path $diaLib)) { throw "diaguids.lib not found: $diaLib" } + # ---- vcpkg libxml2 -> copy as libxml2s.lib into LLVM libdir ---- + $vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg" + git clone --depth 1 https://github.com/microsoft/vcpkg.git $vcpkgRoot + & "$vcpkgRoot\bootstrap-vcpkg.bat" -disableMetrics + & "$vcpkgRoot\vcpkg.exe" install libxml2:x64-windows - $diaLibPosix = $diaLib.Replace('\','/') + $vcpkgInstalled = Join-Path $vcpkgRoot "installed\x64-windows" - $llvmExports = Join-Path $llvmRoot "lib\cmake\llvm\LLVMExports.cmake" - if (!(Test-Path $llvmExports)) { throw "LLVMExports.cmake not found: $llvmExports" } + Copy-Item ` + (Join-Path $vcpkgInstalled "lib\libxml2.lib") ` + (Join-Path $llvmLibDir "libxml2s.lib") ` + -Force - $content = Get-Content $llvmExports -Raw - $content = $content -replace 'C:/Program Files.*?/DIA SDK/lib/amd64/diaguids\.lib', $diaLibPosix - Set-Content -Path $llvmExports -Value $content -NoNewline + # 実行時に dll を拾えるように PATH に追加 + Add-Content $env:GITHUB_PATH "$pwd\.venv\Scripts" + Add-Content $env:GITHUB_PATH (Join-Path $vcpkgInstalled "bin") - # export PATH and LLVM_DIR for cmake find_package(LLVM) - echo "$llvmRoot\bin" | Out-File -FilePath $env:GITHUB_PATH -Append - $llvmDir = (Join-Path $llvmRoot "lib\cmake\llvm").Replace('\','/') - echo "LLVM_DIR=$llvmDir" | Out-File -FilePath $env:GITHUB_ENV -Append - echo "llvm_dir=$llvmDir" | Out-File -FilePath $env:GITHUB_OUTPUT -Append + # 後続 step 用に llvm-config の場所を export(CMake は / 区切りが無難) + $llvmConfigFwd = $llvmConfig.Replace('\','/') + Add-Content $env:GITHUB_ENV "LLVM_CONFIG=$llvmConfigFwd" - name: Build and Install tvm-ffi run: uv pip install --verbose ./3rdparty/tvm-ffi @@ -128,7 +131,7 @@ jobs: - name: Build and Install TVM (Windows) if: matrix.os == 'windows-latest' run: | - $env:CMAKE_ARGS = "-G Ninja -DUSE_LLVM=ON -DBUILD_TESTING=OFF -DLLVM_DIR=${{ steps.install_llvm_windows.outputs.llvm_dir }}" + $env:CMAKE_ARGS = "-DUSE_LLVM=$env:LLVM_CONFIG -DBUILD_TESTING=OFF" uv pip install --no-deps . --verbose - name: Install test dependencies From e3467e1cc787fdb3218444192c64e9aa1624d2d6 Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 3/7] debug print --- .github/workflows/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a207e8f3aa86..88c11d2136f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -137,6 +137,12 @@ jobs: - name: Install test dependencies run: uv pip install --verbose psutil cloudpickle ml_dtypes numpy packaging scipy tornado typing_extensions pytest + - name: Debug versions + run: | + uv run python -V + uv run python -c "import pytest; print('pytest', pytest.__version__)" + uv run python -c "import tvm; print('tvm imported')" + - name: Platform minimal test run: uv run pytest -v tests/python/all-platform-minimal-test From 9b0183bf1ac7972f01462dab070d3f4ab57ce028 Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 4/7] fix macos --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 88c11d2136f3..66a5866d4aeb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,7 +125,7 @@ jobs: - name: Build and Install TVM (MacOS) if: matrix.os == 'macOS-latest' run: | - export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config' -DBUILD_TESTING=OFF" + export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config --ignore-libllvm --link-static' -DBUILD_TESTING=OFF" uv pip install --no-deps . --verbose - name: Build and Install TVM (Windows) From 34a9e2c9350d5d64adfab660fb8243e1812c9d1f Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 5/7] update --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66a5866d4aeb..b30510f90ee1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,7 @@ jobs: Platform: if: ${{ github.repository == 'apache/tvm' }} strategy: + fail-fast: false matrix: include: - name: MacOS @@ -125,7 +126,7 @@ jobs: - name: Build and Install TVM (MacOS) if: matrix.os == 'macOS-latest' run: | - export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config --ignore-libllvm --link-static' -DBUILD_TESTING=OFF" + export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config --link-static' -DBUILD_TESTING=OFF" uv pip install --no-deps . --verbose - name: Build and Install TVM (Windows) From 94627bd2335d0e0f50ce12a85f0a9a796b4457ed Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 6/7] windows --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b30510f90ee1..026526f538fd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -126,14 +126,14 @@ jobs: - name: Build and Install TVM (MacOS) if: matrix.os == 'macOS-latest' run: | - export CMAKE_ARGS="-G Ninja -DUSE_LLVM='/opt/homebrew/opt/llvm/bin/llvm-config --link-static' -DBUILD_TESTING=OFF" - uv pip install --no-deps . --verbose + export CMAKE_ARGS="-G Ninja; -DUSE_LLVM='$(brew --prefix llvm)/bin/llvm-config --link-static'; -DBUILD_TESTING=OFF" + uv pip install --no-deps . --verbose --config-settings=cmake.args="$CMAKE_ARGS" - name: Build and Install TVM (Windows) if: matrix.os == 'windows-latest' run: | $env:CMAKE_ARGS = "-DUSE_LLVM=$env:LLVM_CONFIG -DBUILD_TESTING=OFF" - uv pip install --no-deps . --verbose + uv pip install --no-deps . --verbose --config-settings=cmake.args="$env:CMAKE_ARGS" - name: Install test dependencies run: uv pip install --verbose psutil cloudpickle ml_dtypes numpy packaging scipy tornado typing_extensions pytest From 36eda30143850420b86581fb424429a887864677 Mon Sep 17 00:00:00 2001 From: Masahiro Hiramori Date: Sun, 1 Mar 2026 20:31:07 +0900 Subject: [PATCH 7/7] no ninja --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 026526f538fd..6d1b2ce3a5dc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -72,11 +72,11 @@ jobs: - name: Install LLVM dependencies (MacOS) if: matrix.os == 'macOS-latest' - run: brew install llvm cmake ninja zlib + run: brew install llvm cmake zlib - name: Install dependencies (Windows) if: matrix.os == 'windows-latest' - run: choco install llvm cmake ninja -y --no-progress + run: choco install llvm cmake -y --no-progress - name: Install LLVM + provide libxml2s.lib (Windows) if: matrix.os == 'windows-latest' @@ -126,13 +126,13 @@ jobs: - name: Build and Install TVM (MacOS) if: matrix.os == 'macOS-latest' run: | - export CMAKE_ARGS="-G Ninja; -DUSE_LLVM='$(brew --prefix llvm)/bin/llvm-config --link-static'; -DBUILD_TESTING=OFF" + export CMAKE_ARGS="-DUSE_LLVM='$(brew --prefix llvm)/bin/llvm-config --link-static'" uv pip install --no-deps . --verbose --config-settings=cmake.args="$CMAKE_ARGS" - name: Build and Install TVM (Windows) if: matrix.os == 'windows-latest' run: | - $env:CMAKE_ARGS = "-DUSE_LLVM=$env:LLVM_CONFIG -DBUILD_TESTING=OFF" + $env:CMAKE_ARGS = "-DUSE_LLVM=$env:LLVM_CONFIG" uv pip install --no-deps . --verbose --config-settings=cmake.args="$env:CMAKE_ARGS" - name: Install test dependencies