Skip to content

Commit c2cabd9

Browse files
sepcntSiriusNEO
andauthored
[Feature] Add full Windows support and fix related cross-platform issues (#2093)
* [Feature] Add Windows support with cross-platform minimal diff * [Feature] Add ccache support for Windows * [Feature] Add parallel autotune support for Windows * [Feature] Add nvrtc support for Windows * [Bugfix] Fix tilelibrary support for Windows * [Bugfix] Fix alignment for Windows * [Feature] Add clang-cl support for Windows * [Bugfix] Fix numeric limit for Windows * [Bugfix] Fix rand for Windows * [Misc] Use dynamic test workload to avoid hang * [Bugfix] Fix TMA alignment for Windows and sm120 * [Bugfix] Add unix-like hex formatter for Windows * [CI] Add Windows wheel job * [Feature] Flexible CUDA loader * fix rebase --------- Co-authored-by: SiriusNEO <chaofan@deepseek.com>
1 parent fd46aff commit c2cabd9

56 files changed

Lines changed: 3756 additions & 382 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/dist.yml

Lines changed: 109 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
uses: hendrikmuhs/ccache-action@v1
8282
with:
8383
max-size: "200MB"
84-
create-symlink: true
84+
create-symlink: ${{ runner.os != 'Windows' }}
8585
evict-old-files: "7d"
8686
append-timestamp: false
8787
key: sdist-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/*.cc') }}
@@ -108,19 +108,19 @@ jobs:
108108
if-no-files-found: error
109109

110110
build-wheels:
111-
name: Build wheels for Python ${{ matrix.python-version }} on ${{ matrix.target.runner }} with ${{ matrix.target.toolkit }}
111+
name: Build wheels for Python ${{ matrix.target.python_version }} on ${{ matrix.target.runner }} with ${{ matrix.target.toolkit }}
112112
if: |
113113
github.repository_owner == 'tile-ai' &&
114114
(github.event_name != 'pull_request' || !github.event.pull_request.draft)
115115
strategy:
116116
matrix:
117117
target:
118-
- { runner: ubuntu-latest, toolkit: "CUDA-12.8", test_backends: "cu118 cu130" }
119-
- { runner: ubuntu-24.04-arm, toolkit: "CUDA-12.8", test_backends: "cu126 cu130" }
120-
- { runner: macos-latest, toolkit: "Metal" }
121-
python-version:
122-
# Build wheels for different Python ABIs
123-
- "3.9"
118+
# Build wheels for different Python ABIs.
119+
# Windows CUDA 13.0 uses cp310 because PyTorch cu130 does not publish cp39 wheels.
120+
- { runner: ubuntu-latest, toolkit: "CUDA-12.8", test_backends: "cu118 cu130", python_version: "3.9" }
121+
- { runner: ubuntu-24.04-arm, toolkit: "CUDA-12.8", test_backends: "cu126 cu130", python_version: "3.9" }
122+
- { runner: windows-latest, toolkit: "CUDA-13.0", test_backends: "cu130", python_version: "3.10" }
123+
- { runner: macos-latest, toolkit: "Metal", python_version: "3.9" }
124124
# - "3.14t" # let user to build from source for now
125125
# TODO: Add cp315-abi3.abi3t after PEP 803
126126
fail-fast: false
@@ -131,6 +131,11 @@ jobs:
131131
NO_VERSION_LABEL: "OFF"
132132

133133
steps:
134+
- name: Enable git long paths
135+
if: runner.os == 'Windows'
136+
shell: pwsh
137+
run: git config --global core.longpaths true
138+
134139
- name: Checkout repository
135140
uses: actions/checkout@v6
136141
with:
@@ -141,18 +146,19 @@ jobs:
141146
uses: hendrikmuhs/ccache-action@v1
142147
with:
143148
max-size: "200MB"
144-
create-symlink: true
149+
create-symlink: ${{ runner.os != 'Windows' }}
145150
evict-old-files: "7d"
146151
append-timestamp: false
147-
key: wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ hashFiles('**/*.cc') }}
152+
key: wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.python_version }}-${{ hashFiles('**/*.cc') }}
148153
restore-keys: |
149-
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}-${{ hashFiles('**/*.cc') }}
150-
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.python-version }}
154+
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.python_version }}-${{ hashFiles('**/*.cc') }}
155+
wheel-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.python_version }}
151156
wheel-${{ runner.os }}-${{ runner.arch }}
152157
153158
- name: Set CIBW_BUILD
159+
if: runner.os != 'Windows'
154160
run: |
155-
PYTHON_VERSION="${{ matrix.python-version }}"
161+
PYTHON_VERSION="${{ matrix.target.python_version }}"
156162
PYTHON_VERSION_MAJMIN="$(echo "${PYTHON_VERSION}" | cut -d '.' -f-2)"
157163
PYTHON_VERSION_MAJMIN_NODOT="${PYTHON_VERSION_MAJMIN//./}"
158164
echo "CIBW_BUILD=cp${PYTHON_VERSION_MAJMIN_NODOT}-*" | tee -a "${GITHUB_ENV}"
@@ -175,6 +181,30 @@ jobs:
175181
echo "CIBW_BEFORE_BUILD_LINUX=dnf install -y ccache && ccache -o cache_dir=/host${HOST_CCACHE_DIR}" | tee -a "${GITHUB_ENV}"
176182
fi
177183
184+
- name: Set CIBW_BUILD (Windows)
185+
if: runner.os == 'Windows'
186+
shell: pwsh
187+
run: |
188+
$pythonVersion = "${{ matrix.target.python_version }}"
189+
$pythonVersionMajMin = ($pythonVersion -split '\.')[0..1] -join '.'
190+
$pythonVersionMajMinNoDot = $pythonVersionMajMin -replace '\.', ''
191+
"CIBW_BUILD=cp${pythonVersionMajMinNoDot}-*" | Tee-Object -FilePath $env:GITHUB_ENV -Append
192+
"CIBW_CONFIG_SETTINGS=cmake.build-type=Release" | Tee-Object -FilePath $env:GITHUB_ENV -Append
193+
"CMAKE_BUILD_TYPE=Release" | Tee-Object -FilePath $env:GITHUB_ENV -Append
194+
195+
if ("${{ matrix.target.toolkit }}" -like "*CUDA*") {
196+
$cudaVersion = "${{ matrix.target.toolkit }}".Split('-')[-1]
197+
$cudaVersionMajMin = ($cudaVersion -split '\.')[0..1] -join '.'
198+
$cudaVersionMajMinNoDot = $cudaVersionMajMin -replace '\.', ''
199+
"CUDA_VERSION=$cudaVersion" | Tee-Object -FilePath $env:GITHUB_ENV -Append
200+
"UV_TORCH_BACKEND=cu$cudaVersionMajMinNoDot" | Tee-Object -FilePath $env:GITHUB_ENV -Append
201+
"PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu$cudaVersionMajMinNoDot" | Tee-Object -FilePath $env:GITHUB_ENV -Append
202+
}
203+
204+
if ("${{ env.IS_RELEASE }}" -eq "true") {
205+
"NO_VERSION_LABEL=ON" | Tee-Object -FilePath $env:GITHUB_ENV -Append
206+
}
207+
178208
- name: Build wheels
179209
uses: pypa/cibuildwheel@v3.4
180210
with:
@@ -186,10 +216,11 @@ jobs:
186216
id: setup-uv
187217
uses: astral-sh/setup-uv@v7
188218
with:
189-
python-version: ${{ matrix.python-version }}
219+
python-version: ${{ matrix.target.python_version }}
190220
activate-environment: true
191221

