Skip to content

Commit 7104dbd

Browse files
authored
hendrycks sanity ci (#1900)
* do not oversample hendrycks sanity (trainer bottlenecks) * put hendrycks sanity into nightly config * remove duplicate utils
1 parent 3d9aa90 commit 7104dbd

15 files changed

Lines changed: 40 additions & 108 deletions

configs/ci/nightly/hendrycks_math.toml

Lines changed: 0 additions & 47 deletions
This file was deleted.

examples/hendrycks_sanity/rl.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
1515
[orchestrator]
1616
batch_size = 512
1717
rollouts_per_example = 8
18-
oversampling_factor = 2.0
1918

2019
[[orchestrator.env]]
2120
id = "math-env" # included in lock file

tests/integration/test_alphabet_sort.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_no_error, check_number_goes_up_or_down, check_reward_in_range, strip_escape_codes
7+
from tests.utils import check_no_error, check_reward_goes_up, check_reward_in_range, strip_escape_codes
98

109
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1110

@@ -49,9 +48,6 @@ def rl_process(
4948
return run_process(cmd, timeout=TIMEOUT)
5049

5150

52-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
53-
54-
5551
@pytest.fixture(scope="module")
5652
def test_no_error(rl_process: ProcessResult, rl_output_dir: Path):
5753
"""Tests that the RL process does not fail."""

tests/integration/test_rl.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_no_error, check_number_goes_up_or_down, check_reward_in_range, strip_escape_codes
7+
from tests.utils import check_no_error, check_reward_goes_up, check_reward_in_range, strip_escape_codes
98

109
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1110

@@ -70,9 +69,6 @@ def rl_resume_process(
7069
return run_process(cmd, timeout=TIMEOUT)
7170

7271

73-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
74-
75-
7672
@pytest.fixture(scope="module")
7773
def test_no_error(rl_process: ProcessResult, output_dir: Path):
7874
"""Tests that the RL process does not fail."""

tests/integration/test_rl_lora.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_no_error, check_number_goes_up_or_down, check_reward_in_range, strip_escape_codes
7+
from tests.utils import check_no_error, check_reward_goes_up, check_reward_in_range, strip_escape_codes
98

109
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1110

@@ -70,9 +69,6 @@ def rl_resume_process(
7069
return run_process(cmd, env={"VLLM_ALLOW_RUNTIME_LORA_UPDATING": "True"}, timeout=TIMEOUT)
7170

7271

73-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
74-
75-
7672
@pytest.fixture(scope="module")
7773
def test_no_error(rl_process: ProcessResult, output_dir: Path):
7874
"""Tests that the RL process does not fail."""

tests/integration/test_rl_multi_run_lora.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
import signal
66
import subprocess
77
import time
8-
from functools import partial
98
from pathlib import Path
109
from typing import Generator
1110

1211
import pytest
1312

1413
from tests.conftest import ProcessResult
15-
from tests.utils import check_number_goes_up_or_down, check_reward_in_range, strip_escape_codes
14+
from tests.utils import check_reward_goes_up, check_reward_in_range, strip_escape_codes
1615

1716
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1817

@@ -364,9 +363,6 @@ def multi_run_result(
364363
p.kill()
365364

366365

367-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
368-
369-
370366
def test_remaining_orchestrators_complete(
371367
multi_run_result: dict[str, ProcessResult],
372368
output_dir: Path,

tests/integration/test_sft.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_number_goes_up_or_down, strip_escape_codes
7+
from tests.utils import check_loss_goes_down, strip_escape_codes
98

109
pytestmark = [pytest.mark.slow, pytest.mark.gpu]
1110

@@ -80,9 +79,6 @@ def sft_resume_process(
8079
return run_process(cmd, timeout=TIMEOUT)
8180

8281

83-
check_loss_goes_down = partial(check_number_goes_up_or_down, go_up=False, pattern=r"Loss:\s*(\d+\.\d{4})")
84-
85-
8682
def test_no_error(sft_process: ProcessResult):
8783
"""Tests that the SFT process does not fail."""
8884
assert sft_process.returncode == 0, f"Process has non-zero return code ({sft_process})"

tests/nightly/test_acereason_math.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_mismatch_kl_in_range, check_no_error, check_number_goes_up_or_down, strip_escape_codes
7+
from tests.utils import check_mismatch_kl_in_range, check_no_error, check_reward_goes_up, strip_escape_codes
98

109
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1110

@@ -39,7 +38,6 @@ def rl_process(
3938
return run_process(cmd)
4039

4140

42-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
4341
MISMATCH_KL_MIN = 0.0
4442
MISMATCH_KL_MAX = 0.0015
4543

tests/nightly/test_alphabet_sort.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_no_error, check_number_goes_up_or_down, strip_escape_codes
7+
from tests.utils import check_no_error, check_reward_goes_up, strip_escape_codes
98

109
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1110

@@ -39,9 +38,6 @@ def rl_process(
3938
return run_process(cmd)
4039

4140

42-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
43-
44-
4541
@pytest.fixture(scope="module")
4642
def test_no_error(rl_process: ProcessResult, output_dir: Path):
4743
"""Tests that the RL process does not fail."""
Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
from functools import partial
21
from pathlib import Path
32
from typing import Callable
43

54
import pytest
65

76
from tests.conftest import ProcessResult
8-
from tests.utils import check_mismatch_kl_in_range, check_no_error, check_number_goes_up_or_down, strip_escape_codes
7+
from tests.utils import (
8+
check_mismatch_kl_in_range,
9+
check_no_error,
10+
check_reward_goes_up,
11+
check_reward_in_range,
12+
strip_escape_codes,
13+
)
914

1015
pytestmark = [pytest.mark.gpu, pytest.mark.slow]
1116

1217

1318
@pytest.fixture(scope="module")
1419
def wandb_name(branch_name: str) -> str:
1520
"""Fixture for W&B name for RL CI integration tests."""
16-
return f"hendrycks-math-{branch_name}"
21+
return f"hendrycks-sanity-{branch_name}"
1722

1823

1924
@pytest.fixture(scope="module")
@@ -28,20 +33,22 @@ def rl_process(
2833
"run",
2934
"rl",
3035
"@",
31-
"configs/ci/nightly/hendrycks_math.toml",
36+
"examples/hendrycks_sanity/rl.toml",
3237
"--wandb.project",
3338
wandb_project,
3439
"--wandb.name",
3540
wandb_name,
3641
"--output-dir",
3742
output_dir.as_posix(),
43+
"--max-steps",
44+
"1000", # do less steps to finish in time
3845
]
3946
return run_process(cmd)
4047

4148

42-
check_reward_goes_up = partial(check_number_goes_up_or_down, go_up=True, pattern=r"Reward:\s*(\d+\.\d{4})")
49+
MIN_TRAIN_REWARD = 0.75
4350
MISMATCH_KL_MIN = 0.0
44-
MISMATCH_KL_MAX = 0.0004
51+
MISMATCH_KL_MAX = 0.0005
4552

4653

4754
@pytest.fixture(scope="module")
@@ -51,12 +58,19 @@ def test_no_error(rl_process: ProcessResult, output_dir: Path):
5158

5259

5360
def test_reward_goes_up(rl_process: ProcessResult, test_no_error, output_dir: Path):
54-
"""Tests that the reward goes up in the RL process"""
61+
"""Tests that the train reward goes up during training"""
5562
with open(output_dir / "logs" / "orchestrator.stdout", "r") as f:
5663
orchestrator_stdout = strip_escape_codes(f.read()).splitlines()
5764
check_reward_goes_up(orchestrator_stdout)
5865

5966

67+
def test_reward_reaches_threshold(rl_process: ProcessResult, test_no_error, output_dir: Path):
68+
"""Tests that the train reward reaches a minimum threshold"""
69+
with open(output_dir / "logs" / "orchestrator.stdout", "r") as f:
70+
orchestrator_stdout = strip_escape_codes(f.read()).splitlines()
71+
check_reward_in_range(orchestrator_stdout, min_threshold=MIN_TRAIN_REWARD)
72+
73+
6074
def test_mismatch_kl_in_band(rl_process: ProcessResult, test_no_error, output_dir: Path):
6175
"""Tests that mismatch KL stays within the expected band."""
6276
with open(output_dir / "logs" / "trainer.stdout", "r") as f:

0 commit comments

Comments
 (0)