Skip to content

Commit 2115483

Browse files
committed
Add PyTorch API tests in CICD
1 parent 5cd1ad9 commit 2115483

2 files changed

Lines changed: 93 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Torch API Tests in Container
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
torch-api-test:
13+
runs-on: self-hosted
14+
container:
15+
image: localhost:5000/flagscale:cuda12.4.1-cudnn9.5.0-python3.12-torch2.6.0-time2505241715
16+
options: --gpus all --privileged --ipc=host --ulimit memlock=-1 --ulimit stack=67108864
17+
steps:
18+
- name: Checkout Code
19+
uses: actions/checkout@v4
20+
with:
21+
repository: ${{ github.event.pull_request.head.repo.full_name }}
22+
ref: ${{ github.event.pull_request.head.ref }}
23+
ssh-strict: true
24+
ssh-user: git
25+
persist-credentials: true
26+
clean: true
27+
sparse-checkout-cone-mode: true
28+
fetch-tags: false
29+
show-progress: true
30+
lfs: false
31+
submodules: false
32+
set-safe-directory: true
33+
34+
- name: Set up Install Dependencies
35+
run: |
36+
source /root/miniconda3/bin/activate flagscale-train
37+
apt update -y
38+
apt-get install -y git rdma-core ibverbs-utils perftest infiniband-diags libibverbs-dev librdmacm-dev
39+
cd /__w/FlagCX/FlagCX
40+
git config --global --add safe.directory /__w/FlagCX/FlagCX
41+
git status
42+
pip install setuptools==77.0.1 pre-commit -i https://pypi.tuna.tsinghua.edu.cn/simple
43+
pre-commit install
44+
45+
- name: Run Code Format Check with pre-commit
46+
run: |
47+
cd /__w/FlagCX/FlagCX
48+
apt update -y
49+
apt-get install clang-format -y
50+
git fetch --all
51+
from_ref=${GITHUB_HEAD_REF}
52+
to_ref=${GITHUB_BASE_REF}
53+
54+
echo "From branch: $from_ref, To branch: $to_ref"
55+
56+
pre-commit run --from-ref "origin/$from_ref" --to-ref "origin/$to_ref"
57+
continue-on-error: false
58+
59+
- name: Run `make` to build the project
60+
run: |
61+
cd /__w/FlagCX/FlagCX
62+
export MPI_HOME=/usr/local/mpi
63+
make USE_NVIDIA=1
64+
65+
- name: Enter plugin/torch and install FlagCX PyTorch Plugin
66+
run: |
67+
cd /__w/FlagCX/FlagCX/plugin/torch
68+
python setup.py develop --adaptor nvidia
69+
70+
- name: Run PyTorch API tests
71+
run: |
72+
cd /__w/FlagCX/FlagCX/test/script/
73+
bash torch_api_test.sh

test/script/torch_api_test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
4+
export FLAGCX_DEBUG=INFO
5+
export FLAGCX_DEBUG_SUBSYS=INIT
6+
7+
echo "[INFO] Launching PyTorch API tests in homogeneous mode"
8+
CMD='torchrun --nproc_per_node 8 --nnodes=1 --node_rank=0 --master_addr="localhost" --master_port=8281 ../../plugin/torch/example/example.py'
9+
echo $CMD
10+
eval $CMD
11+
echo "[INFO] Completed PyTorch API tests in homogeneous mode"
12+
echo "--------------------------------------------------------"
13+
14+
echo "[INFO] Launching PyTorch API tests in heterogeneous mode"
15+
export FLAGCX_CLUSTER_SPLIT_LIST=2
16+
CMD='torchrun --nproc_per_node 8 --nnodes=1 --node_rank=0 --master_addr="localhost" --master_port=8281 ../../plugin/torch/example/example.py'
17+
echo $CMD
18+
eval $CMD
19+
echo "[INFO] Completed PyTorch API tests in heterogeneous mode"
20+
echo "--------------------------------------------------------"

0 commit comments

Comments
 (0)