-
Notifications
You must be signed in to change notification settings - Fork 85
168 lines (165 loc) · 6.43 KB
/
Copy pathtorch_c_dlpack.yml
File metadata and controls
168 lines (165 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# 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_linux:
strategy:
fail-fast: false
matrix:
arch: ["x86_64", "aarch64"]
python-version: ["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: jlumbroso/free-disk-space@main
if: ${{ matrix.arch == 'x86_64'}}
- uses: actions/checkout@v5
with:
repository: apache/tvm-ffi
ref: main
fetch-depth: 0
submodules: recursive
path: tvm-ffi
- name: prepare docker environment
run: |
docker pull quay.io/pypa/manylinux_2_28_${{ matrix.arch }}:latest
docker run --name build_lib -d quay.io/pypa/manylinux_2_28_${{ matrix.arch }}:latest tail -f /dev/null
docker cp tvm-ffi build_lib:/tvm-ffi
wget https://developer.download.nvidia.com/compute/cuda/13.0.2/local_installers/cuda-repo-rhel8-13-0-local-13.0.2_580.95.05-1.${{ matrix.arch }}.rpm > /dev/null 2>&1
docker cp cuda-repo-rhel8-13-0-local-13.0.2_580.95.05-1.${{ matrix.arch }}.rpm build_lib:/
rm cuda-repo-rhel8-13-0-local-13.0.2_580.95.05-1.${{ matrix.arch }}.rpm
docker exec build_lib bash -c "rpm -i /cuda-repo-rhel8-13-0-local-13.0.2_580.95.05-1.${{ matrix.arch }}.rpm \
&& dnf clean all \
&& dnf -y install cuda-toolkit-13-0 \
&& rm /cuda-repo-rhel8-13-0-local-13.0.2_580.95.05-1.${{ matrix.arch }}.rpm \
&& dnf clean all"
- name: build torch libs and wheels
run: |
docker exec -w /tvm-ffi build_lib bash ./addons/torch_c_dlpack_ext/build_aot_wheels.sh ${{ matrix.arch }} ${{ matrix.python-version }}
- name: collect built wheels
run: |
mkdir wheelhouse
docker cp build_lib:/tvm-ffi/addons/torch_c_dlpack_ext/wheelhouse/ .
- uses: actions/upload-artifact@v4
with:
name: pypi-wheels-linux-${{ matrix.arch }}-${{ matrix.python-version }}
path: ./wheelhouse/*.whl
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@3d45d157f327c09c04b50ee6ccdea2d9d017ec76 # v0.2.35
id: cuda-toolkit
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- 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
build_wheels_macos:
strategy:
fail-fast: false
matrix:
arch: ["arm64"]
python-version: ["cp39", "cp310", "cp311", "cp312", "cp313", "cp314"]
runs-on: macos-14
steps:
- uses: actions/checkout@v5
with:
repository: apache/tvm-ffi
ref: main
fetch-depth: 0
submodules: recursive
path: tvm-ffi
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
- name: build torch libs and wheels
working-directory: ./tvm-ffi
run: |
bash ./addons/torch_c_dlpack_ext/build_aot_wheels.sh ${{ matrix.arch }} ${{ matrix.python-version }}
- uses: actions/upload-artifact@v4
with:
name: pypi-wheels-macos-${{ matrix.arch }}-${{ matrix.python-version }}
path: ./tvm-ffi/addons/torch_c_dlpack_ext/wheelhouse/*.whl
build_source:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
repository: apache/tvm-ffi
ref: main
fetch-depth: 0
submodules: recursive
path: tvm-ffi
- uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
with:
python-version: "3.12"
activate-environment: true
- name: build source
run: |
uv pip install build
cd ./tvm-ffi/addons/torch_c_dlpack_ext
python -m build -s
- uses: actions/upload-artifact@v4
with:
name: pypi-source
path: ./tvm-ffi/addons/torch_c_dlpack_ext/dist/*tar.gz
upload_pypi:
needs: [build_wheels_linux, build_wheels_windows, build_wheels_macos, build_source]
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@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
attestations: true
verbose: true
# testing publish url
# repository-url: https://test.pypi.org/legacy/