-
Notifications
You must be signed in to change notification settings - Fork 109
238 lines (220 loc) · 8.2 KB
/
levanter-tests.yaml
File metadata and controls
238 lines (220 loc) · 8.2 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: Levanter - Tests
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
cpu-unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
jax-version: ["0.8.0"]
defaults:
run:
working-directory: lib/levanter
steps:
- uses: actions/checkout@v4
- name: Install uv and Python
uses: astral-sh/setup-uv@v6
with:
version: "0.7.20"
python-version: ${{ matrix.python-version }}
enable-cache: true
working-directory: lib/levanter
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Set up Python
run: uv python install
- name: Install dependencies
run: uv sync --package levanter --dev --group test --frozen
- name: Test with pytest
run: |
# Test with specific JAX version, excluding TPU tests
PYTHONPATH=tests:src:. uv run --package levanter --frozen --with "jax[cpu]==${{ matrix.jax-version }}" pytest tests -m "not entry and not slow and not ray and not tpu" --durations=20
cpu-ray-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
defaults:
run:
working-directory: lib/levanter
steps:
- uses: actions/checkout@v4
- name: Install uv and Python
uses: astral-sh/setup-uv@v6
with:
version: "0.7.20"
python-version: ${{ matrix.python-version }}
enable-cache: true
working-directory: lib/levanter
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Set up Python
run: uv python install
- name: Install dependencies
run: uv sync --package levanter --dev --group test --frozen
- name: Test with pytest
run: |
PYTHONPATH=tests:src:. uv run --package levanter --frozen pytest tests -m "ray" --durations=20
cpu-entry-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
defaults:
run:
working-directory: lib/levanter
steps:
- uses: actions/checkout@v4
- name: Install uv and Python
uses: astral-sh/setup-uv@v6
with:
version: "0.7.20"
python-version: ${{ matrix.python-version }}
enable-cache: true
working-directory: lib/levanter
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Set up Python
run: uv python install
- name: Install dependencies
run: uv sync --package levanter --dev --group test --frozen
- name: Test with pytest
run: |
PYTHONPATH=tests:src:. uv run --package levanter --frozen pytest tests -m "entry" --durations=20
cpu-torch-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
python-version: ["3.11"]
defaults:
run:
working-directory: lib/levanter
steps:
- uses: actions/checkout@v4
- name: Install uv and Python
uses: astral-sh/setup-uv@v6
with:
version: "0.7.20"
python-version: ${{ matrix.python-version }}
enable-cache: true
working-directory: lib/levanter
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Set up Python
run: uv python install
- name: Install dependencies
run: uv sync --package levanter --dev --group test --frozen --extra torch_test --no-install-package torch
- name: Install locked CPU torch wheel
run: |
TORCH_CPU_VERSION=$(python3 - <<'PY'
import tomllib
from pathlib import Path
lock = tomllib.loads(Path("../../uv.lock").read_text())
versions = {
package["version"]
for package in lock.get("package", [])
if package.get("name") == "torch" and package.get("version", "").endswith("+cpu")
}
if len(versions) != 1:
raise SystemExit(
f"Expected exactly one torch +cpu version in uv.lock, found {len(versions)}: {sorted(versions)}"
)
print(next(iter(versions)))
PY
)
echo "Using torch ${TORCH_CPU_VERSION}"
if [[ -z "$TORCH_CPU_VERSION" ]]; then
echo "Unable to determine torch CPU version from uv.lock" >&2
exit 1
fi
uv pip install "torch==$TORCH_CPU_VERSION" \
--default-index https://download.pytorch.org/whl/cpu \
--index https://pypi.org/simple \
--index-strategy unsafe-best-match
- name: Test torch-marked suite
run: |
# run directly on CPU to avoid GPU dependency issues
CUDA_VISIBLE_DEVICES="" PYTHONPATH=tests:src:. ../../.venv/bin/python -m pytest tests -m "torch" --durations=20
# CUDA_VISIBLE_DEVICES="" PYTHONPATH=tests:src:. uv run --package levanter --frozen --extra torch_test pytest tests -m "torch" --durations=20
tpu-tests:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: [tpu-ci]
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
jax_version: ["0.8.0"]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ (github.event_name == 'pull_request_review' && format('refs/pull/{0}/merge', github.event.pull_request.number)) || '' }}
- name: Run Levanter TPU tests in Docker
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
JAX_VERSION: ${{ matrix.jax_version }}
run: |
bash infra/tpu-ci/clean-tpu.sh
DOCKER_IMAGE="ghcr.io/marin-community/marin/tpu-ci:latest"
echo "Using Docker image: $DOCKER_IMAGE"
# Create UV cache directory
mkdir -p /tmp/uv-cache
chmod 777 /tmp/uv-cache
# Run Levanter tests with specific JAX version
docker run --rm \
--device /dev/vfio:/dev/vfio \
--shm-size=100g \
--stop-timeout=5 \
--cap-add=SYS_RESOURCE \
--ulimit memlock=68719476736:68719476736 \
-e TPU_CI=true \
-e JAX_COORDINATOR_ADDRESS=127.0.0.1 \
-e TPU_STDERR_LOG_LEVEL=3 \
-e TPU_MIN_LOG_LEVEL=3 \
-e PYTHONPATH=/workspace \
-e JAX_PLATFORMS=tpu,cpu \
-e PJRT_DEVICE=TPU \
-e HF_TOKEN \
-e WANDB_API_KEY \
-e WANDB_MODE=offline \
-e UV_CACHE_DIR=/tmp/uv-cache \
-v ${{ github.workspace }}:/workspace-src:ro \
-v /tmp/uv-cache:/tmp/uv-cache:rw \
-w /workspace \
$DOCKER_IMAGE \
bash -c "\
# Install Node.js in userspace if not present (needed for protobuf generation during uv sync)
if ! command -v npx >/dev/null 2>&1; then \
echo '::group::Installing Node.js in userspace'; \
curl -fsSL https://nodejs.org/dist/v22.16.0/node-v22.16.0-linux-x64.tar.xz | tar -xJ -C /tmp && \
export PATH=/tmp/node-v22.16.0-linux-x64/bin:\$PATH; \
echo '::endgroup::'; \
fi && \
cp -a /workspace-src/. /workspace/ && cd /workspace && \
timeout --kill-after=5 --signal=TERM 890 \
uv run --package levanter --frozen --group test --with 'jax[tpu]==$JAX_VERSION' \
pytest lib/levanter/tests \
-m 'not entry and not ray and not slow and not torch' \
--ignore=lib/levanter/tests/test_audio.py \
--ignore=lib/levanter/tests/test_new_cache.py \
--ignore=lib/levanter/tests/test_hf_checkpoints.py \
--ignore=lib/levanter/tests/test_hf_gpt2_serialize.py \
--ignore=lib/levanter/tests/test_gdn_layer.py \
-v --tb=short --log-cli-level=WARNING --durations=20"