Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 0 additions & 92 deletions .github/actions/dependencies-action/action.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/actions/fetch-and-rebase/action.yml

This file was deleted.

98 changes: 98 additions & 0 deletions .github/workflows/_ascend_npu_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: '_ascend_npu_build'

on:
workflow_call:
inputs:
runner:
required: true
type: string
description: 'The runner selected to run on'
image:
required: true
type: string
description: 'The docker image which will be used to build'
outputs:
artifact_name:
description: 'The torch_npu distribution artifact name'
value: ${{ jobs.build.outputs.dist_name }}

# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
# It's used to activate ascend-toolkit environment variables.
defaults:
run:
shell: bash -el {0}

jobs:
build:
name: build torch_npu
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.image }}
outputs:
dist_name: ${{ steps.list-dist.outputs.dist_name }}
steps:
# TODO(shink): Should we add these dependencies to the image?
- name: Install system dependencies
run: |
sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
apt update
apt install --no-install-recommends -y git gcc g++ make cmake ninja-build

- name: Checkout
uses: actions/checkout@v4

- name: Checkout torch_npu
uses: actions/checkout@v4
with:
# TODO(shink): Use Ascend/pytorch once this pr merged:
# https://gitee.com/ascend/pytorch/pulls/12854
# repository: Ascend/pytorch
repository: shink/torchnpu
ref: feat/autoload
submodules: recursive
path: torch_npu

- name: Install pip dependencies
working-directory: torch_npu
run: |
pip install wheel
pip install -r requirements.txt

- name: List Python version
id: list-py-version
working-directory: torch_npu
run: |
py_version=$(python --version | awk '{print $2}' | cut -d '.' -f 1,2)
echo "py_version=${py_version}" >> $GITHUB_OUTPUT

- name: Build torch_npu
working-directory: torch_npu
run: |
bash ci/build.sh --python=${{ steps.list-py-version.outputs.py_version }}

- name: List distribution package
id: list-dist
working-directory: torch_npu/dist
run: |
dist_name=$(ls torch_npu*.whl)
dist_path=$(pwd)/${dist_name}
echo "dist_name=${dist_name}" >> $GITHUB_OUTPUT
echo "dist_path=${dist_path}" >> $GITHUB_OUTPUT

- name: Upload distribution artifact
id: upload-dist
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: ${{ steps.list-dist.outputs.dist_name }}
path: ${{ steps.list-dist.outputs.dist_path }}
if-no-files-found: error
retention-days: 1
overwrite: true

- name: Write to workflow job summary
if: ${{ steps.upload-dist.outputs.artifact-url }}
run: |
echo "## torch_npu built successfully! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "You can download the distribution package [here](${{ steps.upload-dist.outputs.artifact-url }})." >> $GITHUB_STEP_SUMMARY
95 changes: 95 additions & 0 deletions .github/workflows/_ascend_npu_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: '_ascend_npu_test'

on:
workflow_call:
inputs:
runner:
required: true
type: string
description: 'The runner selected to run on'
image:
required: true
type: string
description: 'The docker image which will be loaded'
device:
required: true
type: string
description: 'The device selected to run on'
artifact_name:
required: true
type: string
description: 'The torch_npu distribution artifact name'

# Bash shells do not use ~/.profile or ~/.bashrc so these shells need to be explicitly
# declared as "shell: bash -el {0}" on steps that need to be properly activated.
# It's used to activate ascend-toolkit environment variables.
defaults:
run:
shell: bash -el {0}

jobs:
test:
name: test torch_npu in ${{ inputs.image }} with ${{ inputs.device }}
runs-on: ${{ inputs.runner }}
container:
image: ${{ inputs.image }}
volumes:
- /usr/local/dcmi:/usr/local/dcmi
- /usr/local/bin/npu-smi:/usr/local/bin/npu-smi
- /usr/local/Ascend/driver/lib64/:/usr/local/Ascend/driver/lib64/
- /usr/local/Ascend/driver/version.info:/usr/local/Ascend/driver/version.info
- /etc/ascend_install.info:/etc/ascend_install.info
options: >-
--network host
--device ${{ inputs.device }}
--device /dev/davinci_manager
--device /dev/devmm_svm
--device /dev/hisi_hdc
steps:
- name: Show NPU info
run: |
npu-smi info

- name: Install system dependencies
run: |
sed -i 's|ports.ubuntu.com|mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
apt update
apt install --no-install-recommends -y git gcc g++ make cmake ninja-build

- name: Checkout
uses: actions/checkout@v4

- name: Checkout torch_npu
uses: actions/checkout@v4
with:
# TODO(shink): Use Ascend/pytorch once this pr merged:
# https://gitee.com/ascend/pytorch/pulls/12854
# repository: Ascend/pytorch
repository: shink/torchnpu
ref: feat/autoload
submodules: recursive
path: torch_npu

- name: Download distribution artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: torch_npu

- name: Install pip dependencies
working-directory: torch_npu
run: |
pip install wheel unittest-xml-reporting
pip install -r requirements.txt
pip install -r test/requirements.txt --no-deps

- name: Install torch_npu
working-directory: torch_npu
run: |
pip install ${{ inputs.artifact_name }}

# TODO(shink): Skip
- name: Do the test
continue-on-error: true
run: |
python torch_npu/ci/access_control_test.py
Loading
Loading