Repository navigation
368 lines (320 loc) · 18.7 KB
/
Copy pathcpu-tests.yml
File metadata and controls
368 lines (320 loc) · 18.7 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# Copyright 2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file defines a module for running tests against the built tunix package.
name: Run Tests Against Tunix Package
on:
workflow_call:
inputs:
wheel_artifact_name:
description: 'Artifact name containing the built Tunix wheel'
required: false
default: 'tunix-wheel'
type: string
wheel_only:
description: 'Test strictly against the installed wheel in site-packages by removing ./tunix'
required: false
default: false
type: boolean
permissions:
contents: read
env:
JAX_COMPILATION_CACHE_DIR: /tmp/jax_compilation_cache
JAX_PERSISTENT_CACHE_MIN_COMPILE_TIME_SECS: "0"
jobs:
run_core_shard:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
shard:
- agentic_and_utils
- rl
- sft_and_distill
- models
- dist_rl
- experimental
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.12'
- name: Cache uv
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.cache/uv
key: uv-cpu-core-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements/**/*.txt', 'requirements*.txt', 'constraints*.txt') }}
restore-keys: |
uv-cpu-core-${{ runner.os }}-
- name: Cache JAX compilation
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: /tmp/jax_compilation_cache
key: jax-cache-cpu-core-${{ matrix.shard }}-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements/**/*.txt', 'requirements*.txt') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
jax-cache-cpu-core-${{ matrix.shard }}-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements/**/*.txt', 'requirements*.txt') }}-
jax-cache-cpu-core-${{ matrix.shard }}-${{ runner.os }}-
jax-cache-cpu-core-${{ runner.os }}-
- name: Download the tunix wheel
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: ${{ inputs.wheel_artifact_name }}
- name: Install the tunix wheel
if: ${{ !inputs.wheel_only }}
run: |
python -m pip install -q uv
uv pip install --system --find-links=. --reinstall-package google-tunix "google-tunix[prod,test,experimental]"
python -c "import pathlib, shutil, sysconfig; root = pathlib.Path(sysconfig.get_paths()['platlib']) / 'tunix'; exts = {ext: list(root.glob(f'{ext}*.so')) for ext in ('dist_rl/worker/_compression_ext', 'rl/_packing_ext', 'utils/_trajectory_logger_ext')}; assert all(exts.values()), f'Missing nanobind extensions in {root}: {exts}'; [shutil.copy2(p, pathlib.Path('tunix') / p.relative_to(root)) for paths in exts.values() for p in paths]"
# Wheel-only mode installs the prebuilt wheel (never the sdist that may sit
# next to it in the artifact) and deletes ./tunix so that every
# `import tunix.*` resolves to site-packages.
- name: Install the tunix wheel and remove ./tunix (wheel-only mode)
if: ${{ inputs.wheel_only }}
env:
COMPILE_PROTOS: ${{ matrix.shard == 'dist_rl' || matrix.shard == 'experimental' }}
run: |
python -m pip install -q uv
WHEEL=$(ls -1 ./google_tunix-*.whl | head -n1)
[ -n "$WHEEL" ] || { echo "No google_tunix-*.whl found in the artifact"; exit 1; }
uv pip install --system "${WHEEL}[prod,test,experimental]"
rm -rf tunix
PLATLIB=$(python -c "import sysconfig; print(sysconfig.get_paths()['platlib'])")
if [ "$COMPILE_PROTOS" = "true" ]; then
# Compile the .proto sources shipped in the wheel, not the checkout's.
PROTOS=$(find "$PLATLIB/tunix/dist_rl/distributed" -name "*.proto")
[ -n "$PROTOS" ] || { echo "No .proto files found in $PLATLIB/tunix/dist_rl/distributed"; exit 1; }
find "$PLATLIB/tunix/dist_rl/distributed" -name "*.proto" -exec \
python -m grpc_tools.protoc -I"$PLATLIB" --python_out="$PLATLIB" --grpc_python_out="$PLATLIB" {} +
fi
python -c "import pathlib, sysconfig; root = pathlib.Path(sysconfig.get_paths()['platlib']) / 'tunix'; exts = {ext: list(root.glob(f'{ext}*.abi3.so')) for ext in ('dist_rl/worker/_compression_ext', 'rl/_packing_ext', 'utils/_trajectory_logger_ext')}; assert all(exts.values()), f'Missing nanobind extensions in {root}: {exts}'"
- name: Verify Tunix imports from installed package
env:
WHEEL_ONLY: ${{ inputs.wheel_only }}
run: |
python3 -c "
import os
import pathlib
import sysconfig
import tunix
import tunix.models
import tunix.generate
import tunix.sft
import tunix.distillation
import tunix.rl
from tunix.dist_rl.worker import _compression_ext
from tunix.rl import _packing_ext
from tunix.utils import _trajectory_logger_ext
assert tunix.__version__ != '0.0.0.dev0', 'Tunix version not set correctly'
if os.environ['WHEEL_ONLY'] == 'true':
platlib = pathlib.Path(sysconfig.get_paths()['platlib']).resolve()
tunix_file = pathlib.Path(tunix.__file__).resolve()
assert tunix_file.is_relative_to(platlib), f'tunix resolved outside site-packages ({platlib}): {tunix_file}'
print('All tunix modules imported successfully and version is', tunix.__version__)
"
- name: Run agentic RL tests
if: ${{ matrix.shard == 'agentic_and_utils' }}
run: |
python -m pytest tests/rl/agentic/ -n auto --dist load -v --tb=short
- name: Run Cli utils tests
if: ${{ matrix.shard == 'agentic_and_utils' }}
run: |
python -m pytest tests/cli/utils/ -v --tb=short
- name: Run shared mesh, topology, and OSS utility tests
if: ${{ matrix.shard == 'agentic_and_utils' }}
run: |
python -m pytest tests/utils/mesh_test.py tests/utils/topology_test.py tests/tests/test_common_test.py -v --tb=short
- name: Run perf tests
if: ${{ matrix.shard == 'agentic_and_utils' }}
run: |
python -m pytest tests/perf/ -v --tb=short
- name: Run CPU generate and core utility tests
if: ${{ matrix.shard == 'agentic_and_utils' }}
run: |
python -m pytest tests/generate/beam_search_test.py tests/generate/mappings_config_test.py tests/common/ tests/diffusion/ tests/examples/ tests/processors/ tests/tests/ tests/utils/ --ignore=tests/utils/mesh_test.py --ignore=tests/utils/topology_test.py --ignore=tests/tests/test_common_test.py -n auto --dist loadscope -v --tb=short
XLA_FLAGS="--xla_force_host_platform_device_count=4" python -m pytest tests/generate/utils_test.py -n auto --dist loadscope -v --tb=short
- name: Run SFT and distillation unit tests
if: ${{ matrix.shard == 'sft_and_distill' }}
env:
XLA_FLAGS: "--xla_force_host_platform_device_count=4"
run: |
python -m pytest tests/sft/ tests/distillation/ -n auto --dist loadscope -v --tb=short
- name: Run RL unit tests
if: ${{ matrix.shard == 'rl' }}
run: |
python -m pytest tests/rl/ -n auto --dist loadscope -v --tb=short -k "not test_grpo_with_lora_model" --ignore=tests/rl/agentic --ignore=tests/rl/rl_cluster_test.py
python -m pytest tests/rl/rl_cluster_test.py -n auto --dist loadscope -v --tb=short -k "not vllm and not sglang_jax"
- name: Run model tests
if: ${{ matrix.shard == 'models' }}
run: |
# Cap at -n 2 to stay within the 16 GB runner RAM budget (~14 GB peak RSS vs ~21.8 GB at -n 4).
python -m pytest tests/models/ -n 2 --dist loadscope -v --tb=short \
--ignore=tests/models/naming_test.py \
--ignore=tests/models/paged_attention_test.py
python -m pytest tests/models/paged_attention_test.py -n 2 --dist load -v --tb=short
- name: Compile gRPC Protobuf definitions
if: ${{ !inputs.wheel_only && (matrix.shard == 'dist_rl' || matrix.shard == 'experimental') }}
run: |
find tunix/dist_rl/distributed -name "*.proto" -exec \
python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. {} +
- name: Run dist_rl tests
if: ${{ matrix.shard == 'dist_rl' }}
run: |
# TODO(tunix-dev): add back raiden tests after tpu_sync lib is ready.
python -m pytest tests/dist_rl/ -n auto --dist loadscope -v --tb=short \
--ignore-glob='*/raiden_*.py' \
--ignore=tests/dist_rl/rollout/vllm_sampler_test.py \
--ignore=tests/dist_rl/weight_sync/weight_sync_test.py
- name: Run experimental tests
if: ${{ matrix.shard == 'experimental' }}
run: |
python -m pytest tests/experimental/ -n auto --dist loadscope -v --tb=short \
--ignore-glob='*/raiden_*.py'
run_core:
needs: [run_core_shard]
if: ${{ always() }}
runs-on: ubuntu-24.04
steps:
- name: Check core test shards
env:
SHARDS_RESULT: ${{ needs.run_core_shard.result }}
run: |
if [[ "$SHARDS_RESULT" != "success" ]]; then
echo "Core test shards failed (result=$SHARDS_RESULT)."
exit 1
fi
run_vllm:
runs-on: ubuntu-24.04
container:
image: vllm/vllm-tpu:nightly-20261110-02e570d-52e8596 # zizmor: ignore[unpinned-images]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Download the tunix wheel
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: ${{ inputs.wheel_artifact_name }}
- name: Freeze container dependency overrides
run: |
rm -f /etc/pip.conf /root/.config/pip/pip.conf /opt/venv/pip.conf ~/.pip/pip.conf || true
# Preserve the container's co-versioned JAX/vLLM/Tokamax stack (including container-only .dev builds)
# instead of plain `pip install`, which downgrades preinstalled wheels when resolving Tunix deps.
# TODO(b/584829765): Deduplicate container-overrides setup into a shared action/script and
# revisit `--override` if vllm/vllm-tpu stops shipping unpublished .dev wheels.
python3 -m pip install -q uv
uv pip freeze --python "$(which python3)" \
| grep -E '^(jax|jaxlib|libtpu|tokamax|flax|safetensors|transformers|huggingface-hub|torch|torchvision|torchax|numba)==' \
> /tmp/container-overrides.txt || [ "$?" -eq 1 ]
- name: Install the tunix wheel
if: ${{ !inputs.wheel_only }}
run: |
# `--override` forces uv to keep the frozen container versions even if package bounds differ.
uv pip install --system --break-system-packages --find-links=. --override /tmp/container-overrides.txt "google-tunix[test,experimental]"
# Copy compiled nanobind .so extensions from the wheel into `./tunix` so pytest finds them via source-tree imports.
python3 -c "import pathlib, shutil, sysconfig; root = pathlib.Path(sysconfig.get_paths()['platlib']) / 'tunix'; exts = {ext: list(root.glob(f'{ext}*.so')) for ext in ('dist_rl/worker/_compression_ext', 'rl/_packing_ext', 'utils/_trajectory_logger_ext')}; assert all(exts.values()), f'Missing nanobind extensions in {root}: {exts}'; [shutil.copy2(p, pathlib.Path('tunix') / p.relative_to(root)) for paths in exts.values() for p in paths]"
# tpu-inference/Numba needs NumPy 2.3 or less.
uv pip install --system --break-system-packages --force-reinstall numpy==2.3.5
- name: Install the tunix wheel and remove ./tunix (wheel-only mode)
if: ${{ inputs.wheel_only }}
run: |
WHEEL=$(ls -1 ./google_tunix-*.whl | head -n1)
[ -n "$WHEEL" ] || { echo "No google_tunix-*.whl found in the artifact"; exit 1; }
# `--override` forces uv to keep the frozen container versions even if package bounds differ.
uv pip install --system --break-system-packages --override /tmp/container-overrides.txt "${WHEEL}[test,experimental]"
python3 -c "import pathlib, sysconfig; root = pathlib.Path(sysconfig.get_paths()['platlib']) / 'tunix'; exts = {ext: list(root.glob(f'{ext}*.abi3.so')) for ext in ('dist_rl/worker/_compression_ext', 'rl/_packing_ext', 'utils/_trajectory_logger_ext')}; assert all(exts.values()), f'Missing nanobind extensions in {root}: {exts}'"
# tpu-inference/Numba needs NumPy 2.3 or less.
uv pip install --system --break-system-packages --force-reinstall numpy==2.3.5
rm -rf tunix
- name: Run vllm driver tests
run: |
python3 -m pytest tests/generate/vllm_driver_test.py -v --tb=short
- name: Run vllm rollout experimental tests
run: |
python3 -m pytest tests/dist_rl/rollout/vllm_sampler_test.py -v --tb=short
- name: Run vllm sampler and rl_cluster unit tests
run: |
JAX_PLATFORMS=cpu python3 -m pytest tests/generate/vllm_sampler_test.py::VllmSamplerConfigTest tests/generate/vllm_sampler_test.py::VllmSamplerTokenInputTest -v --tb=short
JAX_PLATFORMS=cpu XLA_FLAGS="--xla_force_host_platform_device_count=4" python3 -m pytest tests/rl/rl_cluster_test.py -k "vllm" -v --tb=short
# ---------------------------------------------------------------------------
# Job: run_dev
# Purpose: Model download, CLI integration, naming, and alignment tests on CPU.
# Hardware: Standard Ubuntu runner.
# Secrets: None (uses public Hugging Face Hub and GCS checkpoints).
# Scope: Smoke model creation, CLI config tests, HF naming, and PyTorch alignment.
# ---------------------------------------------------------------------------
run_dev:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.12'
- name: Cache uv
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.cache/uv
key: uv-cpu-dev-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements/**/*.txt', 'requirements*.txt', 'constraints*.txt') }}
restore-keys: |
uv-cpu-dev-${{ runner.os }}-
- name: Cache JAX compilation
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: /tmp/jax_compilation_cache
key: jax-cache-cpu-dev-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements/**/*.txt', 'requirements*.txt') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
jax-cache-cpu-dev-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements/**/*.txt', 'requirements*.txt') }}-
jax-cache-cpu-dev-${{ runner.os }}-
# Cache Hugging Face hub
- name: Cache HF hub
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
with:
path: ~/.cache/huggingface
key: hf-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'requirements*.txt', 'constraints*.txt') }}
restore-keys: |
hf-${{ runner.os }}-
- name: Download the tunix wheel
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name: ${{ inputs.wheel_artifact_name }}
- name: Install the tunix wheel and dependencies
if: ${{ !inputs.wheel_only }}
run: |
python -m pip install -q uv
uv pip install --system --find-links=. --reinstall-package google-tunix "google-tunix[prod,test,experimental]"
python -c "import pathlib, shutil, sysconfig; root = pathlib.Path(sysconfig.get_paths()['platlib']) / 'tunix'; exts = {ext: list(root.glob(f'{ext}*.so')) for ext in ('dist_rl/worker/_compression_ext', 'rl/_packing_ext', 'utils/_trajectory_logger_ext')}; assert all(exts.values()), f'Missing nanobind extensions in {root}: {exts}'; [shutil.copy2(p, pathlib.Path('tunix') / p.relative_to(root)) for paths in exts.values() for p in paths]"
uv pip install --system --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match --upgrade kagglehub kagglesdk torch
- name: Install the tunix wheel and dependencies, and remove ./tunix (wheel-only mode)
if: ${{ inputs.wheel_only }}
run: |
python -m pip install -q uv
WHEEL=$(ls -1 ./google_tunix-*.whl | head -n1)
[ -n "$WHEEL" ] || { echo "No google_tunix-*.whl found in the artifact"; exit 1; }
uv pip install --system "${WHEEL}[prod,test,experimental]"
python -c "import pathlib, sysconfig; root = pathlib.Path(sysconfig.get_paths()['platlib']) / 'tunix'; exts = {ext: list(root.glob(f'{ext}*.abi3.so')) for ext in ('dist_rl/worker/_compression_ext', 'rl/_packing_ext', 'utils/_trajectory_logger_ext')}; assert all(exts.values()), f'Missing nanobind extensions in {root}: {exts}'"
uv pip install --system --extra-index-url https://download.pytorch.org/whl/cpu --index-strategy unsafe-best-match --upgrade kagglehub kagglesdk torch
rm -rf tunix
- name: Run Smoke tests (model creation)
run: |
echo "Running Smoke tests..."
python -m pytest tests/smoke_tests/model_creation_test.py -v --tb=short
- name: Run tunix cli integration tests
run: |
python -m pytest tests/cli/ -n auto --dist loadscope -v --tb=short \
--ignore=tests/cli/utils/model_test.py
- name: Run tunix model naming tests
run: |
python -m pytest tests/models/naming_test.py -v --tb=short
- name: Run model alignment tests
run: |
JAX_PLATFORMS=cpu python -m pytest tests/model_alignment/ -v --tb=short