Add Prime-RL custom trainer compatibility controls#856
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a0408cb15
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| dataset_dir = work_dir / "prime-rl-dataset" | ||
| if dataset_dir.exists(): | ||
| shutil.rmtree(dataset_dir) | ||
| shutil.copytree(source_path, dataset_dir) |
There was a problem hiding this comment.
Avoid recursively copying the work dir into staged datasets
When --data points at a local dataset directory and the work dir is inside that directory (for example --data . with the default train-runs/sft), run_prime_rl_sft has already created <work-dir>/prime-rl before this copy runs. copytree then sees the new work directory under the source and recursively copies it into <work-dir>/prime-rl-dataset until it fails or consumes disk, so the documented local-dataset --tool-defs-mode omit path can break before launching training. Stage only the needed dataset files or ignore the work/staging subtree during the copy.
Useful? React with 👍 / 👎.
Summary
Adds explicit BenchFlow wrapper controls for reproducing the historical custom
train_lora_sft.pydata/rendering semantics while still launching native Prime-RL SFT:--renderer-mode noneemits--renderer None, disabling Prime-RL's hand-coded renderer so SFT falls back to tokenizerapply_chat_templatetokenization.--tool-defs-mode omitvalidates a local Prime-SFT source JSONL first, then removestool_defs/toolsonly from BenchFlow's temporary training copy under<work-dir>/prime-rl-dataset.train-run.jsonso experiment artifacts preserve the exact compatibility semantics.Experiment impact
This targets the remaining env-0 Mobile300 trainer-swap mismatch: the archived custom trainer consumed rows with
tool_defsbut notools, so it rendered without tool schemas and trained full rendered sequences. Prime-RL with[renderer] name="qwen3.5"instead readstool_defs, inserts tool schemas, and masks via renderer sampled-token semantics. These flags let BenchFlow run Prime-RL with the custom trainer's effective input contract without modifying Prime-RL.Validation
uv run pytest tests/test_train_cli.py -quv run pytest tests/trajectories/test_export_prime_sft.py -quv run pytest tests/test_train_cli.py tests/trajectories/test_export_prime_sft.py -quv run ruff check src/benchflow/training/backends/prime_rl.py src/benchflow/cli/train.py tests/test_train_cli.pyuv run ruff format --check src/benchflow/training/backends/prime_rl.py src/benchflow/cli/train.py tests/test_train_cli.pyuv run ty check src/benchflow/training/backends/prime_rl.pycli(SFTConfig, args=[..., "--renderer", "None", "--dry-run"])resolvedrenderer None.uv run bench train run sft --helpSpendful validation
No training rerun in this PR. The next env-0-experiment run should use: