1- from functools import partial
21from pathlib import Path
32from typing import Callable
43
54import pytest
65
76from 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
1015pytestmark = [pytest .mark .gpu , pytest .mark .slow ]
1116
1217
1318@pytest .fixture (scope = "module" )
1419def 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
4350MISMATCH_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
5360def 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+
6074def 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