Skip to content

Commit 2a00868

Browse files
committed
formate
1 parent 570b9e8 commit 2a00868

24 files changed

+757
-1407
lines changed

.github/workflows/pr-test.yml

Lines changed: 84 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262

6363
steps:
6464
- name: Checkout repository
65-
uses: actions/checkout@v6
65+
uses: actions/checkout@v4
6666

6767
- name: Install
6868
shell: bash
@@ -118,7 +118,7 @@ jobs:
118118

119119
steps:
120120
- name: Checkout repository
121-
uses: actions/checkout@v6
121+
uses: actions/checkout@v4
122122

123123
- name: Install
124124
shell: bash
@@ -174,7 +174,7 @@ jobs:
174174

175175
steps:
176176
- name: Checkout repository
177-
uses: actions/checkout@v6
177+
uses: actions/checkout@v4
178178

179179
- name: Install
180180
shell: bash
@@ -187,7 +187,11 @@ jobs:
187187
if [[ "$TEST_PATH" != tests/* ]]; then
188188
TEST_PATH="tests/$TEST_PATH"
189189
fi
190-
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
190+
if [ "${{ matrix.info.num_gpus }}" = "0" ]; then
191+
python "$TEST_PATH"
192+
else
193+
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
194+
fi
191195
192196
e2e-test-precision:
193197
if: (github.event_name == 'workflow_dispatch') || (github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'run-ci-precision'))
@@ -226,7 +230,7 @@ jobs:
226230

227231
steps:
228232
- name: Checkout repository
229-
uses: actions/checkout@v6
233+
uses: actions/checkout@v4
230234

231235
- name: Install
232236
shell: bash
@@ -239,7 +243,11 @@ jobs:
239243
if [[ "$TEST_PATH" != tests/* ]]; then
240244
TEST_PATH="tests/$TEST_PATH"
241245
fi
242-
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
246+
if [ "${{ matrix.info.num_gpus }}" = "0" ]; then
247+
python "$TEST_PATH"
248+
else
249+
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
250+
fi
243251
244252
e2e-test-ckpt:
245253
if: (github.event_name == 'workflow_dispatch') || (github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'run-ci-ckpt'))
@@ -278,7 +286,7 @@ jobs:
278286

279287
steps:
280288
- name: Checkout repository
281-
uses: actions/checkout@v6
289+
uses: actions/checkout@v4
282290

283291
- name: Install
284292
shell: bash
@@ -291,7 +299,67 @@ jobs:
291299
if [[ "$TEST_PATH" != tests/* ]]; then
292300
TEST_PATH="tests/$TEST_PATH"
293301
fi
294-
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
302+
if [ "${{ matrix.info.num_gpus }}" = "0" ]; then
303+
python "$TEST_PATH"
304+
else
305+
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
306+
fi
307+
308+
e2e-test-plugin-contracts:
309+
if: (github.event_name == 'workflow_dispatch') || (github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'run-ci-plugin-contracts'))
310+
runs-on: self-hosted
311+
container:
312+
image: slimerl/slime:latest
313+
options: >
314+
--gpus all
315+
--ipc=host
316+
--shm-size=16g
317+
--ulimit memlock=-1
318+
--ulimit stack=67108864
319+
--memory=0
320+
--memory-swap=0
321+
-e http_proxy=$http_proxy
322+
-e https_proxy=$https_proxy
323+
-e HTTP_PROXY=$HTTP_PROXY
324+
-e HTTPS_PROXY=$HTTPS_PROXY
325+
-v /mnt/nvme0n1/slime_ci:/data/slime_ci
326+
-v /mnt/nvme0n1/slime_ci/models:/root/models
327+
-v /mnt/nvme0n1/slime_ci/datasets:/root/datasets
328+
strategy:
329+
fail-fast: false
330+
matrix:
331+
info: [{"num_gpus": 0, "test_file": "plugin_contracts/test_plugin_rollout_contracts.py"}, {"num_gpus": 0, "test_file": "plugin_contracts/test_plugin_runtime_hook_contracts.py"}, {"num_gpus": 0, "test_file": "plugin_contracts/test_plugin_path_loading_contracts.py"}, {"num_gpus": 0, "test_file": "plugin_contracts/test_plugin_generate_contracts.py"}]
332+
defaults:
333+
run:
334+
working-directory: ${{ github.workspace }}
335+
env:
336+
GITHUB_COMMIT_NAME: ${{ github.sha }}_${{ github.event.pull_request.number || 'non-pr' }}
337+
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
338+
SLIME_TEST_ENABLE_INFINITE_RUN: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.infinite_run) || 'false' }}
339+
SLIME_TEST_USE_DEEPEP: ${{ matrix.info.use_deepep || '0' }}
340+
SLIME_TEST_USE_FP8_ROLLOUT: ${{ matrix.info.use_fp8_rollout || '0' }}
341+
SLIME_TEST_ENABLE_EVAL: ${{ matrix.info.enable_eval || '1' }}
342+
343+
steps:
344+
- name: Checkout repository
345+
uses: actions/checkout@v4
346+
347+
- name: Install
348+
shell: bash
349+
run: cd $GITHUB_WORKSPACE && pip install -e . --no-deps --break-system-packages
350+
351+
- name: Execute
352+
shell: bash
353+
run: |
354+
TEST_PATH="${{ matrix.info.test_file }}"
355+
if [[ "$TEST_PATH" != tests/* ]]; then
356+
TEST_PATH="tests/$TEST_PATH"
357+
fi
358+
if [ "${{ matrix.info.num_gpus }}" = "0" ]; then
359+
python "$TEST_PATH"
360+
else
361+
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
362+
fi
295363
296364
e2e-test-image:
297365
if: (github.event_name == 'workflow_dispatch') || (github.event.pull_request && contains(github.event.pull_request.labels.*.name, 'run-ci-image'))
@@ -330,7 +398,7 @@ jobs:
330398

331399
steps:
332400
- name: Checkout repository
333-
uses: actions/checkout@v6
401+
uses: actions/checkout@v4
334402

335403
- name: Install
336404
shell: bash
@@ -343,7 +411,11 @@ jobs:
343411
if [[ "$TEST_PATH" != tests/* ]]; then
344412
TEST_PATH="tests/$TEST_PATH"
345413
fi
346-
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
414+
if [ "${{ matrix.info.num_gpus }}" = "0" ]; then
415+
python "$TEST_PATH"
416+
else
417+
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
418+
fi
347419
348420
349421
e2e-test-changed-detect:
@@ -432,7 +504,7 @@ jobs:
432504

433505
steps:
434506
- name: Checkout repository
435-
uses: actions/checkout@v6
507+
uses: actions/checkout@v4
436508

437509
- name: Install
438510
shell: bash
@@ -449,4 +521,4 @@ jobs:
449521
python "$TEST_PATH"
450522
else
451523
python tests/ci/gpu_lock_exec.py --count ${{ matrix.info.num_gpus }} -- python "$TEST_PATH"
452-
fi
524+
fi

.github/workflows/pr-test.yml.j2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@
4747
],
4848
},
4949

50+
'e2e-test-plugin-contracts': {
51+
'label': 'run-ci-plugin-contracts',
52+
'tests': [
53+
{'test_file': 'plugin_contracts/test_plugin_rollout_contracts.py', 'num_gpus': 0},
54+
{'test_file': 'plugin_contracts/test_plugin_runtime_hook_contracts.py', 'num_gpus': 0},
55+
{'test_file': 'plugin_contracts/test_plugin_path_loading_contracts.py', 'num_gpus': 0},
56+
{'test_file': 'plugin_contracts/test_plugin_generate_contracts.py', 'num_gpus': 0},
57+
],
58+
},
59+
5060
'e2e-test-image': {
5161
'label': 'run-ci-image',
5262
'image': 'slimerl/slime-test:latest',

docs/en/developer_guide/ci.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,9 @@ For CPU-only contract tests that validate hooks loaded from function paths, run:
115115
```bash
116116
python -m pytest \
117117
tests/plugin_contracts/test_plugin_rollout_contracts.py \
118-
tests/plugin_contracts/test_plugin_eval_function_contracts.py \
119118
tests/plugin_contracts/test_plugin_generate_contracts.py \
120-
tests/plugin_contracts/test_plugin_custom_rm_contracts.py \
121-
tests/plugin_contracts/test_plugin_dynamic_filter_contracts.py \
122-
tests/plugin_contracts/test_plugin_buffer_filter_contracts.py \
123-
tests/plugin_contracts/test_plugin_data_source_contracts.py \
124-
tests/plugin_contracts/test_plugin_custom_rollout_log_contracts.py \
125-
tests/plugin_contracts/test_plugin_custom_eval_rollout_log_contracts.py \
126-
tests/plugin_contracts/test_plugin_custom_reward_post_process_contracts.py \
127-
tests/plugin_contracts/test_plugin_custom_convert_samples_to_train_data_contracts.py \
128-
tests/plugin_contracts/test_plugin_rollout_sample_filter_contracts.py \
129-
tests/plugin_contracts/test_plugin_rollout_all_samples_process_contracts.py \
130-
tests/plugin_contracts/test_plugin_rollout_data_postprocess_contracts.py
119+
tests/plugin_contracts/test_plugin_path_loading_contracts.py \
120+
tests/plugin_contracts/test_plugin_runtime_hook_contracts.py
131121
```
132122

133123
These files also support direct execution as `python tests/plugin_contracts/<file>.py`. They declare `NUM_GPUS = 0`, so `run-ci-changed` can pick them up without treating them as GPU-heavy end-to-end tests.

docs/en/get_started/customization.md

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -426,41 +426,25 @@ For detailed explanation of R3 and SlimeRouter, see [Slime Router](../advanced/s
426426

427427
slime also provides CPU-only contract tests for customization interfaces. These tests resolve components through import-path strings, so they can validate both built-in hooks and user-defined implementations passed through the same CLI arguments used by training.
428428

429-
The tests live under `tests/plugin_contracts/`, with one file per customization argument:
430-
431-
- `--rollout-function-path` -> `tests/plugin_contracts/test_plugin_rollout_contracts.py`
432-
- `--eval-function-path` -> `tests/plugin_contracts/test_plugin_eval_function_contracts.py`
433-
- `--custom-generate-function-path` -> `tests/plugin_contracts/test_plugin_generate_contracts.py`
434-
- `--custom-rm-path` -> `tests/plugin_contracts/test_plugin_custom_rm_contracts.py`
435-
- `--dynamic-sampling-filter-path` -> `tests/plugin_contracts/test_plugin_dynamic_filter_contracts.py`
436-
- `--buffer-filter-path` -> `tests/plugin_contracts/test_plugin_buffer_filter_contracts.py`
437-
- `--data-source-path` -> `tests/plugin_contracts/test_plugin_data_source_contracts.py`
438-
- `--custom-rollout-log-function-path` -> `tests/plugin_contracts/test_plugin_custom_rollout_log_contracts.py`
439-
- `--custom-eval-rollout-log-function-path` -> `tests/plugin_contracts/test_plugin_custom_eval_rollout_log_contracts.py`
440-
- `--custom-reward-post-process-path` -> `tests/plugin_contracts/test_plugin_custom_reward_post_process_contracts.py`
441-
- `--custom-convert-samples-to-train-data-path` -> `tests/plugin_contracts/test_plugin_custom_convert_samples_to_train_data_contracts.py`
442-
- `--rollout-sample-filter-path` -> `tests/plugin_contracts/test_plugin_rollout_sample_filter_contracts.py`
443-
- `--rollout-all-samples-process-path` -> `tests/plugin_contracts/test_plugin_rollout_all_samples_process_contracts.py`
444-
- `--rollout-data-postprocess-path` -> `tests/plugin_contracts/test_plugin_rollout_data_postprocess_contracts.py`
429+
The tests live under `tests/plugin_contracts/` and are grouped by hook shape:
430+
431+
- `tests/plugin_contracts/test_plugin_rollout_contracts.py`
432+
Covers `--rollout-function-path`
433+
- `tests/plugin_contracts/test_plugin_generate_contracts.py`
434+
Covers `--custom-generate-function-path`
435+
- `tests/plugin_contracts/test_plugin_path_loading_contracts.py`
436+
Covers `--eval-function-path`, `--custom-rm-path`, `--dynamic-sampling-filter-path`, `--buffer-filter-path`, `--data-source-path`, `--rollout-sample-filter-path`, and `--rollout-all-samples-process-path`
437+
- `tests/plugin_contracts/test_plugin_runtime_hook_contracts.py`
438+
Covers `--custom-rollout-log-function-path`, `--custom-eval-rollout-log-function-path`, `--custom-reward-post-process-path`, `--custom-convert-samples-to-train-data-path`, and `--rollout-data-postprocess-path`
445439

446440
Run all customization contract tests locally:
447441

448442
```bash
449443
python -m pytest \
450444
tests/plugin_contracts/test_plugin_rollout_contracts.py \
451-
tests/plugin_contracts/test_plugin_eval_function_contracts.py \
452445
tests/plugin_contracts/test_plugin_generate_contracts.py \
453-
tests/plugin_contracts/test_plugin_custom_rm_contracts.py \
454-
tests/plugin_contracts/test_plugin_dynamic_filter_contracts.py \
455-
tests/plugin_contracts/test_plugin_buffer_filter_contracts.py \
456-
tests/plugin_contracts/test_plugin_data_source_contracts.py \
457-
tests/plugin_contracts/test_plugin_custom_rollout_log_contracts.py \
458-
tests/plugin_contracts/test_plugin_custom_eval_rollout_log_contracts.py \
459-
tests/plugin_contracts/test_plugin_custom_reward_post_process_contracts.py \
460-
tests/plugin_contracts/test_plugin_custom_convert_samples_to_train_data_contracts.py \
461-
tests/plugin_contracts/test_plugin_rollout_sample_filter_contracts.py \
462-
tests/plugin_contracts/test_plugin_rollout_all_samples_process_contracts.py \
463-
tests/plugin_contracts/test_plugin_rollout_data_postprocess_contracts.py
446+
tests/plugin_contracts/test_plugin_path_loading_contracts.py \
447+
tests/plugin_contracts/test_plugin_runtime_hook_contracts.py
464448
```
465449

466450
Each test file can also be executed directly with `python tests/plugin_contracts/<file>.py`, which keeps them compatible with `run-ci-changed`.

docs/zh/developer_guide/ci.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,9 @@ cd .github/workflows && python generate_github_workflows.py
115115
```bash
116116
python -m pytest \
117117
tests/plugin_contracts/test_plugin_rollout_contracts.py \
118-
tests/plugin_contracts/test_plugin_eval_function_contracts.py \
119118
tests/plugin_contracts/test_plugin_generate_contracts.py \
120-
tests/plugin_contracts/test_plugin_custom_rm_contracts.py \
121-
tests/plugin_contracts/test_plugin_dynamic_filter_contracts.py \
122-
tests/plugin_contracts/test_plugin_buffer_filter_contracts.py \
123-
tests/plugin_contracts/test_plugin_data_source_contracts.py \
124-
tests/plugin_contracts/test_plugin_custom_rollout_log_contracts.py \
125-
tests/plugin_contracts/test_plugin_custom_eval_rollout_log_contracts.py \
126-
tests/plugin_contracts/test_plugin_custom_reward_post_process_contracts.py \
127-
tests/plugin_contracts/test_plugin_custom_convert_samples_to_train_data_contracts.py \
128-
tests/plugin_contracts/test_plugin_rollout_sample_filter_contracts.py \
129-
tests/plugin_contracts/test_plugin_rollout_all_samples_process_contracts.py \
130-
tests/plugin_contracts/test_plugin_rollout_data_postprocess_contracts.py
119+
tests/plugin_contracts/test_plugin_path_loading_contracts.py \
120+
tests/plugin_contracts/test_plugin_runtime_hook_contracts.py
131121
```
132122

133123
这些测试文件也支持直接执行 `python tests/plugin_contracts/<file>.py`。它们声明了 `NUM_GPUS = 0`,因此可以被 `run-ci-changed` 自动识别,同时不会被当作 GPU 重型端到端测试。

docs/zh/get_started/customization.md

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -428,41 +428,26 @@ def custom_hook(args, rollout_id, step_id, model, optimizer, opt_param_scheduler
428428

429429
slime 现在也提供了一组 CPU 契约测试,用于校验这些 customization 接口。测试会通过字符串形式的导入路径来动态加载组件,因此既能回归仓库内置 hook,也能验证用户通过和训练时完全相同的 CLI 参数传入的自定义实现。
430430

431-
这些测试统一放在 `tests/plugin_contracts/` 目录下,并且保持“一条 customization 参数对应一个测试文件”:
432-
433-
- `--rollout-function-path` -> `tests/plugin_contracts/test_plugin_rollout_contracts.py`
434-
- `--eval-function-path` -> `tests/plugin_contracts/test_plugin_eval_function_contracts.py`
435-
- `--custom-generate-function-path` -> `tests/plugin_contracts/test_plugin_generate_contracts.py`
436-
- `--custom-rm-path` -> `tests/plugin_contracts/test_plugin_custom_rm_contracts.py`
437-
- `--dynamic-sampling-filter-path` -> `tests/plugin_contracts/test_plugin_dynamic_filter_contracts.py`
438-
- `--buffer-filter-path` -> `tests/plugin_contracts/test_plugin_buffer_filter_contracts.py`
439-
- `--data-source-path` -> `tests/plugin_contracts/test_plugin_data_source_contracts.py`
440-
- `--custom-rollout-log-function-path` -> `tests/plugin_contracts/test_plugin_custom_rollout_log_contracts.py`
441-
- `--custom-eval-rollout-log-function-path` -> `tests/plugin_contracts/test_plugin_custom_eval_rollout_log_contracts.py`
442-
- `--custom-reward-post-process-path` -> `tests/plugin_contracts/test_plugin_custom_reward_post_process_contracts.py`
443-
- `--custom-convert-samples-to-train-data-path` -> `tests/plugin_contracts/test_plugin_custom_convert_samples_to_train_data_contracts.py`
444-
- `--rollout-sample-filter-path` -> `tests/plugin_contracts/test_plugin_rollout_sample_filter_contracts.py`
445-
- `--rollout-all-samples-process-path` -> `tests/plugin_contracts/test_plugin_rollout_all_samples_process_contracts.py`
446-
- `--rollout-data-postprocess-path` -> `tests/plugin_contracts/test_plugin_rollout_data_postprocess_contracts.py`
431+
这些测试统一放在 `tests/plugin_contracts/` 目录下,并按 hook 形态归并成少数几个文件:
432+
433+
- `tests/plugin_contracts/test_plugin_rollout_contracts.py`
434+
覆盖 `--rollout-function-path`
435+
- `tests/plugin_contracts/test_plugin_generate_contracts.py`
436+
覆盖 `--custom-generate-function-path`
437+
- `tests/plugin_contracts/test_plugin_path_loading_contracts.py`
438+
覆盖 `--eval-function-path``--custom-rm-path``--dynamic-sampling-filter-path``--buffer-filter-path``--data-source-path``--rollout-sample-filter-path``--rollout-all-samples-process-path`
439+
- `tests/plugin_contracts/test_plugin_runtime_hook_contracts.py`
440+
覆盖 `--custom-rollout-log-function-path``--custom-eval-rollout-log-function-path``--custom-reward-post-process-path``--custom-convert-samples-to-train-data-path``--rollout-data-postprocess-path`
447441

448442
本地运行全部 customization 契约测试:
449443

450444
```bash
451445
python -m pytest \
452446
tests/plugin_contracts/test_plugin_rollout_contracts.py \
453-
tests/plugin_contracts/test_plugin_eval_function_contracts.py \
454447
tests/plugin_contracts/test_plugin_generate_contracts.py \
455-
tests/plugin_contracts/test_plugin_custom_rm_contracts.py \
456-
tests/plugin_contracts/test_plugin_dynamic_filter_contracts.py \
457-
tests/plugin_contracts/test_plugin_buffer_filter_contracts.py \
458-
tests/plugin_contracts/test_plugin_data_source_contracts.py \
459-
tests/plugin_contracts/test_plugin_custom_rollout_log_contracts.py \
460-
tests/plugin_contracts/test_plugin_custom_eval_rollout_log_contracts.py \
461-
tests/plugin_contracts/test_plugin_custom_reward_post_process_contracts.py \
462-
tests/plugin_contracts/test_plugin_custom_convert_samples_to_train_data_contracts.py \
463-
tests/plugin_contracts/test_plugin_rollout_sample_filter_contracts.py \
464-
tests/plugin_contracts/test_plugin_rollout_all_samples_process_contracts.py \
465-
tests/plugin_contracts/test_plugin_rollout_data_postprocess_contracts.py
448+
tests/plugin_contracts/test_plugin_generate_contracts.py \
449+
tests/plugin_contracts/test_plugin_path_loading_contracts.py \
450+
tests/plugin_contracts/test_plugin_runtime_hook_contracts.py
466451
```
467452

468453
每个测试文件也支持直接通过 `python tests/plugin_contracts/<file>.py` 执行,这样可以和 `run-ci-changed` 保持兼容。

tests/plugin_contracts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Plugin contract tests."""

0 commit comments

Comments
 (0)