Skip to content

Commit facaec6

Browse files
authored
refactor(torch_npu): improve workflows (#9)
1 parent e66d303 commit facaec6

File tree

6 files changed

+218
-326
lines changed

6 files changed

+218
-326
lines changed

.github/actions/dependencies-action/action.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

.github/actions/fetch-and-rebase/action.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: '_ascend_npu_build'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner:
7+
required: true
8+
type: string
9+
description: 'The runner selected to run on'
10+
image:
11+
required: true
12+
type: string
13+
description: 'The docker image which will be used to build'
14+
outputs:
15+
artifact_name:
16+
description: 'The torch_npu distribution artifact name'
17+
value: ${{ jobs.build.outputs.dist_name }}
18+
19+
# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
20+
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
21+
# It's used to activate ascend-toolkit environment variables.
22+
defaults:
23+
run:
24+
shell: bash -el {0}
25+
26+
jobs:
27+
build:
28+
name: build torch_npu
29+
runs-on: ${{ inputs.runner }}
30+
container:
31+
image: ${{ inputs.image }}
32+
outputs:
33+
dist_name: ${{ steps.list-dist.outputs.dist_name }}
34+
steps:
35+
# TODO(shink): Should we add these dependencies to the image?
36+
- name: Install system dependencies
37+
run: |
38+
sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
39+
apt update
40+
apt install --no-install-recommends -y git gcc g++ make cmake ninja-build
41+
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
45+
- name: Checkout torch_npu
46+
uses: actions/checkout@v4
47+
with:
48+
# TODO(shink): Use Ascend/pytorch once this pr merged:
49+
# https://gitee.com/ascend/pytorch/pulls/12854
50+
# repository: Ascend/pytorch
51+
repository: shink/torchnpu
52+
ref: feat/autoload
53+
submodules: recursive
54+
path: torch_npu
55+
56+
- name: Install pip dependencies
57+
working-directory: torch_npu
58+
run: |
59+
pip install wheel
60+
pip install -r requirements.txt
61+
62+
- name: List Python version
63+
id: list-py-version
64+
working-directory: torch_npu
65+
run: |
66+
py_version=$(python --version | awk '{print $2}' | cut -d '.' -f 1,2)
67+
echo "py_version=${py_version}" >> $GITHUB_OUTPUT
68+
69+
- name: Build torch_npu
70+
working-directory: torch_npu
71+
run: |
72+
bash ci/build.sh --python=${{ steps.list-py-version.outputs.py_version }}
73+
74+
- name: List distribution package
75+
id: list-dist
76+
working-directory: torch_npu/dist
77+
run: |
78+
dist_name=$(ls torch_npu*.whl)
79+
dist_path=$(pwd)/${dist_name}
80+
echo "dist_name=${dist_name}" >> $GITHUB_OUTPUT
81+
echo "dist_path=${dist_path}" >> $GITHUB_OUTPUT
82+
83+
- name: Upload distribution artifact
84+
id: upload-dist
85+
continue-on-error: true
86+
uses: actions/upload-artifact@v4
87+
with:
88+
name: ${{ steps.list-dist.outputs.dist_name }}
89+
path: ${{ steps.list-dist.outputs.dist_path }}
90+
if-no-files-found: error
91+
retention-days: 1
92+
overwrite: true
93+
94+
- name: Write to workflow job summary
95+
if: ${{ steps.upload-dist.outputs.artifact-url }}
96+
run: |
97+
echo "## torch_npu built successfully! :rocket:" >> $GITHUB_STEP_SUMMARY
98+
echo "You can download the distribution package [here](${{ steps.upload-dist.outputs.artifact-url }})." >> $GITHUB_STEP_SUMMARY
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: '_ascend_npu_test'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
runner:
7+
required: true
8+
type: string
9+
description: 'The runner selected to run on'
10+
image:
11+
required: true
12+
type: string
13+
description: 'The docker image which will be loaded'
14+
device:
15+
required: true
16+
type: string
17+
description: 'The device selected to run on'
18+
artifact_name:
19+
required: true
20+
type: string
21+
description: 'The torch_npu distribution artifact name'
22+
23+
# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
24+
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
25+
# It's used to activate ascend-toolkit environment variables.
26+
defaults:
27+
run:
28+
shell: bash -el {0}
29+
30+
jobs:
31+
test:
32+
name: test torch_npu in ${{ inputs.image }} with ${{ inputs.device }}
33+
runs-on: ${{ inputs.runner }}
34+
container:
35+
image: ${{ inputs.image }}
36+
volumes:
37+
- /usr/local/dcmi:/usr/local/dcmi
38+
- /usr/local/bin/npu-smi:/usr/local/bin/npu-smi
39+
- /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/
40+
- /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info
41+
- /etc/ascend_install.info:/etc/ascend_install.info
42+
options: >-
43+
--network host
44+
--device ${{ inputs.device }}
45+
--device /dev/davinci_manager
46+
--device /dev/devmm_svm
47+
--device /dev/hisi_hdc
48+
steps:
49+
- name: Show NPU info
50+
run: |
51+
npu-smi info
52+
53+
- name: Install system dependencies
54+
run: |
55+
sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
56+
apt update
57+
apt install --no-install-recommends -y git gcc g++ make cmake ninja-build
58+
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Checkout torch_npu
63+
uses: actions/checkout@v4
64+
with:
65+
# TODO(shink): Use Ascend/pytorch once this pr merged:
66+
# https://gitee.com/ascend/pytorch/pulls/12854
67+
# repository: Ascend/pytorch
68+
repository: shink/torchnpu
69+
ref: feat/autoload
70+
submodules: recursive
71+
path: torch_npu
72+
73+
- name: Download distribution artifact
74+
uses: actions/download-artifact@v4
75+
with:
76+
name: ${{ inputs.artifact_name }}
77+
path: torch_npu
78+
79+
- name: Install pip dependencies
80+
working-directory: torch_npu
81+
run: |
82+
pip install wheel unittest-xml-reporting
83+
pip install -r requirements.txt
84+
pip install -r test/requirements.txt --no-deps
85+
86+
- name: Install torch_npu
87+
working-directory: torch_npu
88+
run: |
89+
pip install ${{ inputs.artifact_name }}
90+
91+
# TODO(shink): Skip
92+
- name: Do the test
93+
continue-on-error: true
94+
run: |
95+
python torch_npu/ci/access_control_test.py

0 commit comments

Comments
 (0)