-
Notifications
You must be signed in to change notification settings - Fork 84
[ADDON] Add torch c dlpack ext wheels for windows #252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+202
−4
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
9a5db15
upd
cyx-6 546dce0
debug
cyx-6 feb62cb
upd
cyx-6 f93895f
upd
cyx-6 ea06d08
upd
cyx-6 057226b
upd
cyx-6 2c8cc2d
upd
cyx-6 384154f
debug
cyx-6 dcb7740
upd
cyx-6 3eba302
debug
cyx-6 4f61dab
try
cyx-6 52127de
try
cyx-6 deecd7a
fix
cyx-6 9f2d637
fix
cyx-6 adcd734
fix
cyx-6 90c8bd7
fix
cyx-6 7c6f353
revert
cyx-6 7c32ea0
upd
cyx-6 4f688f1
fix
cyx-6 158a96c
fix
cyx-6 a0a23e1
debug
cyx-6 ed23696
fix
cyx-6 1c492d7
debug
cyx-6 b358da9
debug
cyx-6 4d9c6e5
debug
cyx-6 1a6ed54
fix
cyx-6 3429d46
debug
cyx-6 170881f
debug
cyx-6 3fb642d
fix
cyx-6 1d2d183
debug
cyx-6 816e21e
try
cyx-6 ac0f41a
fix
cyx-6 7dd023a
fix
cyx-6 69b279e
upd
cyx-6 2d38e29
Merge commit '583e4b73c11aa3257e7be862834b98f33c39a6dd' into torch-c-…
cyx-6 7a9e32e
upd
cyx-6 f967489
upd
cyx-6 ff8201b
upd
cyx-6 e402db2
fix
cyx-6 6f13c57
fix
cyx-6 ec03037
upd
cyx-6 806538c
fix
cyx-6 c2d787b
upd
cyx-6 1c8f4e7
upd
cyx-6 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| name: torch c dlpack | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| branch: | ||
| description: "Branch or tag to publish (manual run)" | ||
| required: true | ||
|
|
||
| jobs: | ||
| build_wheels_windows: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| arch: ["x86_64"] | ||
| python-version: ["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"] | ||
| runs-on: windows-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| with: | ||
| repository: apache/tvm-ffi | ||
| ref: main | ||
| fetch-depth: 0 | ||
| submodules: recursive | ||
| path: tvm-ffi | ||
| - uses: Jimver/cuda-toolkit@6008063726ffe3309d1b22e413d9e88fed91a2f2 | ||
| id: cuda-toolkit | ||
| - uses: astral-sh/setup-uv@v7 | ||
| - name: build wheels | ||
| env: | ||
| CUDA_HOME: ${{steps.cuda-toolkit.outputs.CUDA_PATH}} | ||
| shell: cmd | ||
| working-directory: ./tvm-ffi | ||
| run: ./addons/torch_c_dlpack_ext/build_aot_wheels.bat ${{ matrix.arch }} ${{ matrix.python-version }} | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pypi-wheels-windows-${{ matrix.arch }}-${{ matrix.python-version }} | ||
| path: ./tvm-ffi/addons/torch_c_dlpack_ext/wheelhouse/*.whl | ||
| upload_pypi: | ||
| needs: [build_wheels_windows] | ||
| runs-on: ubuntu-latest | ||
| environment: pypi | ||
| permissions: | ||
| id-token: write | ||
| attestations: write | ||
| if: github.event_name == 'workflow_dispatch' # <-- publish only on manual trigger | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: pypi-* | ||
| path: dist | ||
| merge-multiple: true | ||
| - name: Generate artifact attestation for sdist and wheels | ||
| uses: actions/attest-build-provenance@v1 | ||
| with: | ||
| subject-path: dist/* | ||
| - name: Publish package distributions to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| attestations: true | ||
| verbose: true | ||
| # testing publish url | ||
| # repository-url: https://test.pypi.org/legacy/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| @REM Licensed to the Apache Software Foundation (ASF) under one | ||
| @REM or more contributor license agreements. See the NOTICE file | ||
| @REM distributed with this work for additional information | ||
| @REM regarding copyright ownership. The ASF licenses this file | ||
| @REM to you under the Apache License, Version 2.0 (the | ||
| @REM "License"); you may not use this file except in compliance | ||
| @REM with the License. You may obtain a copy of the License at | ||
| @REM | ||
| @REM http://www.apache.org/licenses/LICENSE-2.0 | ||
| @REM | ||
| @REM Unless required by applicable law or agreed to in writing, | ||
| @REM software distributed under the License is distributed on an | ||
| @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| @REM KIND, either express or implied. See the License for the | ||
| @REM specific language governing permissions and limitations | ||
| @REM under the License. | ||
| @echo off | ||
| setlocal enabledelayedexpansion | ||
|
|
||
| set arch=%~1 | ||
| set python_version=%~2 | ||
|
|
||
| set tvm_ffi=%cd% | ||
| set torch_c_dlpack_ext=%tvm_ffi%\addons\torch_c_dlpack_ext | ||
|
|
||
| if not exist "%tvm_ffi%\.venv" mkdir "%tvm_ffi%\.venv" | ||
| if not exist "%tvm_ffi%\lib" mkdir "%tvm_ffi%\lib" | ||
| for %%P in (2.4 2.5 2.6 2.7 2.8 2.9) do ( | ||
| call :build_libs %%P | ||
| ) | ||
|
|
||
| copy %tvm_ffi%\lib\*.dll %torch_c_dlpack_ext%\torch_c_dlpack_ext | ||
| uv venv %tvm_ffi%\.venv\build --python %python_version% | ||
| call %tvm_ffi%\.venv\build\Scripts\activate | ||
| uv pip install build wheel | ||
| cd %torch_c_dlpack_ext% | ||
| python -m build -w | ||
| dir dist | ||
| for %%f in (dist\*.whl) do python -m wheel tags "%%f" --python-tag=%python_version% --abi-tag=%python_version% --platform-tag=win_amd64 | ||
| dir dist | ||
| mkdir wheelhouse | ||
| copy dist\*-win_amd64.whl wheelhouse | ||
| dir wheelhouse | ||
| endlocal | ||
| exit /b | ||
|
|
||
| :build_libs | ||
| set torch_version=%1 | ||
| call :check_availability | ||
| if %errorlevel%==0 ( | ||
| call :get_torch_url | ||
| uv venv %tvm_ffi%\.venv\torch%torch_version% --python %python_version% | ||
| call %tvm_ffi%\.venv\torch%torch_version%\Scripts\activate | ||
| uv pip install setuptools ninja | ||
| uv pip install torch==%torch_version% --index-url !torch_url! | ||
| uv pip install -v . | ||
| python -m tvm_ffi.utils._build_optional_torch_c_dlpack --output-dir %tvm_ffi%\lib | ||
| python -m tvm_ffi.utils._build_optional_torch_c_dlpack --output-dir %tvm_ffi%\lib --build-with-cuda | ||
| call deactivate | ||
| rmdir -s -q %tvm_ffi%\.venv\torch%torch_version% | ||
| ) else ( | ||
| echo Skipping build for torch %torch_version% on %arch% with python %python_version% as it is not available. | ||
| ) | ||
| exit /b 0 | ||
|
|
||
|
|
||
| :check_availability | ||
| if %torch_version%==2.4 ( | ||
| if %python_version%==cp313 exit /b 1 | ||
| if %python_version%==cp314 exit /b 1 | ||
| exit /b 0 | ||
| ) | ||
| if %torch_version%==2.5 ( | ||
| if %python_version%==cp314 exit /b 1 | ||
| exit /b 0 | ||
| ) | ||
| if %torch_version%==2.6 ( | ||
| if %python_version%==cp314 exit /b 1 | ||
| exit /b 0 | ||
| ) | ||
| if %torch_version%==2.7 ( | ||
| if %python_version%==cp314 exit /b 1 | ||
| exit /b 0 | ||
| ) | ||
| if %torch_version%==2.8 ( | ||
| if %python_version%==cp314 exit /b 1 | ||
| exit /b 0 | ||
| ) | ||
| if %torch_version%==2.9 ( | ||
| if %python_version%==cp39 exit /b 1 | ||
| exit /b 0 | ||
| ) | ||
| echo Unknown or unsupported torch version: %torch_version% >&2 | ||
| exit /b 1 | ||
|
|
||
| :get_torch_url | ||
| set cuda_version= | ||
| if %torch_version%==2.4 set cuda_version=cu124 | ||
| if %torch_version%==2.5 set cuda_version=cu124 | ||
| if %torch_version%==2.6 set cuda_version=cu126 | ||
| if %torch_version%==2.7 set cuda_version=cu128 | ||
| if %torch_version%==2.8 set cuda_version=cu129 | ||
| if %torch_version%==2.9 set cuda_version=cu129 | ||
| if defined cuda_version ( | ||
| set torch_url=https://download.pytorch.org/whl/%cuda_version% | ||
| exit /b 0 | ||
| ) | ||
| echo Unknown or unsupported torch version: %torch_version% >&2 | ||
| exit /b 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.