Skip to content

Commit 5aa9c6c

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

4 files changed

Lines changed: 118 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Run Container and Execute Tests
22

3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
3+
on: none
4+
# push:
5+
# branches:
6+
# - main
7+
# pull_request:
8+
# branches:
9+
# - main
1010

1111
jobs:
1212
test-in-container:
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
export PATH=/root/miniconda3/bin:$PATH
37+
eval "$(/root/miniconda3/bin/conda shell.bash hook)" && conda activate flagscale-train && conda env list
38+
apt update -y && apt-get install -y git rdma-core ibverbs-utils perftest infiniband-diags libibverbs-dev librdmacm-dev clang-format
39+
pip list | grep torch && which python
40+
pip uninstall -y setuptools && pip install setuptools==77.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
41+
pip install pre-commit -i https://pypi.tuna.tsinghua.edu.cn/simple
42+
cd /__w/FlagCX/FlagCX
43+
git config --global --add safe.directory /__w/FlagCX/FlagCX && git status
44+
pre-commit install
45+
46+
- name: Run Code Format Check with pre-commit
47+
run: |
48+
cd /__w/FlagCX/FlagCX
49+
git fetch --all
50+
from_ref=${GITHUB_HEAD_REF}
51+
to_ref=${GITHUB_BASE_REF}
52+
53+
echo "From branch: $from_ref, To branch: $to_ref"
54+
55+
pre-commit run --from-ref "origin/$from_ref" --to-ref "origin/$to_ref"
56+
continue-on-error: false
57+
58+
- name: Run `make` to build the project
59+
run: |
60+
cd /__w/FlagCX/FlagCX
61+
export MPI_HOME=/usr/local/mpi
62+
make USE_NVIDIA=1 -j$(nproc)
63+
64+
- name: Enter plugin/torch and install FlagCX PyTorch Plugin
65+
run: |
66+
cd /__w/FlagCX/FlagCX/plugin/torch
67+
python setup.py develop --adaptor nvidia
68+
69+
- name: Run PyTorch API tests
70+
run: |
71+
cd /__w/FlagCX/FlagCX/test/script/
72+
bash torch_api_test.sh

.github/workflows/unit-test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: Unit Tests in Container
22

3-
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
3+
on: none
4+
# push:
5+
# branches:
6+
# - main
7+
# pull_request:
8+
# branches:
9+
# - main
1010

1111
jobs:
1212
unit-test:

test/script/torch_api_test.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
export CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
5+
export FLAGCX_DEBUG=INFO
6+
export FLAGCX_DEBUG_SUBSYS=INIT
7+
8+
CMD_BASE='torchrun --nproc_per_node 8 --nnodes=1 --node_rank=0 --master_addr="localhost"'
9+
PY_SCRIPT='../../plugin/torch/example/example.py'
10+
11+
echo "[INFO] Launching PyTorch API tests in homogeneous mode"
12+
while true; do
13+
PORT=$(shuf -i 20000-65535 -n 1)
14+
(echo >/dev/tcp/127.0.0.1/$PORT) &>/dev/null || break
15+
done
16+
CMD="$CMD_BASE --master_port=$PORT $PY_SCRIPT"
17+
echo "$CMD"
18+
eval "$CMD"
19+
echo "[INFO] Completed PyTorch API tests in homogeneous mode"
20+
echo "--------------------------------------------------------"
21+
22+
echo "[INFO] Launching PyTorch API tests in heterogeneous mode"
23+
export FLAGCX_CLUSTER_SPLIT_LIST=2
24+
while true; do
25+
PORT=$(shuf -i 20000-65535 -n 1)
26+
(echo >/dev/tcp/127.0.0.1/$PORT) &>/dev/null || break
27+
done
28+
CMD="$CMD_BASE --master_port=$PORT $PY_SCRIPT"
29+
echo "$CMD"
30+
eval "$CMD"
31+
echo "[INFO] Completed PyTorch API tests in heterogeneous mode"
32+
echo "--------------------------------------------------------"

0 commit comments

Comments
 (0)