Skip to content

Commit a8092e9

Browse files
committed
Add PyTorch API tests in CICD
1 parent 09529b7 commit a8092e9

2 files changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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.8.1-cudnn9.7.1-python3.12-torch2.7.0-time2507111538
16+
#localhost:5000/flagscale:cuda12.4.1-cudnn9.5.0-python3.12-torch2.6.0-time2505241715
17+
options: --gpus all --shm-size=500g --privileged --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 --ulimit nofile=65535:65535 --user root
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v4
21+
with:
22+
repository: ${{ github.event.pull_request.head.repo.full_name }}
23+
ref: ${{ github.event.pull_request.head.ref }}
24+
ssh-strict: true
25+
ssh-user: git
26+
persist-credentials: true
27+
clean: true
28+
sparse-checkout-cone-mode: true
29+
fetch-tags: false
30+
show-progress: true
31+
lfs: false
32+
submodules: false
33+
set-safe-directory: true
34+
35+
- name: Set up Install Dependencies
36+
run: |
37+
export PATH=/root/miniconda3/bin:$PATH
38+
eval "$(/root/miniconda3/bin/conda shell.bash hook)" && conda activate flagscale-train && conda env list
39+
apt update -y && apt-get install -y git rdma-core ibverbs-utils perftest infiniband-diags libibverbs-dev librdmacm-dev clang-format
40+
pip list | grep torch && which python
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: Install FlagCX PyTorch Plugin
65+
run: |
66+
export PATH=/root/miniconda3/bin:$PATH
67+
eval "$(/root/miniconda3/bin/conda shell.bash hook)" && conda activate flagscale-train && conda env list
68+
pip uninstall -y setuptools && pip install setuptools==77.0.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
69+
cd /__w/FlagCX/FlagCX/plugin/torch
70+
python setup.py develop --adaptor nvidia
71+
72+
- name: Run PyTorch API Tests
73+
run: |
74+
export PATH=/root/miniconda3/bin:$PATH
75+
eval "$(/root/miniconda3/bin/conda shell.bash hook)" && conda activate flagscale-train && conda env list
76+
cd /__w/FlagCX/FlagCX/test/script/
77+
export FLAGCX_DEBUG=TRACE
78+
export FLAGCX_DEBUG_SUBSYS=ALL
79+
bash torch_api_test.sh

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)