Skip to content

Commit e061d42

Browse files
authored
Add CI to export Whisper models to Ascend NPU (#3008)
1 parent 42aa0b8 commit e061d42

7 files changed

Lines changed: 642 additions & 7 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python3
2+
# Copyright 2026 Xiaomi Corp. (authors: Fangjun Kuang)
3+
4+
import itertools
5+
import json
6+
from dataclasses import asdict, dataclass
7+
8+
from generate_zipformer_ctc_20250703 import get_image, get_soc_version, get_cann_version
9+
10+
11+
@dataclass
12+
class Config:
13+
# 7.0, 8.0, 8.2
14+
cann: str
15+
16+
# 910B, 910B2, 910B3, 310P3
17+
soc_version: str
18+
19+
model: str
20+
21+
image: str = ""
22+
23+
def __post_init__(self):
24+
self.image = get_image(self.cann, soc_version=self.soc_version)
25+
26+
27+
def main():
28+
cann_version = get_cann_version()
29+
soc_version = get_soc_version()
30+
model_list = [
31+
"turbo",
32+
"distil-medium.en",
33+
"distil-small.en",
34+
"tiny.en",
35+
"base.en",
36+
"small.en",
37+
"medium.en",
38+
"tiny",
39+
"base",
40+
"small",
41+
"medium",
42+
"medium-aishell",
43+
]
44+
45+
configs = [
46+
Config(cann=cann, soc_version=soc, model=model)
47+
for cann, soc, model in itertools.product(cann_version, soc_version, model_list)
48+
]
49+
50+
ans = [asdict(c) for c in configs]
51+
52+
print(json.dumps({"include": ans}))
53+
54+
55+
if __name__ == "__main__":
56+
main()

.github/workflows/export-paraformer-to-ascend-npu.yaml

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: export-paraformer-to-ascend-npu
33
on:
44
push:
55
branches:
6-
- ascend-910b4-2
6+
- ci-export-whisper-ascend-npu-2
77
workflow_dispatch:
88

99
concurrency:
@@ -63,7 +63,7 @@ jobs:
6363
6464
- name: Install curl
6565
shell: bash
66-
run: apt-get update && apt-get install -y curl bzip2
66+
run: apt-get update && apt-get install -y curl bzip2 git git-lfs
6767

6868
- name: Verify environment
6969
shell: bash
@@ -127,6 +127,8 @@ jobs:
127127
python3 ./export_decoder_onnx.py
128128
python3 ./export_predictor_onnx.py
129129
130+
rm -v *.pt
131+
130132
ls -lh *.onnx
131133
132134
source /usr/local/Ascend/ascend-toolkit/set_env.sh
@@ -171,6 +173,8 @@ jobs:
171173
172174
ls -lh *.om
173175
176+
rm -v *.onnx
177+
174178
175179
echo "collect results"
176180
d=sherpa-onnx-ascend-${soc_version}-cann-$cann-paraformer-zh-2023-03-28
@@ -191,6 +195,8 @@ jobs:
191195
ls -lh *.tar.bz2
192196
rm -rf $d
193197
198+
rm -v *.om
199+
194200
echo "----show---"
195201
ls -lh *.tar.bz2
196202
@@ -267,6 +273,7 @@ jobs:
267273
268274
ls -lh *.om
269275
276+
rm -v *.onnx
270277
271278
echo "collect results"
272279
d=sherpa-onnx-ascend-${soc_version}-cann-$cann-paraformer-zh-2025-10-07
@@ -287,6 +294,8 @@ jobs:
287294
ls -lh *.tar.bz2
288295
rm -rf $d
289296
297+
rm -v *.om
298+
290299
echo "----show---"
291300
ls -lh *.tar.bz2
292301
@@ -311,3 +320,81 @@ jobs:
311320
file: ./*.tar.bz2
312321
overwrite: true
313322
tag: asr-models-ascend
323+
324+
- name: Publish to huggingface
325+
if: true
326+
env:
327+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
328+
uses: nick-fields/retry@v3
329+
with:
330+
max_attempts: 20
331+
timeout_seconds: 200
332+
shell: bash
333+
command: |
334+
git config --global user.email "csukuangfj@gmail.com"
335+
git config --global user.name "Fangjun Kuang"
336+
for m in "*.tar.bz2"; do
337+
export GIT_LFS_SKIP_SMUDGE=1
338+
export GIT_CLONE_PROTECTION_ACTIVE=false
339+
rm -rf huggingface
340+
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models huggingface
341+
342+
d=asr-models/ascend-npu/paraformer
343+
mkdir -p huggingface/$d
344+
345+
cp -v $m huggingface/$d/
346+
347+
pushd huggingface
348+
git lfs track "*.tar.bz2"
349+
ls -lh $d
350+
pushd $d
351+
git lfs track "*.tar.bz2"
352+
popd
353+
354+
git status
355+
git add .
356+
357+
git commit -m "add $m"
358+
git push https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models main
359+
popd
360+
done
361+
rm -rf huggingface
362+
363+
- name: Publish to modelscope
364+
if: true
365+
env:
366+
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
367+
uses: nick-fields/retry@v3
368+
with:
369+
max_attempts: 20
370+
timeout_seconds: 200
371+
shell: bash
372+
command: |
373+
git config --global user.email "csukuangfj@gmail.com"
374+
git config --global user.name "Fangjun Kuang"
375+
for m in "*.tar.bz2"; do
376+
export GIT_LFS_SKIP_SMUDGE=1
377+
export GIT_CLONE_PROTECTION_ACTIVE=false
378+
379+
rm -rf ms
380+
git clone https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git ms
381+
382+
d=ascend-npu/paraformer
383+
mkdir -p ms/$d
384+
385+
cp -av $m ms/$d/
386+
387+
pushd ms
388+
git lfs track "*.tar.bz2"
389+
git status
390+
ls -lh $d/$m
391+
392+
ls -lh $d
393+
git add .
394+
395+
git commit -m "add $m"
396+
git push https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git
397+
398+
popd
399+
done
400+
rm -rf ms

.github/workflows/export-sense-voice-to-ascend-npu.yaml

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: export-sense-voice-to-ascend-npu
33
on:
44
push:
55
branches:
6-
- ascend-910b4-2
6+
- ci-export-whisper-ascend-npu-2
77
workflow_dispatch:
88

99
concurrency:
@@ -62,7 +62,7 @@ jobs:
6262
6363
- name: Install curl
6464
shell: bash
65-
run: apt-get update && apt-get install -y curl bzip2
65+
run: apt-get update && apt-get install -y curl bzip2 git git-lfs
6666

6767
- name: Verify environment
6868
shell: bash
@@ -116,6 +116,7 @@ jobs:
116116
echo "export to onnx"
117117
118118
python3 ./export_onnx.py
119+
rm -v *.pt
119120
120121
ls -lh *.onnx
121122
@@ -137,6 +138,8 @@ jobs:
137138
--input_shape="x:1,-1,560;prompt:4" \
138139
--soc_version="Ascend${soc_version}"
139140
141+
rm -v *.onnx
142+
140143
ls -lh *.om
141144
142145
echo "collect results"
@@ -156,6 +159,8 @@ jobs:
156159
ls -lh *.tar.bz2
157160
rm -rf $d
158161
162+
rm -v *.om
163+
159164
echo "----show---"
160165
ls -lh *.tar.bz2
161166
@@ -186,6 +191,7 @@ jobs:
186191
187192
echo "export to onnx"
188193
python3 ./export_onnx.py
194+
rm -v *.pt
189195
190196
ls -lh *.onnx
191197
@@ -207,6 +213,7 @@ jobs:
207213
--input_shape="x:1,-1,560;prompt:4" \
208214
--soc_version="Ascend${soc_version}"
209215
216+
rm -v *.onnx
210217
ls -lh *.om
211218
212219
echo "collect results"
@@ -225,6 +232,8 @@ jobs:
225232
ls -lh *.tar.bz2
226233
rm -rf $d
227234
235+
rm -v *.om
236+
228237
echo "----show---"
229238
ls -lh *.tar.bz2
230239
@@ -249,3 +258,85 @@ jobs:
249258
file: ./*.tar.bz2
250259
overwrite: true
251260
tag: asr-models-ascend
261+
262+
- name: Publish to huggingface
263+
if: true
264+
env:
265+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
266+
uses: nick-fields/retry@v3
267+
with:
268+
max_attempts: 20
269+
timeout_seconds: 200
270+
shell: bash
271+
command: |
272+
git config --global user.email "csukuangfj@gmail.com"
273+
git config --global user.name "Fangjun Kuang"
274+
for m in "*.tar.bz2"; do
275+
export GIT_LFS_SKIP_SMUDGE=1
276+
export GIT_CLONE_PROTECTION_ACTIVE=false
277+
rm -rf huggingface
278+
git clone https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models huggingface
279+
280+
d=asr-models/ascend-npu/sense-voice
281+
mkdir -p huggingface/$d
282+
283+
cp -v $m huggingface/$d/
284+
285+
pushd huggingface
286+
git lfs track "*.tar.bz2"
287+
ls -lh $d/$m
288+
289+
ls -lh $d
290+
291+
pushd $d
292+
git lfs track "*.tar.bz2"
293+
popd
294+
295+
git status
296+
git add .
297+
298+
git commit -m "add $m"
299+
git push https://csukuangfj:$HF_TOKEN@huggingface.co/k2-fsa/sherpa-onnx-models main
300+
popd
301+
done
302+
303+
rm -rf huggingface
304+
305+
- name: Publish to modelscope
306+
if: true
307+
env:
308+
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
309+
uses: nick-fields/retry@v3
310+
with:
311+
max_attempts: 20
312+
timeout_seconds: 200
313+
shell: bash
314+
command: |
315+
git config --global user.email "csukuangfj@gmail.com"
316+
git config --global user.name "Fangjun Kuang"
317+
for m in "*.tar.bz2"; do
318+
export GIT_LFS_SKIP_SMUDGE=1
319+
export GIT_CLONE_PROTECTION_ACTIVE=false
320+
321+
rm -rf ms
322+
git clone https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git ms
323+
324+
d=ascend-npu/sense-voice
325+
mkdir -p ms/$d
326+
327+
cp -av $m ms/$d/
328+
329+
pushd ms
330+
git lfs track "*.tar.bz2"
331+
git status
332+
ls -lh $d/$m
333+
334+
ls -lh $d
335+
git add .
336+
337+
git commit -m "add $m"
338+
git push https://oauth2:${MS_TOKEN}@www.modelscope.cn/csukuangfj/asr-models.git
339+
340+
popd
341+
done
342+
rm -rf ms

0 commit comments

Comments
 (0)