-
Notifications
You must be signed in to change notification settings - Fork 175
114 lines (101 loc) · 3.89 KB
/
Copy pathunittest.yml
File metadata and controls
114 lines (101 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: GPU Unit Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: gpu-unittest-${{ github.ref }}
cancel-in-progress: true
jobs:
unittest:
name: Unit Tests (H20, 4 GPUs)
runs-on: [self-hosted, linux, x64, h20, gpu]
# Allow 120 minutes for image preparation plus the existing 60-minute test job budget.
timeout-minutes: 180
env:
CI_CONTAINER_NAME: relax-unittest-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Prepare local test image
id: image
uses: ./.github/actions/prepare-image
timeout-minutes: 120
with:
# Include patch targets as well as the symlinks under patch/latest.
hash-key: ${{ hashFiles('docker/Dockerfile', '.dockerignore', 'requirements.txt', 'docker/patch/**', 'relax/backends/megatron/kernels/int4_qat/**', '.github/actions/prepare-image/action.yml') }}
- name: Acquire test devices
id: devices
uses: ./.github/actions/acquire-devices
timeout-minutes: 35
with:
backend: nvidia
count: 4
timeout: 1800
- name: Create test container
env:
CI_IMAGE: ${{ steps.image.outputs.image-id }}
CI_DEVICES: ${{ steps.devices.outputs.devices }}
HOST_UV_CACHE_DIR: /home/relax-ci/.cache/uv
UV_CACHE_DIR: /uv-cache
UV_LINK_MODE: copy
ARTIFACT_DIR: ${{ runner.temp }}/unittest-${{ github.run_id }}-${{ github.run_attempt }}
run: |
set -euo pipefail
mkdir -p "$HOST_UV_CACHE_DIR" "$ARTIFACT_DIR"
# Keep network, IPC and /tmp private for parallel Ray/NCCL tests.
# Create before starting so cancellation during a pull cannot start tests.
docker create --pull never --rm --init \
--name "$CI_CONTAINER_NAME" \
--gpus "\"device=$CI_DEVICES\"" \
--shm-size=32g \
-v "$GITHUB_WORKSPACE:/source:ro" \
-v "$ARTIFACT_DIR:/artifacts" \
-v "$HOST_UV_CACHE_DIR:$UV_CACHE_DIR" \
--workdir /workspace/Relax \
--env UV_CACHE_DIR \
--env UV_LINK_MODE \
--env http_proxy \
--env https_proxy \
--env no_proxy \
--entrypoint /bin/bash "$CI_IMAGE" -c 'sleep infinity'
docker inspect --format 'Test image: {{.Config.Image}} ({{.Image}})' "$CI_CONTAINER_NAME"
docker start "$CI_CONTAINER_NAME"
- name: Prepare workspace and show GPUs
run: |
docker exec "$CI_CONTAINER_NAME" bash -euc '
cp -a --no-preserve=ownership /source/. /workspace/Relax/
nvidia-smi
'
- name: Install dependencies
run: |
docker exec "$CI_CONTAINER_NAME" uv pip install \
--system --break-system-packages -r requirements.txt \
--extra-index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
- name: Run unittest
timeout-minutes: 10
run: |
docker exec "$CI_CONTAINER_NAME" bash -euo pipefail -c '
python -m pytest tests/ -v -ra --tb=short --junitxml=/artifacts/junit.xml \
2>&1 | tee /artifacts/pytest.log
'
- name: Remove test container
if: always()
run: |
if docker inspect "$CI_CONTAINER_NAME" >/dev/null 2>&1; then
docker rm --force "$CI_CONTAINER_NAME"
fi
- name: Upload test results
if: always()
uses: actions/upload-artifact@v7
with:
name: unittest-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ runner.temp }}/unittest-${{ github.run_id }}-${{ github.run_attempt }}/
if-no-files-found: warn
retention-days: 14