192222
- name: Test built wheels
223+
if: runner.os != 'Windows'
193224
run: |
194225
for WHEEL in wheelhouse/*.whl; do
195226
echo "Testing wheel: ${WHEEL}"
@@ -212,8 +243,34 @@ jobs:
212243
)
213244
done
214245
246+
- name: Test built wheels (Windows)
247+
if: runner.os == 'Windows'
248+
shell: pwsh
249+
run: |
250+
Get-ChildItem wheelhouse -Filter *.whl | ForEach-Object {
251+
$wheel = $_.FullName
252+
Write-Host "Testing wheel: $wheel"
253+
if ($_.Name -like "*abi3*") {
254+
uvx abi3audit --verbose --strict $wheel
255+
}
256+
if (Test-Path test-venv) {
257+
Remove-Item -Recurse -Force test-venv
258+
}
259+
uv venv test-venv
260+
$python = Join-Path (Resolve-Path test-venv).Path "Scripts\python.exe"
261+
262+
uv pip install -v --python $python $wheel
263+
Push-Location $env:RUNNER_TEMP
264+
try {
265+
& $python -c "import tilelang; print(tilelang.__version__)"
266+
} finally {
267+
Pop-Location
268+
}
269+
Remove-Item -Recurse -Force test-venv
270+
}
271+
215272
- name: Test built wheels with different CUDA
216-
if: contains(matrix.target.toolkit, 'CUDA')
273+
if: contains(matrix.target.toolkit, 'CUDA') && runner.os != 'Windows'
217274
run: |
218275
export UV_PYTHON=3.12
219276
VERSION_LOG=$(mktemp)
@@ -239,12 +296,48 @@ jobs:
239296
done
240297
cat "$VERSION_LOG"
241298
299+
- name: Test built wheels with CUDA (Windows)
300+
if: contains(matrix.target.toolkit, 'CUDA') && runner.os == 'Windows'
301+
shell: pwsh
302+
run: |
303+
$env:UV_PYTHON = "3.12"
304+
$versionLog = Join-Path $env:RUNNER_TEMP "tilelang-wheel-versions.txt"
305+
if (Test-Path $versionLog) {
306+
Remove-Item -Force $versionLog
307+
}
308+
309+
foreach ($backend in ("${{ matrix.target.test_backends }}" -split '\s+')) {
310+
if ($backend -eq "") {
311+
continue
312+
}
313+
$env:UV_TORCH_BACKEND = $backend
314+
Get-ChildItem wheelhouse -Filter *.whl | ForEach-Object {
315+
$wheel = $_.FullName
316+
Write-Host "Testing wheel: $wheel"
317+
if (Test-Path test-venv) {
318+
Remove-Item -Recurse -Force test-venv
319+
}
320+
uv venv test-venv
321+
$python = Join-Path (Resolve-Path test-venv).Path "Scripts\python.exe"
322+
323+
uv pip install -v --python $python $wheel
324+
Push-Location $env:RUNNER_TEMP
325+
try {
326+
& $python -c "import tilelang, torch; print(tilelang.__version__, torch.__version__)" | Out-File -Append -FilePath $versionLog -Encoding utf8
327+
} finally {
328+
Pop-Location
329+
}
330+
Remove-Item -Recurse -Force test-venv
331+
}
332+
}
333+
Get-Content $versionLog
334+
242335
- name: Upload wheels
243336
# Not PR to save artifact storage, as wheels are only needed for releases.
244337
if: github.event_name != 'pull_request' || contains(github.event.pull_request.title, '[Release]')
245338
uses: actions/upload-artifact@v7
246339
with:
247-
name: wheels-${{ matrix.python-version }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
340+
name: wheels-${{ matrix.target.python_version }}-${{ runner.os }}-${{ runner.arch }}-${{ matrix.target.toolkit }}
248341
path: wheelhouse/*.whl
249342
if-no-files-found: error
250343

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ maint/host_checks/logs/*
124124

125125
# agent skills folder
126126
.humanize*
127+
128+
# uv Lockfile
129+
uv.lock

0 commit comments

Comments
 (0)