[codex] Allow SFT without a teacher - #2720
Conversation
|
@codex review |
There was a problem hiding this comment.
Pull request overview
This PR adds a replay-backed SFT path to the RL orchestrator so SFT can run without a teacher inference server when training environments replay stored message traces (via sft-replay). It also tightens config guardrails for teacherless SFT and ensures replayed message-only trajectories get token usage populated so batching/metrics work correctly.
Changes:
- Add teacherless SFT validation: only allowed when all train envs are
sft-replayand each providesargs.taskset.dataset(orargs.config.taskset.dataset). - Backfill
token_usagefrom tokenized trajectories when replay/teacher paths omitfinal_input_tokens/final_output_tokens. - Wire dependencies/docs/debug config to support and document replay-backed SFT (
sft_replay.toml, skills/docs updates, editable deps for verifiers packages/env).
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
uv.lock |
Adds editable packages/env entries (harnesses, tasksets, sft-replay) and registers sft-replay in env extras. |
pyproject.toml |
Registers sft-replay env and editable verifiers packages; adds override deps for harnesses/tasksets. |
packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py |
Adds teacherless SFT guardrails and drops the default zero_advantage post-batch filter for SFT unless explicitly configured. |
src/prime_rl/orchestrator/orchestrator.py |
Allows SFT train rollouts to come from the teacher when configured, otherwise uses student inference (for replay envs that ignore inference). |
src/prime_rl/orchestrator/dispatcher.py |
Updates comments/docstring to reflect teacher-backed vs replay-backed SFT behavior. |
src/prime_rl/orchestrator/trajectories.py |
Adds _set_token_usage_from_trajectory and triggers it when token usage is missing on tokenized trajectories. |
tests/unit/test_configs.py |
Adds config validation tests for teacherless replay SFT and post-filter behavior. |
tests/unit/orchestrator/test_sft_replay_env.py |
Adds an integration-style unit test covering replay rollout → token backfill → interleave. |
configs/debug/training_modes/sft_replay.toml |
Adds a debug config demonstrating replay-backed SFT through the orchestrator. |
configs/debug/training_modes/README.md |
Documents how to run the new debug replay-backed SFT config. |
docs/training.md |
Documents sft mode as teacher-optional when using sft-replay trace replay. |
skills/configs/SKILL.md |
Adds guidance on the expected config shape for replay-backed SFT datasets. |
skills/training/start-run/SKILL.md |
Updates training-mode guidance to include replay-backed teacherless SFT constraints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 16e74f0. Configure here.
Bring the v1 nano branch up to date with main. Submodule pins for verifiers (7a98b566) and renderers (057f0087) kept at the branch's v1 commits; research-environments follows main (4c08260, branch never customized it). Conflict resolutions (favoring the v1 design): - utils/client.py: keep both imports (main's AsyncRetrying admin-retry + v1 client configs) - orchestrator.py: keep ROLLOUT_DUMP_EXCLUDE; keep v1 eval logging but graft main's per-eval policy_version metric; drop main's orchestrator-side token-export drain (#2641) - metrics.py / envs.py / configs/orchestrator.py: take v1 versions; drop main's orchestrator-side token-export (#2641), per-env advantage (#2721, branch uses top-level advantage via train_sink), and sft-no-teacher renderer=None (#2720, branch is renderer-only) - pyproject.toml: dedupe tasksets/harnesses sources; drop mini-swe-agent-plus-rlm - uv.lock regenerated; orphan orchestrator/token_export_metrics.py removed Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Summary
orchestrator.training_mode = "sft"without a configured teacherMotivation
This is needed for replay-backed SFT workflows where the train env can provide the supervision without a teacher model. PrimeRL should only need the generic capability: SFT can run without
orchestrator.teacher; replay-specific taskset/env behavior stays outside this PR.Validation
uvx ruff==0.13.0 check --config=pyproject.toml packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py src/prime_rl/orchestrator/orchestrator.py src/prime_rl/orchestrator/dispatcher.pypython3 -m py_compile packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py src/prime_rl/orchestrator/orchestrator.py src/prime_rl/orchestrator/dispatcher.pygit diff --checkNotes
The earlier replay-specific package wiring, debug config, docs, tests, Verifiers submodule pointer, token-usage backfill, and zero-adv filter changes have been removed from the effective diff. The PR is now limited to the teacher-optional SFT routing/cache consequences.
Note
Medium Risk
Changes SFT train inference routing and prefix-cache salting when no teacher is set; misconfiguration could affect rollout correctness or cache reuse, but scope is limited to orchestrator config and dispatch.
Overview
SFT can run without
orchestrator.teacher. Config validation no longer requires a teacher fortraining_mode = "sft"(only OPD still mandates one). Forcingrenderer = Noneis limited to teacher-backed SFT; teacherless SFT keeps the normal student renderer path.Train rollout routing is split: SFT with a teacher still uses the frozen teacher inference pool and disables prefix-cache salting on train rollouts; SFT without a teacher uses the student rollout pool with policy-version cache salt, same as RL/OPD train paths. The dispatcher takes an explicit
use_cache_saltflag instead of inferring this fromtraining_mode == "sft"alone.Reviewed by Cursor Bugbot for commit cdba94e. Bugbot is set up for automated code reviews on this repo. Configure here.