-
Notifications
You must be signed in to change notification settings - Fork 45
304 lines (266 loc) · 9.94 KB
/
release.yml
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: Release
run-name: "${{ github.event.inputs.title }}"
defaults:
run:
shell: bash -le {0}
on:
release:
types: [ published ]
repository_dispatch:
workflow_dispatch:
inputs:
title:
description: 'set a title for this run'
required: false
default: ''
repo:
description: 'GitHub repo {owner}/{repo}'
required: false
default: ''
ref:
description: 'GitHub ref: Branch, Tag or Commit SHA'
required: false
default: ''
pr_number:
description: 'PR Number'
required: false
type: number
target:
description: 'CUDA Torch Python version separated by space, check http://10.0.13.31/gpu/runner/docker to get all supported combinations'
required: false
default: ''
max-parallel:
description: 'max parallel jobs'
required: false
default: '10'
upload_release:
description: 'upload to release (it only works with a tag ref)'
type: boolean
required: false
default: false
upload_pypi:
description: 'upload to PyPI'
type: boolean
required: false
default: false
env:
CUDA_DEVICE_ORDER: PCI_BUS_ID
RUNNER: 10.0.14.248
TORCH_CUDA_ARCH_LIST: '8.0 8.6 8.9 9.0'
RELEASE_MODE: 1
CI: 1
GPTQMODEL_FORCE_BUILD: 1
repo: ${{ github.event.inputs.repo || github.repository }}
ref: ${{ github.event.inputs.ref || github.ref }}
MAX_JOBS: 8
concurrency:
group: ${{ github.event.inputs.ref || github.ref }}-workflow-release
cancel-in-progress: true
jobs:
check-vm:
runs-on: [self-hosted, Linux]
container:
image: modelcloud/gptqmodel:alpine-ci-v1
outputs:
ip: ${{ steps.get_ip.outputs.ip }}
task_list: ${{ steps.assign.outputs.task_list }}
max-parallel: ${{ steps.get_ip.outputs.max-parallel }}
steps:
- name: Print env
run: |
echo "event name: ${{ github.event_name }}"
echo "repo: ${{ env.repo }}"
echo "ref: ${{ env.ref }}"
echo "max-parallel: ${{ inputs.max-parallel }}"
echo "upload_release: ${{ inputs.upload_release }}"
echo "upload_pypi: ${{ inputs.upload_pypi }}"
- name: Select server
id: get_ip
run: |
echo "ip=${RUNNER}" >> "$GITHUB_OUTPUT"
echo "GPU_IP=${RUNNER}" >> $GITHUB_ENV
echo "ip: $ip"
max_p=${{ github.event.inputs.max-parallel }}
max_p="{\"size\": ${max_p:-10}}"
echo "max-parallel=$max_p" >> "$GITHUB_OUTPUT"
echo "max-parallel=$max_p"
- name: Assign tasks
id: assign
run: |
input="${{ github.event.inputs.target }}"
if [[ -z "$input" ]]; then
server_lists=$(curl -s "http://${RUNNER}/gpu/runner/docker?json=1")
echo "lists=$server_lists"
IFS=$'+' read -r list_1 list_2 <<< "$server_lists"
echo "list 1: $list_1"
echo "list 2: $list_2"
else
echo "inputed target is: $input"
if [[ "$input" =~ \ ]]; then
echo "extracting cuda torch and python"
read -r cuda torch py <<< "$input"
task=compiler_cuda$cuda-torch$torch-python$py
list_1="[\"$task\"]"
else
echo "use inputed image name"
list_1="[\"$input\"]"
fi
list_2="[]"
echo "task list: $list_1"
fi
echo "task_list=$list_1" >> "$GITHUB_OUTPUT"
release:
strategy:
fail-fast: false
max-parallel: ${{ fromJson(needs.check-vm.outputs.max-parallel).size || 10 }}
matrix:
tag: ${{ fromJSON(needs.check-vm.outputs.task_list) }}
runs-on: [self-hosted, xeon5 ]
needs:
- check-vm
if: needs.check-vm.outputs.task_list != '' && !cancelled()
container:
image: ${{ needs.check-vm.outputs.ip }}:5000/modelcloud/gptqmodel:${{ matrix.tag }}
steps:
- name: Checkout Codes
uses: actions/checkout@v4
with:
repository: ${{ env.repo }}
ref: ${{ env.ref }}
- name: Fetch PR by number
if: ${{ github.event.inputs.pr_number != 0 }}
run: |
PR_NUMBER=${{ github.event.inputs.pr_number }}
echo "pr number $PR_NUMBER"
git config --global --add safe.directory $(pwd)
git fetch origin pull/${PR_NUMBER}/head:pr-${PR_NUMBER}
git checkout pr-${PR_NUMBER}
- name: Print Env
run: |
echo "== pyenv =="
pyenv versions
echo "== python =="
python --version
echo "== nvcc =="
#nvcc --version
echo "== torch =="
pip show torch
- name: Install requirements
run: |
cuda_version=$(echo ${{ matrix.tag }} | grep -oP 'cuda\K[0-9.]+')
torch_version=$(echo ${{ matrix.tag }} | grep -oP 'torch\K[0-9.]+')
python_version=$(echo ${{ matrix.tag }} | grep -oP 'python\K[0-9.]+')
bash -c "$(curl -L http://${RUNNER}/scripts/env/init_compiler.sh)" @ $cuda_version $torch_version $python_version
- name: Compile
run: python setup.py bdist_wheel
- name: Test install
run: |
ls -ahl dist
whl=$(ls -t dist/*.whl | head -n 1 | xargs basename)
echo "WHL_NAME=$whl" >> $GITHUB_ENV
twine check dist/$whl
pip install dist/$whl
- name: Upload wheel
continue-on-error: true
run: |
sha256=$(sha256sum dist/${{ env.WHL_NAME }})
response=$(curl -s -F "runid=${{ github.run_id }}" -F "repo=${{ env.repo }}" -F "ref=${{ env.ref }}" -F "sha256=$sha256" -F "file=@dist/${{ env.WHL_NAME }}" http://${{ needs.check-vm.outputs.ip }}/gpu/whl/upload)
if [ "$response" -eq 0 ]; then
echo "UPLOADED=1" >> $GITHUB_ENV
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
continue-on-error: ${{ env.UPLOADED == '1' }}
with:
overwrite: true
name: ${{ env.WHL_NAME }}
path: dist/${{ env.WHL_NAME }}
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
if: (github.event_name == 'release' || github.event.inputs.upload_release == 'true') && !cancelled()
with:
repo_name: ${{ env.repo }}
tag: ${{ env.ref }}
file: dist/${{ env.WHL_NAME }}
file_glob: true
overwrite: true
release-source:
runs-on: [self-hosted, xeon5 ]
needs:
- check-vm
container:
image: ${{ needs.check-vm.outputs.ip }}:5000/modelcloud/gptqmodel:compiler_cuda124-torch2.4.1-python311
env:
RELEASE_MODE: 0
steps:
- name: Checkout Codes
uses: actions/checkout@v4
with:
repository: ${{ env.repo }}
ref: ${{ env.ref }}
- name: Fetch PR by number
if: ${{ github.event.inputs.pr_number != 0 }}
run: |
PR_NUMBER=${{ github.event.inputs.pr_number }}
echo "pr number $PR_NUMBER"
git config --global --add safe.directory $(pwd)
git fetch origin pull/${PR_NUMBER}/head:pr-${PR_NUMBER}
git checkout pr-${PR_NUMBER}
- name: Install requirements
run: pip install build setuptools -U -i http://${{ needs.check-vm.outputs.ip }}/simple/ --trusted-host ${{ needs.check-vm.outputs.ip }}
- name: Compile
run: python -m build --no-isolation --sdist
- name: Check dist
run: |
ls -ahl dist
whl=$(ls -t dist/*.gz | head -n 1 | xargs basename)
echo "WHL_NAME=$whl" >> $GITHUB_ENV
twine check dist/$whl
- name: Upload to local
continue-on-error: true
run: |
sha256=$(sha256sum dist/${{ env.WHL_NAME }})
response=$(curl -s -F "runid=${{ github.run_id }}" -F "repo=${{ env.repo }}" -F "ref=${{ env.ref }}" -F "sha256=$sha256" -F "file=@dist/${{ env.WHL_NAME }}" http://${{ needs.check-vm.outputs.ip }}/gpu/whl/upload)
if [ "$response" -eq 0 ]; then
echo "UPLOADED=1" >> $GITHUB_ENV
fi
- name: Upload to artifact
uses: actions/upload-artifact@v4
continue-on-error: ${{ env.UPLOADED == '1' }}
with:
name: ${{ env.WHL_NAME }}
path: dist/${{ env.WHL_NAME }}
- name: Upload package to release
uses: svenstaro/upload-release-action@v2
if: (github.event_name == 'release' || github.event.inputs.upload_release == 'true') && !cancelled()
with:
file: dist/${{ env.WHL_NAME }}
tag: ${{ env.ref }}
file_glob: true
overwrite: true
- name: Waiting for confirmation
if: (github.event_name == 'release' || github.event.inputs.upload_pypi == 'true') && !cancelled()
run: |
timestamp=$(date +%s%3N)
echo "open http://${RUNNER}/gpu/ci/confirm?id=${{ github.run_id }}×tamp=$timestamp&confirmed=1 to confirm releasing to pypi"
for i in {1..5}; do echo "."; done
echo "click http://${RUNNER}/gpu/ci/confirm?id=${{ github.run_id }}×tamp=$timestamp&denied=1 to DENY"
status=-1
while [ "$status" -lt 0 ]; do
status=$(curl -s "http://${RUNNER}/gpu/ci/confirm?id=${{ github.run_id }}×tamp=$timestamp")
if [ "$status" == "2" ]; then
echo "PYPI_RELEASE_CONFIRMATION=$status" >> $GITHUB_ENV
elif [ "$status" -lt 0 ]; then
sleep 5
else
echo "release has been confirmed"
echo "PYPI_RELEASE_CONFIRMATION=$status" >> $GITHUB_ENV
fi
done
- name: Upload sdist to pypi
if: (github.event_name == 'release' || github.event.inputs.upload_pypi == 'true') && env.PYPI_RELEASE_CONFIRMATION == '1' && !cancelled()
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_KEY }}
run: |
python -m twine upload dist/*gz