Skip to content

Add Prime-RL custom trainer compatibility controls#856

Merged
bingran-you merged 1 commit into
mainfrom
bry/prime-rl-custom-trainer-compat
Jun 30, 2026
Merged

Add Prime-RL custom trainer compatibility controls#856
bingran-you merged 1 commit into
mainfrom
bry/prime-rl-custom-trainer-compat

Conversation

@bingran-you

Copy link
Copy Markdown
Collaborator

Summary

Adds explicit BenchFlow wrapper controls for reproducing the historical custom train_lora_sft.py data/rendering semantics while still launching native Prime-RL SFT:

  • --renderer-mode none emits --renderer None, disabling Prime-RL's hand-coded renderer so SFT falls back to tokenizer apply_chat_template tokenization.
  • --tool-defs-mode omit validates a local Prime-SFT source JSONL first, then removes tool_defs / tools only from BenchFlow's temporary training copy under <work-dir>/prime-rl-dataset.
  • Records both choices in train-run.json so experiment artifacts preserve the exact compatibility semantics.
  • Updates CLI docs and adds focused tests for the custom-trainer-compatible path and remote-dataset rejection.

Experiment impact

This targets the remaining env-0 Mobile300 trainer-swap mismatch: the archived custom trainer consumed rows with tool_defs but no tools, so it rendered without tool schemas and trained full rendered sequences. Prime-RL with [renderer] name="qwen3.5" instead reads tool_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 -q
  • uv run pytest tests/trajectories/test_export_prime_sft.py -q
  • uv run pytest tests/test_train_cli.py tests/trajectories/test_export_prime_sft.py -q
  • uv run ruff check src/benchflow/training/backends/prime_rl.py src/benchflow/cli/train.py tests/test_train_cli.py
  • uv run ruff format --check src/benchflow/training/backends/prime_rl.py src/benchflow/cli/train.py tests/test_train_cli.py
  • uv run ty check src/benchflow/training/backends/prime_rl.py
  • H100 Prime-RL parser check: cli(SFTConfig, args=[..., "--renderer", "None", "--dry-run"]) resolved renderer None.
  • uv run bench train run sft --help

Spendful validation

No training rerun in this PR. The next env-0-experiment run should use:

TARGET_EXAMPLES=300 \
PACK_FUNCTION=stack \
LOSS_MASK=all \
MODEL_ATTN=sdpa \
RENDERER_MODE=none \
TOOL_DEFS_MODE=omit \
RUN_KIND=mobile300-custom-trainer-compatible-prime-rl \
bash experiments/env0-mobile-pr828-prime-rl-benchflow-cli/scripts/run_prime_rl_wandb_sft.sh

@bingran-you
bingran-you temporarily deployed to pypi-internal-preview June 30, 2026 05:00 — with GitHub Actions Inactive

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@bingran-you
bingran-you merged commit 1e71346 into main Jun 30, 2026
9 checks passed
@bingran-you
bingran-you deleted the bry/prime-rl-custom-trainer-compat branch June 30, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant