From cb74ae2bebe9710b11551970a9661d10116c7179 Mon Sep 17 00:00:00 2001 From: hallerite Date: Tue, 21 Jul 2026 16:44:20 -0700 Subject: [PATCH] feat: bump verifiers to 0.2.2.dev7, adopt the multi-agent episode wire (#3104) * feat: bump verifiers to 0.2.2.dev7, adopt the multi-agent episode wire Companion to PrimeIntellect-ai/verifiers#1939 (multi-agent api). Re-pins deps/verifiers to 192fd8ef0 (= 0.2.2.dev7) and deps/pydantic-config to v0.4.2 (verifiers now requires prime-pydantic-config>=0.4.2). - Serve wire: the env-server route run_rollout -> run, answering one Episode envelope ({id, env, ok, errors, traces}) per env-rollout. Env.run returns list[Rollout]; an episode that failed before minting any trace raises (the dispatcher synthesizes its error marker), and a not-ok episode marks its clean traces failed so a broken episode's partial seats are never trained on. - The episode is the pipeline currency: the dispatcher emits one episode (list[Rollout]) per completed task onto out_q (a legacy run_group result emits its traces as single-trace episodes), and both sinks count episodes - never loose traces - toward group_size and eval epoch sizes. episode_id is stamped into info so saved records keep grouping. - ok is the success sentinel: has_error now reads it, so the dispatcher's empty-trajectory promotion also flips ok, and error markers carry it. - Only the trainable subset becomes training samples: a trace stamped untrainable (a multi-agent env's frozen agent) is never tokenized, never enters the group advantage, and never ships; it still lands in the trace files and observation window. - Config shape: everything env lives under the env block, following the new vf.EnvServerConfig (env.taskset, env.agent.harness, per-agent caps under env.agent.*). All checked-in TOMLs migrated; the spawned env server receives the picklable env block via env_config_data. - run_group survives only for v0/legacy bridge envs (a v1 server refuses it and always reports requires_group_scoring=False); vf's @group_reward removal doesn't touch prime-rl's own Algorithm.score_group. Verified: tests/unit green (487 passed; config-loading params covered all migrated TOMLs), ruff clean, and a 3-step reverse-text RL run on 2 GPUs trains at 0% errors with every saved trace carrying ok, agent.name, agent.trainable, and a distinct info.episode_id. Co-Authored-By: Claude Fable 5 * chore: trim narrative comments to the load-bearing facts Co-Authored-By: Claude Fable 5 * fix: count buffered sink progress in episodes; explicit ok=False on cancel markers Co-Authored-By: Claude Fable 5 * fix: keep untrainable traces out of the effective views and the derived avg@k Co-Authored-By: Claude Fable 5 --------- Co-authored-by: Claude Fable 5 --- configs/basic/alphabet-sort/rl.toml | 4 +- configs/basic/hendrycks-sanity/rl.toml | 4 +- configs/basic/reverse-text/rl.toml | 4 +- configs/basic/wiki-search/rl.toml | 4 +- configs/basic/wordle/rl.toml | 4 +- configs/ci/integration/alphabet_sort.toml | 4 +- .../integration/reverse-text-lora/resume.toml | 4 +- .../integration/reverse-text-lora/start.toml | 4 +- .../integration/reverse-text-moe/start.toml | 4 +- .../reverse-text-multi-run/orchestrator.toml | 4 +- .../reverse-text-rl-opd/start.toml | 8 +- .../reverse-text-rl-sft/start.toml | 8 +- .../ci/integration/reverse-text/resume.toml | 4 +- .../ci/integration/reverse-text/start.toml | 4 +- .../ci/nightly/multimodal_color_codeword.toml | 4 +- configs/debug/algo/echo.toml | 4 +- configs/debug/algo/grpo.toml | 8 +- configs/debug/algo/max_rl.toml | 8 +- configs/debug/algo/mixed_grpo_opd.toml | 12 +-- configs/debug/algo/opd.toml | 8 +- configs/debug/algo/opd_lora.toml | 8 +- configs/debug/algo/self_distill.toml | 8 +- configs/debug/algo/sft_distill.toml | 8 +- configs/debug/algo/sft_distill_lora.toml | 8 +- deps/verifiers | 2 +- docs/configuration.md | 14 ++-- examples/advanced/glm-4.5-air/search.toml | 24 +++--- examples/advanced/glm-4.5-air/swe.toml | 10 +-- examples/advanced/glm-4.5-air/terminal.toml | 28 +++---- examples/advanced/glm-5.2/swe-llmd.toml | 4 +- examples/advanced/glm-5.2/swe.toml | 4 +- examples/advanced/intellect-3.1/rl.toml | 28 +++---- examples/advanced/minimax-m2.5/swe.toml | 8 +- examples/advanced/nemotron-3-super/swe.toml | 10 +-- examples/advanced/qwen3-30b-a3b/math.toml | 8 +- examples/advanced/qwen3-30b-a3b/swe.toml | 8 +- examples/advanced/qwen3-30b-a3b/tool.toml | 4 +- examples/basic/alphabet-sort/rl.toml | 4 +- examples/basic/hendrycks-sanity/rl.toml | 8 +- examples/basic/reverse-text/rl.toml | 4 +- examples/basic/wiki-search/rl.toml | 4 +- examples/basic/wordle/rl.toml | 4 +- .../src/prime_rl/configs/orchestrator.py | 31 ++++---- skills/configs/SKILL.md | 6 +- skills/training/monitor-run/SKILL.md | 19 +++-- src/prime_rl/orchestrator/dispatcher.py | 72 +++++++++++------- .../orchestrator/env_server/env_server.py | 6 +- src/prime_rl/orchestrator/envs.py | 38 +++++++--- src/prime_rl/orchestrator/eval_sink.py | 50 +++++++------ src/prime_rl/orchestrator/metrics.py | 21 ++++-- src/prime_rl/orchestrator/orchestrator.py | 33 +++++---- src/prime_rl/orchestrator/train_sink.py | 73 +++++++++---------- src/prime_rl/orchestrator/types.py | 5 +- src/prime_rl/utils/monitor/prime.py | 2 +- tests/unit/orchestrator/test_metrics.py | 2 + uv.lock | 13 ++++ 56 files changed, 375 insertions(+), 312 deletions(-) diff --git a/configs/basic/alphabet-sort/rl.toml b/configs/basic/alphabet-sort/rl.toml index a8d4ae2f..8363e1e3 100644 --- a/configs/basic/alphabet-sort/rl.toml +++ b/configs/basic/alphabet-sort/rl.toml @@ -34,8 +34,8 @@ max_completion_tokens = 768 [[orchestrator.train.env]] name = "alphabet-sort" -taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [ckpt] # Checkpoint at the end of training diff --git a/configs/basic/hendrycks-sanity/rl.toml b/configs/basic/hendrycks-sanity/rl.toml index b852d6cf..0512fead 100644 --- a/configs/basic/hendrycks-sanity/rl.toml +++ b/configs/basic/hendrycks-sanity/rl.toml @@ -21,8 +21,8 @@ seq_len = 8192 [[orchestrator.train.env]] name = "hendrycks-math" -taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.model] seq_len = 16384 diff --git a/configs/basic/reverse-text/rl.toml b/configs/basic/reverse-text/rl.toml index 91c09091..5d80c55a 100644 --- a/configs/basic/reverse-text/rl.toml +++ b/configs/basic/reverse-text/rl.toml @@ -24,8 +24,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/basic/wiki-search/rl.toml b/configs/basic/wiki-search/rl.toml index 6a38caa2..f69278c9 100644 --- a/configs/basic/wiki-search/rl.toml +++ b/configs/basic/wiki-search/rl.toml @@ -42,8 +42,8 @@ max_completion_tokens = 512 [[orchestrator.train.env]] name = "wiki-search" -taskset = { id = "wiki-search-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "wiki-search-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [ckpt] # Checkpoint at the end of training diff --git a/configs/basic/wordle/rl.toml b/configs/basic/wordle/rl.toml index ba1e49e4..aec07641 100644 --- a/configs/basic/wordle/rl.toml +++ b/configs/basic/wordle/rl.toml @@ -23,8 +23,8 @@ group_size = 8 [[orchestrator.train.env]] name = "wordle" -taskset = { id = "wordle-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "wordle-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.train.sampling] max_completion_tokens = 1024 diff --git a/configs/ci/integration/alphabet_sort.toml b/configs/ci/integration/alphabet_sort.toml index 61e2f84a..1c131765 100644 --- a/configs/ci/integration/alphabet_sort.toml +++ b/configs/ci/integration/alphabet_sort.toml @@ -24,8 +24,8 @@ max_completion_tokens = 384 [[orchestrator.train.env]] name = "alphabet-sort" -taskset = { id = "alphabet-sort-v1", min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, task = { similarity_power = 4, power_per_turn = false } } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "alphabet-sort-v1", min_turns = 2, max_turns = 2, min_names_per_turn = 1, max_names_per_turn = 3, task = { similarity_power = 4, power_per_turn = false } } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] diff --git a/configs/ci/integration/reverse-text-lora/resume.toml b/configs/ci/integration/reverse-text-lora/resume.toml index c0118603..7c655028 100644 --- a/configs/ci/integration/reverse-text-lora/resume.toml +++ b/configs/ci/integration/reverse-text-lora/resume.toml @@ -28,8 +28,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] enable_lora = true diff --git a/configs/ci/integration/reverse-text-lora/start.toml b/configs/ci/integration/reverse-text-lora/start.toml index 283cc855..f10981be 100644 --- a/configs/ci/integration/reverse-text-lora/start.toml +++ b/configs/ci/integration/reverse-text-lora/start.toml @@ -27,8 +27,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] enable_lora = true diff --git a/configs/ci/integration/reverse-text-moe/start.toml b/configs/ci/integration/reverse-text-moe/start.toml index 55f81c7b..c695e80d 100644 --- a/configs/ci/integration/reverse-text-moe/start.toml +++ b/configs/ci/integration/reverse-text-moe/start.toml @@ -27,8 +27,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] gpu_memory_utilization = 0.7 diff --git a/configs/ci/integration/reverse-text-multi-run/orchestrator.toml b/configs/ci/integration/reverse-text-multi-run/orchestrator.toml index fc28577c..f60ffc5c 100644 --- a/configs/ci/integration/reverse-text-multi-run/orchestrator.toml +++ b/configs/ci/integration/reverse-text-multi-run/orchestrator.toml @@ -16,8 +16,8 @@ max_completion_tokens = 128 [[train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [ckpt] interval = 10 diff --git a/configs/ci/integration/reverse-text-rl-opd/start.toml b/configs/ci/integration/reverse-text-rl-opd/start.toml index 6fa9b6d1..03552758 100644 --- a/configs/ci/integration/reverse-text-rl-opd/start.toml +++ b/configs/ci/integration/reverse-text-rl-opd/start.toml @@ -39,8 +39,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -51,8 +51,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/ci/integration/reverse-text-rl-sft/start.toml b/configs/ci/integration/reverse-text-rl-sft/start.toml index 615ae876..8b46a4b5 100644 --- a/configs/ci/integration/reverse-text-rl-sft/start.toml +++ b/configs/ci/integration/reverse-text-rl-sft/start.toml @@ -45,8 +45,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -57,8 +57,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/ci/integration/reverse-text/resume.toml b/configs/ci/integration/reverse-text/resume.toml index 3e97b6db..e1163b56 100644 --- a/configs/ci/integration/reverse-text/resume.toml +++ b/configs/ci/integration/reverse-text/resume.toml @@ -25,8 +25,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] diff --git a/configs/ci/integration/reverse-text/start.toml b/configs/ci/integration/reverse-text/start.toml index 78ccdf11..c2aea784 100644 --- a/configs/ci/integration/reverse-text/start.toml +++ b/configs/ci/integration/reverse-text/start.toml @@ -24,8 +24,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] diff --git a/configs/ci/nightly/multimodal_color_codeword.toml b/configs/ci/nightly/multimodal_color_codeword.toml index be84b97c..4c8d980c 100644 --- a/configs/ci/nightly/multimodal_color_codeword.toml +++ b/configs/ci/nightly/multimodal_color_codeword.toml @@ -22,8 +22,8 @@ max_completion_tokens = 64 [[orchestrator.train.env]] name = "color-codeword" -taskset = { id = "color-codeword-v1", images_per_turn = 1 } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "color-codeword-v1", images_per_turn = 1 } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer] diff --git a/configs/debug/algo/echo.toml b/configs/debug/algo/echo.toml index 49ed0f30..88ca238f 100644 --- a/configs/debug/algo/echo.toml +++ b/configs/debug/algo/echo.toml @@ -26,8 +26,8 @@ alpha = 0.1 [[orchestrator.train.env]] name = "alphabet-sort" -taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.train.sampling] max_completion_tokens = 512 diff --git a/configs/debug/algo/grpo.toml b/configs/debug/algo/grpo.toml index e45ba3b8..ea1fa4b9 100644 --- a/configs/debug/algo/grpo.toml +++ b/configs/debug/algo/grpo.toml @@ -23,8 +23,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -35,8 +35,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/debug/algo/max_rl.toml b/configs/debug/algo/max_rl.toml index e5ac29ce..9c416aab 100644 --- a/configs/debug/algo/max_rl.toml +++ b/configs/debug/algo/max_rl.toml @@ -23,8 +23,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -35,8 +35,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/debug/algo/mixed_grpo_opd.toml b/configs/debug/algo/mixed_grpo_opd.toml index 58fb2da5..5e55450e 100644 --- a/configs/debug/algo/mixed_grpo_opd.toml +++ b/configs/debug/algo/mixed_grpo_opd.toml @@ -33,13 +33,13 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text-grpo" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [[orchestrator.train.env]] name = "reverse-text-opd" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.train.env.algo] type = "opd" @@ -57,8 +57,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/debug/algo/opd.toml b/configs/debug/algo/opd.toml index 3def82e9..53e9eac2 100644 --- a/configs/debug/algo/opd.toml +++ b/configs/debug/algo/opd.toml @@ -35,8 +35,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -47,8 +47,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/debug/algo/opd_lora.toml b/configs/debug/algo/opd_lora.toml index b4a723be..948bb512 100644 --- a/configs/debug/algo/opd_lora.toml +++ b/configs/debug/algo/opd_lora.toml @@ -35,8 +35,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -47,8 +47,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 1e-4 diff --git a/configs/debug/algo/self_distill.toml b/configs/debug/algo/self_distill.toml index db318523..25344d1f 100644 --- a/configs/debug/algo/self_distill.toml +++ b/configs/debug/algo/self_distill.toml @@ -31,8 +31,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -43,8 +43,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/debug/algo/sft_distill.toml b/configs/debug/algo/sft_distill.toml index b4712368..c34dac0d 100644 --- a/configs/debug/algo/sft_distill.toml +++ b/configs/debug/algo/sft_distill.toml @@ -40,8 +40,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -52,8 +52,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/configs/debug/algo/sft_distill_lora.toml b/configs/debug/algo/sft_distill_lora.toml index 95eaeb80..ad05f653 100644 --- a/configs/debug/algo/sft_distill_lora.toml +++ b/configs/debug/algo/sft_distill_lora.toml @@ -40,8 +40,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 1 @@ -52,8 +52,8 @@ max_completion_tokens = 128 [[orchestrator.eval.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 1e-4 diff --git a/deps/verifiers b/deps/verifiers index 1f457da1..192fd8ef 160000 --- a/deps/verifiers +++ b/deps/verifiers @@ -1 +1 @@ -Subproject commit 1f457da17a0408ef062f2c11576e67d2cd66126a +Subproject commit 192fd8ef0d2fdcefc8566b0ec793d73631e7b51a diff --git a/docs/configuration.md b/docs/configuration.md index 81da0bc2..e624f471 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -149,25 +149,25 @@ Training environments are an array of tables — set one per env, optionally wit ```toml [[orchestrator.train.env]] name = "gsm8k" -taskset = { id = "gsm8k-v1", split = "train" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "gsm8k-v1", split = "train" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } ratio = 3 # 75% of batches [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } ratio = 1 # default — 25% of batches [[orchestrator.eval.env]] name = "gsm8k-eval" -taskset = { id = "gsm8k-v1", split = "test" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "gsm8k-v1", split = "test" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } ``` `ratio` defaults to `1` (equal weight per env); values are relative weights normalized to probabilities across envs. -Fields in `taskset` configure the V1 taskset. `harness` selects how its tasks are run. +Everything environment lives under the `env` block (verifiers' `[env]` shape): `env.taskset` configures the v1 taskset, and each agent is a field on the env — `env.agent.harness` selects how the single-agent env's tasks are run, and per-run caps are per-agent (`env.agent.max_turns`, `env.agent.timeout`, `env.agent.max_output_tokens`). A multi-agent env declares its own seats (`env..*`). The same taskset can appear multiple times across train and eval (or with different settings) — useful for evaluating on a held-out split or comparing two configurations side by side. When it is reused, set a distinct `name` on each entry; `name` defaults to the taskset id and must be unique across all envs in the same group. diff --git a/examples/advanced/glm-4.5-air/search.toml b/examples/advanced/glm-4.5-air/search.toml index 9027d93c..ee706e83 100644 --- a/examples/advanced/glm-4.5-air/search.toml +++ b/examples/advanced/glm-4.5-air/search.toml @@ -95,12 +95,12 @@ num_turns_weight = 0.0 # the plugged BC-style prompt is replaced by the reference judge's stock prompt). [[orchestrator.train.env]] name = "openseeker" -harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } } +env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } } -[orchestrator.train.env.taskset] +[orchestrator.train.env.env.taskset] id = "openseeker-v1" -[[orchestrator.train.env.taskset.task.judges]] +[[orchestrator.train.env.env.taskset.task.judges]] id = "reference" name = "correct" model = "Qwen/Qwen3-235B-A22B-Instruct-2507" @@ -108,7 +108,7 @@ question_field = "question" choices = ["A", "B"] # # Metric-only monitor (weight 0): rlm harness-mechanics rubric, judged by GLM-5.2. -# [[orchestrator.train.env.taskset.task.judges]] +# [[orchestrator.train.env.env.taskset.task.judges]] # id = "rubric" # name = "rlm" # path = "deps/research-environments/rubrics/rlm.toml" @@ -117,12 +117,12 @@ choices = ["A", "B"] [[orchestrator.train.env]] name = "redsearcher" -harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } } +env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } } -[orchestrator.train.env.taskset] +[orchestrator.train.env.env.taskset] id = "redsearcher-v1" # optional `difficulty` filter (easy/medium/hard) -[[orchestrator.train.env.taskset.task.judges]] +[[orchestrator.train.env.env.taskset.task.judges]] id = "reference" name = "correct" model = "Qwen/Qwen3-235B-A22B-Instruct-2507" @@ -130,7 +130,7 @@ question_field = "question" choices = ["A", "B"] # # Metric-only monitor (weight 0): rlm harness-mechanics rubric, judged by GLM-5.2. -# [[orchestrator.train.env.taskset.task.judges]] +# [[orchestrator.train.env.env.taskset.task.judges]] # id = "rubric" # name = "rlm" # path = "deps/research-environments/rubrics/rlm.toml" @@ -145,15 +145,15 @@ interval = 20 [[orchestrator.eval.env]] name = "browsecomp" num_examples = 500 # full set is 1266; cap eval at 500 -harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } } -timeout = { rollout = 3600 } +env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } } +env.agent.timeout = { rollout = 3600 } -[orchestrator.eval.env.taskset] +[orchestrator.eval.env.env.taskset] id = "browsecomp-v1" task = { judge = { model = "Qwen/Qwen3-235B-A22B-Instruct-2507" } } # # Metric-only monitor (weight 0): rlm harness-mechanics rubric, judged by GLM-5.2. -# [[orchestrator.eval.env.taskset.task.judges]] +# [[orchestrator.eval.env.env.taskset.task.judges]] # id = "rubric" # name = "rlm" # path = "deps/research-environments/rubrics/rlm.toml" diff --git a/examples/advanced/glm-4.5-air/swe.toml b/examples/advanced/glm-4.5-air/swe.toml index f46025b6..6bfcc0ad 100644 --- a/examples/advanced/glm-4.5-air/swe.toml +++ b/examples/advanced/glm-4.5-air/swe.toml @@ -99,8 +99,8 @@ thinking_retention = "all" [[orchestrator.train.env]] name = "scaleswe" -taskset = { id = "scaleswe-v1" } -harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] } } +env.taskset = { id = "scaleswe-v1" } +env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] } } [orchestrator.prime_monitor] @@ -111,9 +111,9 @@ interval = 20 [[orchestrator.eval.env]] name = "swebench-verified" -taskset = { id = "swebench-verified-v1" } -harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] } } -timeout = { rollout = 3600 } +env.taskset = { id = "swebench-verified-v1" } +env.agent.harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] } } +env.agent.timeout = { rollout = 3600 } # --- Inference --- diff --git a/examples/advanced/glm-4.5-air/terminal.toml b/examples/advanced/glm-4.5-air/terminal.toml index d44ceb2d..ba51a85d 100644 --- a/examples/advanced/glm-4.5-air/terminal.toml +++ b/examples/advanced/glm-4.5-air/terminal.toml @@ -93,20 +93,20 @@ num_turns_weight = 0.1 [[orchestrator.train.env]] name = "tmax" -harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] } } +env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] } } -[orchestrator.train.env.taskset] +[orchestrator.train.env.env.taskset] id = "tmax-v1" # # Metric-only monitors (weight 0): rlm harness-mechanics + swe code-usage rubrics, judged by GLM-5.2. -# [[orchestrator.train.env.taskset.judges]] +# [[orchestrator.train.env.env.taskset.judges]] # id = "rubric" # name = "rlm" # path = "deps/research-environments/rubrics/rlm.toml" # model = "zai-org/GLM-5.2" # weight = 0.0 -# [[orchestrator.train.env.taskset.judges]] +# [[orchestrator.train.env.env.taskset.judges]] # id = "rubric" # name = "swe" # path = "deps/research-environments/rubrics/swe.toml" @@ -120,20 +120,20 @@ interval = 20 [[orchestrator.eval.env]] name = "swebench-verified" -harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] } } -timeout = { rollout = 3600 } +env.agent.harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] } } +env.agent.timeout = { rollout = 3600 } -[orchestrator.eval.env.taskset] +[orchestrator.eval.env.env.taskset] id = "swebench-verified-v1" -# [[orchestrator.eval.env.taskset.judges]] +# [[orchestrator.eval.env.env.taskset.judges]] # id = "rubric" # name = "rlm" # path = "deps/research-environments/rubrics/rlm.toml" # model = "zai-org/GLM-5.2" # weight = 0.0 -# [[orchestrator.eval.env.taskset.judges]] +# [[orchestrator.eval.env.env.taskset.judges]] # id = "rubric" # name = "swe" # path = "deps/research-environments/rubrics/swe.toml" @@ -143,20 +143,20 @@ id = "swebench-verified-v1" [[orchestrator.eval.env]] name = "terminal-bench-2" group_size = 4 # avg@4 -harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] } } -timeout = { rollout = 3600 } +env.agent.harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] } } +env.agent.timeout = { rollout = 3600 } -[orchestrator.eval.env.taskset] +[orchestrator.eval.env.env.taskset] id = "terminal-bench-2-v1" -# [[orchestrator.eval.env.taskset.judges]] +# [[orchestrator.eval.env.env.taskset.judges]] # id = "rubric" # name = "rlm" # path = "deps/research-environments/rubrics/rlm.toml" # model = "zai-org/GLM-5.2" # weight = 0.0 -# [[orchestrator.eval.env.taskset.judges]] +# [[orchestrator.eval.env.env.taskset.judges]] # id = "rubric" # name = "swe" # path = "deps/research-environments/rubrics/swe.toml" diff --git a/examples/advanced/glm-5.2/swe-llmd.toml b/examples/advanced/glm-5.2/swe-llmd.toml index f6edf9cd..8e544235 100644 --- a/examples/advanced/glm-5.2/swe-llmd.toml +++ b/examples/advanced/glm-5.2/swe-llmd.toml @@ -98,8 +98,8 @@ extra_body = {chat_template_kwargs = {clear_thinking = false}} [[orchestrator.train.env]] name = "r2e" -taskset = { id = "r2e-gym-v1" } -harness = { id = "rlm", runtime = { type = "prime", labels = ["glm5-llmd"] } } +env.taskset = { id = "r2e-gym-v1" } +env.agent.harness = { id = "rlm", runtime = { type = "prime", labels = ["glm5-llmd"] } } [inference] enable_expert_parallel = true diff --git a/examples/advanced/glm-5.2/swe.toml b/examples/advanced/glm-5.2/swe.toml index c4ab884f..3e2aa33c 100644 --- a/examples/advanced/glm-5.2/swe.toml +++ b/examples/advanced/glm-5.2/swe.toml @@ -73,8 +73,8 @@ interval = 20 [[orchestrator.eval.env]] name = "swe-bench-verified" -taskset = { id = "swebench-verified-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["glm5-pd-disag", "swe-bench-verified"] } } +env.taskset = { id = "swebench-verified-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["glm5-pd-disag", "swe-bench-verified"] } } [[orchestrator.post_batch_filters]] type = "gibberish" diff --git a/examples/advanced/intellect-3.1/rl.toml b/examples/advanced/intellect-3.1/rl.toml index d0806988..373a4d9d 100644 --- a/examples/advanced/intellect-3.1/rl.toml +++ b/examples/advanced/intellect-3.1/rl.toml @@ -50,32 +50,32 @@ oversampling_factor = 2 [[orchestrator.train.env]] name = "swe" ratio = 0.3 -taskset = { id = "r2e-gym-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["intellect-3.1", "swe"] } } +env.taskset = { id = "r2e-gym-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["intellect-3.1", "swe"] } } [[orchestrator.train.env]] name = "deepdive" ratio = 0.2 -taskset = { id = "deepdive-v1" } -harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], runtime = { type = "prime", labels = ["intellect-3.1", "deepdive"] } } +env.taskset = { id = "deepdive-v1" } +env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], runtime = { type = "prime", labels = ["intellect-3.1", "deepdive"] } } [[orchestrator.train.env]] name = "math" ratio = 0.3 -taskset = { id = "i3_math_v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "i3_math_v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [[orchestrator.train.env]] name = "logic" ratio = 0.2 -taskset = { id = "i3_logic_v1", filter = { max = 0.874 } } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "i3_logic_v1", filter = { max = 0.874 } } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [[orchestrator.train.env]] name = "code" ratio = 0.2 -taskset = { id = "i3_code_v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "i3_code_v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [[orchestrator.pre_batch_filters]] type = "zero_advantage" @@ -86,13 +86,13 @@ interval = 25 [[orchestrator.eval.env]] name = "swe-bench-verified" -taskset = { id = "swebench-verified-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["intellect-3.1", "swe-bench-verified"] } } +env.taskset = { id = "swebench-verified-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["intellect-3.1", "swe-bench-verified"] } } [[orchestrator.eval.env]] name = "aime2025" -taskset = { id = "aime25-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "aime25-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference.parallel] tp = 8 diff --git a/examples/advanced/minimax-m2.5/swe.toml b/examples/advanced/minimax-m2.5/swe.toml index adedc819..9f2dd8d7 100644 --- a/examples/advanced/minimax-m2.5/swe.toml +++ b/examples/advanced/minimax-m2.5/swe.toml @@ -51,16 +51,16 @@ max_off_policy_steps = 16 [[orchestrator.train.env]] name = "swe" -taskset = { id = "r2e-gym-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["minimax-swe", "swe"] } } +env.taskset = { id = "r2e-gym-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["minimax-swe", "swe"] } } [orchestrator.eval] interval = 25 [[orchestrator.eval.env]] name = "swe-bench-verified" -taskset = { id = "swebench-verified-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["minimax-swe", "swe-bench-verified"] } } +env.taskset = { id = "swebench-verified-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["minimax-swe", "swe-bench-verified"] } } [inference.parallel] tp = 8 diff --git a/examples/advanced/nemotron-3-super/swe.toml b/examples/advanced/nemotron-3-super/swe.toml index e2430dd3..9b625a93 100644 --- a/examples/advanced/nemotron-3-super/swe.toml +++ b/examples/advanced/nemotron-3-super/swe.toml @@ -83,8 +83,8 @@ truncate_history_thinking = false [[orchestrator.train.env]] name = "scaleswe" -taskset = { id = "scaleswe-v1" } -harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] } } +env.taskset = { id = "scaleswe-v1" } +env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] } } [orchestrator.prime_monitor] @@ -93,9 +93,9 @@ interval = 20 [[orchestrator.eval.env]] name = "swebench-verified" -taskset = { id = "swebench-verified-v1" } -harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] } } -timeout = { rollout = 3600 } +env.taskset = { id = "swebench-verified-v1" } +env.agent.harness = { id = "rlm", summarize_at_tokens = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] } } +env.agent.timeout = { rollout = 3600 } [inference] enable_expert_parallel = true diff --git a/examples/advanced/qwen3-30b-a3b/math.toml b/examples/advanced/qwen3-30b-a3b/math.toml index c8d7b24d..3fefccc5 100644 --- a/examples/advanced/qwen3-30b-a3b/math.toml +++ b/examples/advanced/qwen3-30b-a3b/math.toml @@ -50,16 +50,16 @@ max_completion_tokens = 32768 [[orchestrator.train.env]] name = "math" -taskset = { id = "i3_math_v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "i3_math_v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 25 [[orchestrator.eval.env]] name = "aime2025" -taskset = { id = "aime25-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "aime25-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference.parallel] tp = 8 \ No newline at end of file diff --git a/examples/advanced/qwen3-30b-a3b/swe.toml b/examples/advanced/qwen3-30b-a3b/swe.toml index 2a7b8c48..2eff6c9b 100644 --- a/examples/advanced/qwen3-30b-a3b/swe.toml +++ b/examples/advanced/qwen3-30b-a3b/swe.toml @@ -48,16 +48,16 @@ max_off_policy_steps = 16 [[orchestrator.train.env]] name = "swe" -taskset = { id = "r2e-gym-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["qwen30b-swe", "swe"] } } +env.taskset = { id = "r2e-gym-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["qwen30b-swe", "swe"] } } [orchestrator.eval] interval = 25 [[orchestrator.eval.env]] name = "swe-bench-verified" -taskset = { id = "swebench-verified-v1" } -harness = { id = "bash", runtime = { type = "prime", labels = ["qwen30b-swe", "swe-bench-verified"] } } +env.taskset = { id = "swebench-verified-v1" } +env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["qwen30b-swe", "swe-bench-verified"] } } [inference.parallel] tp = 8 \ No newline at end of file diff --git a/examples/advanced/qwen3-30b-a3b/tool.toml b/examples/advanced/qwen3-30b-a3b/tool.toml index 9ba89dd2..36243892 100644 --- a/examples/advanced/qwen3-30b-a3b/tool.toml +++ b/examples/advanced/qwen3-30b-a3b/tool.toml @@ -36,8 +36,8 @@ group_size = 16 max_off_policy_steps = 32 [[orchestrator.train.env]] -taskset = { id = "general-agent-v1", task = { tools = { colocated = true } }, min_tier = 1 } -harness = { id = "null", runtime = { type = "modal" } } +env.taskset = { id = "general-agent-v1", task = { tools = { colocated = true } }, min_tier = 1 } +env.agent.harness = { id = "null", runtime = { type = "modal" } } [inference] gpu_memory_utilization = 0.85 diff --git a/examples/basic/alphabet-sort/rl.toml b/examples/basic/alphabet-sort/rl.toml index 830850a3..114e2b16 100644 --- a/examples/basic/alphabet-sort/rl.toml +++ b/examples/basic/alphabet-sort/rl.toml @@ -33,7 +33,7 @@ max_completion_tokens = 768 [[orchestrator.train.env]] name = "alphabet-sort" -taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [inference] # Default inference config diff --git a/examples/basic/hendrycks-sanity/rl.toml b/examples/basic/hendrycks-sanity/rl.toml index 8076c0f8..e10198a1 100644 --- a/examples/basic/hendrycks-sanity/rl.toml +++ b/examples/basic/hendrycks-sanity/rl.toml @@ -18,16 +18,16 @@ seq_len = 8192 [[orchestrator.train.env]] name = "hendrycks-math" -taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.eval] interval = 50 [[orchestrator.eval.env]] name = "aime2024" -taskset = { id = "aime24-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "aime24-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } group_size = 32 [trainer.model] diff --git a/examples/basic/reverse-text/rl.toml b/examples/basic/reverse-text/rl.toml index 2c4694dc..9cf5d9a4 100644 --- a/examples/basic/reverse-text/rl.toml +++ b/examples/basic/reverse-text/rl.toml @@ -17,8 +17,8 @@ max_completion_tokens = 128 [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [trainer.optim] lr = 3e-6 diff --git a/examples/basic/wiki-search/rl.toml b/examples/basic/wiki-search/rl.toml index 9ae98575..eb757e63 100644 --- a/examples/basic/wiki-search/rl.toml +++ b/examples/basic/wiki-search/rl.toml @@ -46,8 +46,8 @@ enforce = true [[orchestrator.train.env]] name = "wiki-search" -taskset = { id = "wiki-search-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "wiki-search-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [ckpt] # Checkpoint at the end of training diff --git a/examples/basic/wordle/rl.toml b/examples/basic/wordle/rl.toml index 048b324d..7db5537a 100644 --- a/examples/basic/wordle/rl.toml +++ b/examples/basic/wordle/rl.toml @@ -20,8 +20,8 @@ group_size = 16 [[orchestrator.train.env]] name = "wordle" -taskset = { id = "wordle-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "wordle-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } [orchestrator.train.sampling] max_completion_tokens = 1024 diff --git a/packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py b/packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py index 2c11a4dd..1f32abd1 100644 --- a/packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py +++ b/packages/prime-rl-configs/src/prime_rl/configs/orchestrator.py @@ -172,24 +172,16 @@ class EnvConfig(vf.EnvServerConfig): data["pool"] = {"type": "static", "num_workers": num_workers} return data - @property - def is_legacy(self) -> bool: - """A v0/legacy env (run via the bridge): an ``id`` is set and no v1 ``taskset`` is.""" - return not self.taskset.id - - @property - def env_id(self) -> str: - """The env identifier — the v1 taskset id (v1) or the legacy env id (v0).""" - return self.taskset.id or self.id or "" - @property def resolved_name(self) -> str: return self.name or self.env_id @model_validator(mode="after") def validate_env(self): - if not self.taskset.id and not self.id: - raise ValueError('no env configured — set taskset = { id = "" } (v1) or id = "" (v0/legacy)') + if not self.env_id: + raise ValueError( + 'no env configured — set env = { taskset = { id = "" } } (v1) or id = "" (v0/legacy)' + ) if self.resolved_name == "agg": raise ValueError( 'Environment name "agg" is reserved for cross-env metric aggregation. Use a different name or id.' @@ -200,13 +192,16 @@ class EnvConfig(vf.EnvServerConfig): def resolve_legacy_env_kwargs(self): """For a v0/legacy env, surface the v1 knobs the legacy bridge applies via ``extra_env_kwargs`` (``env.set_kwargs(...)``): the per-rollout wall-clock timeout and - the multi-turn completion-token budget. (``max_seq_len`` is added per train run in - ``OrchestratorConfig.resolve_env_config``, which knows ``seq_len``.)""" + the multi-turn completion-token budget, read off ``env.agent``. (``max_seq_len`` is + added per train run in ``OrchestratorConfig.resolve_env_config``, which knows + ``seq_len``.)""" if self.is_legacy: - if self.timeout.rollout is not None: - self.extra_env_kwargs["timeout_seconds"] = self.timeout.rollout - if self.max_output_tokens is not None: - self.extra_env_kwargs["max_total_completion_tokens"] = self.max_output_tokens + agent = getattr(self.env, "agent", None) + if agent is not None: + if agent.timeout.rollout is not None: + self.extra_env_kwargs["timeout_seconds"] = agent.timeout.rollout + if agent.max_output_tokens is not None: + self.extra_env_kwargs["max_total_completion_tokens"] = agent.max_output_tokens return self diff --git a/skills/configs/SKILL.md b/skills/configs/SKILL.md index ae9f1e59..1aa0d006 100644 --- a/skills/configs/SKILL.md +++ b/skills/configs/SKILL.md @@ -43,11 +43,11 @@ Incompatible combinations (e.g. CP requires flash attention) must raise in a `mo ```toml [[orchestrator.train.env]] name = "reverse-text" -taskset = { id = "reverse-text-v1" } -harness = { id = "null", runtime = { type = "subprocess" } } +env.taskset = { id = "reverse-text-v1" } +env.agent.harness = { id = "null", runtime = { type = "subprocess" } } ``` -CLI: `--orchestrator.train.env.0.taskset.id reverse-text-v1`. +CLI: `--orchestrator.train.env.0.env.taskset.id reverse-text-v1`. **Dicts** — TOML uses a section; CLI takes a JSON string: `--vllm-extra '{"key1": "value1"}'`. This works for plain `dict` fields only — nested pydantic-model fields (e.g. `algo`) reject JSON strings; use dotted keys (`--orchestrator.algo.type max_rl`) or a TOML overlay file. diff --git a/skills/training/monitor-run/SKILL.md b/skills/training/monitor-run/SKILL.md index 83a0fde9..7e92283b 100644 --- a/skills/training/monitor-run/SKILL.md +++ b/skills/training/monitor-run/SKILL.md @@ -137,18 +137,21 @@ curl -s http://localhost:8000/metrics | grep -E "num_requests|gpu_cache_usage" {output_dir}/rollouts/step_N/{train,eval}/effective/traces.jsonl # written per finalized batch / eval epoch ``` -JSONL files of `vf.Trace` records (training tensors excluded). `all` gets every completed -rollout the moment it arrives — errored, filtered, and never-batched ones included — so it's -crash-durable; `effective` gets the clean subset that went into the step's train batch (eval: -the non-errored epoch cohort; multiple eval envs share the step file). Each record carries -`run` (`{type, id, step}`; for eval, `step` is the trigger step), `verifiers` (producing build), -`agent` (model, sampling, harness), and `runtime` (config + provisioned resource id, e.g. the -sandbox id), plus `env_name`, `group_id`, and `policy_version` under `info`. +JSONL files of `vf.Trace` records (training tensors excluded), one line per trace — a +multi-agent env's episode contributes several lines sharing one `info.episode_id`. `all` +gets every completed rollout the moment it arrives — errored, filtered, and never-batched +ones included — so it's crash-durable; `effective` gets the clean trainable subset that went +into the step's train batch (eval: the non-errored trainable epoch cohort; multiple eval envs +share the step file) — untrainable traces (a frozen judge's) appear only in `all`. Each record carries `run` (`{type, id, step}`; for eval, `step` is the trigger step), +`verifiers` (producing build), `agent` (model, sampling, harness, `name`, `trainable`), `ok` +(the success sentinel — `errors` alone keeps retry history even after a recovery), and +`runtime` (config + provisioned resource id, e.g. the sandbox id), plus `env_name`, +`group_id`, `episode_id`, and `policy_version` under `info`. ```bash wc -l {output_dir}/rollouts/step_42/train/{all,effective}/traces.jsonl jq '.rewards' {output_dir}/rollouts/step_42/train/effective/traces.jsonl -jq 'select(.errors != []) | {id, env: .info.env_name, runtime}' {output_dir}/rollouts/step_*/train/all/traces.jsonl +jq 'select(.ok | not) | {id, env: .info.env_name, runtime}' {output_dir}/rollouts/step_*/train/all/traces.jsonl ``` The binary batches consumed by the trainer still live at `{output_dir}/rollouts/step_N/train_rollouts.bin`, next to the trace subtrees. diff --git a/src/prime_rl/orchestrator/dispatcher.py b/src/prime_rl/orchestrator/dispatcher.py index 11a1ab4d..91cc3c21 100644 --- a/src/prime_rl/orchestrator/dispatcher.py +++ b/src/prime_rl/orchestrator/dispatcher.py @@ -3,8 +3,8 @@ - Capacity (``max_inflight_rollouts``) is shared across train + eval. A group-scoring task that runs N rollouts in one call reserves N permits. - Optional rate limiting via ``AsyncLimiter(tasks_per_minute, 60)``. -- Emit-everything invariant: every dispatched rollout eventually reaches - ``out_q`` exactly once as a ``Rollout``. Failures +- Emit-everything invariant: every dispatched env-rollout eventually reaches + ``out_q`` exactly once, as one episode (a ``list[Rollout]``). Failures (env error, empty trajectory, task exception, off-policy cancel) carry ``trace.error`` set; sinks decide drop / partial-train policy. - ``DispatcherMode.PREFER_TRAIN`` / ``PREFER_EVAL`` controls which kind to @@ -152,8 +152,9 @@ class RolloutDispatcher: self.inflight: dict[asyncio.Task, InflightRollout] = {} self.groups: dict[uuid.UUID, GroupState] = {} - # Bounded so the dispatcher backpressures on a slow sink - self.out_q: asyncio.Queue[Rollout] = asyncio.Queue(maxsize=max(8, self.max_inflight)) + # Bounded so the dispatcher backpressures on a slow sink. One entry per + # episode — the sinks count episodes, never loose traces. + self.out_q: asyncio.Queue[list[Rollout]] = asyncio.Queue(maxsize=max(8, self.max_inflight)) self.mode: DispatcherMode = DispatcherMode.PREFER_TRAIN # Set by the orchestrator after the final train step; pipeline then @@ -393,7 +394,7 @@ class RolloutDispatcher: ) async def schedule_group_rollout(self, group_id: uuid.UUID, group: GroupState) -> bool: - """Dispatch one ``run_rollout`` / ``run_group`` task for this group. + """Dispatch one ``run`` / ``run_group`` task for this group. Returns False only if we couldn't even schedule one rollout (no clients ready, no permits). Returns True after issuing one task — the caller @@ -454,7 +455,7 @@ class RolloutDispatcher: group.rollouts_to_schedule -= 1 await self.acquire(permits) task = asyncio.create_task( - env.run_rollout( + env.run( client=client, task_idx=group.task_idx, model_name=model_name, @@ -485,11 +486,13 @@ class RolloutDispatcher: self.inflight_permits -= n async def handle_completed_rollout(self, task: asyncio.Task) -> None: - """Emit every dispatched rollout exactly once to ``out_q``. Task - exceptions synthesize ``meta.rollout_count`` error markers so the - sink's count-to-``group_size`` finalization still triggers. - Cancelled tasks (popped by ``drop_group``) raise ``CancelledError`` - and are discarded — ``drop_group`` already emitted their markers. + """Emit every dispatched env-rollout exactly once to ``out_q``: a ``run`` + result as one episode, a legacy ``run_group`` result as ``rollout_count`` + single-trace episodes. Task exceptions synthesize ``rollout_count`` + error-marker episodes so the sink's count-to-``group_size`` finalization + still triggers. Cancelled tasks (popped by ``drop_group``) raise + ``CancelledError`` and are discarded — ``drop_group`` already emitted + their markers. """ meta = self.inflight.pop(task, None) if meta is None: @@ -501,6 +504,8 @@ class RolloutDispatcher: try: result = task.result() rollouts: list[Rollout] = result if isinstance(result, list) else [result] + if not rollouts: + raise RuntimeError("env run returned an empty episode (no traces)") except asyncio.CancelledError: return except Exception as exc: @@ -517,20 +522,28 @@ class RolloutDispatcher: for r in rollouts: if not r.has_error and r.num_turns == 0: # Empty trajectory: promote to an explicit error so the sink - # treats it like any other failure + # treats it like any other failure (``has_error`` reads ``ok``) r.errors.append(vf.Error(type="EmptyTrajectory", message="Rollout returned with no trajectory steps")) + r.ok = False get_logger().warning(f"Empty trajectory in group {meta.group_id} ({meta.env_name})") if r.has_error: self.metrics.record_error(kind=meta.kind, env_name=meta.env_name) - if not is_synth_exception: + if not is_synth_exception and r.error is not None: get_logger().warning( f"Rollout failed in group {meta.group_id} ({meta.env_name}) — {r.error.type}: {r.error.message}" ) - await self.emit_rollout(meta, group, r) + if meta.rollout_count == 1: + # A ``run`` task: the whole result is one episode. + await self.emit_episode(meta, group, rollouts) + else: + # A legacy ``run_group`` task: one single-trace episode per trace. + for r in rollouts: + await self.emit_episode(meta, group, [r]) - async def emit_rollout(self, meta: InflightRollout, group: GroupState | None, rollout: Rollout) -> None: - """Stamp prime-rl metadata onto the completed rollout and put it on ``out_q``. - Pops the group from ``self.groups`` once every member has been emitted.""" + async def emit_episode(self, meta: InflightRollout, group: GroupState | None, rollouts: list[Rollout]) -> None: + """Stamp prime-rl metadata onto one completed episode and put it on + ``out_q``. Pops the group from ``self.groups`` once every owed episode + has been emitted.""" eval_step = meta.eval_step policy_version = meta.policy_version if group is not None: @@ -540,15 +553,16 @@ class RolloutDispatcher: if group.emitted >= group.target_rollouts: self.groups.pop(meta.group_id, None) - rollout.kind = meta.kind - rollout.env_name = meta.env_name - rollout.group_id = meta.group_id - rollout.policy_version = policy_version - rollout.off_policy_steps = meta.off_policy_steps - if meta.kind == "eval": - assert eval_step is not None, "eval rollout missing eval_step" - rollout.eval_step = eval_step - await self.out_q.put(rollout) + for rollout in rollouts: + rollout.kind = meta.kind + rollout.env_name = meta.env_name + rollout.group_id = meta.group_id + rollout.policy_version = policy_version + rollout.off_policy_steps = meta.off_policy_steps + if meta.kind == "eval": + assert eval_step is not None, "eval rollout missing eval_step" + rollout.eval_step = eval_step + await self.out_q.put(rollouts) async def drop_group(self, group_id: uuid.UUID) -> int: """Cancel remaining in-flight tasks for this group and emit a @@ -578,10 +592,11 @@ class RolloutDispatcher: for _ in range(meta.rollout_count): trace = Rollout( task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)), + ok=False, errors=[vf.Error(type="Cancelled", message="Off-policy cancel")], stop_condition="error", ) - await self.emit_rollout(meta, group, trace) + await self.emit_episode(meta, group, [trace]) # For non-group-scoring envs, the group may have rollouts that # were never dispatched (``rollouts_to_schedule > 0``). Emit @@ -604,10 +619,11 @@ class RolloutDispatcher: for _ in range(unscheduled_cancelled): trace = Rollout( task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)), + ok=False, errors=[vf.Error(type="Cancelled", message="Off-policy cancel")], stop_condition="error", ) - await self.emit_rollout(fallback_meta, group, trace) + await self.emit_episode(fallback_meta, group, [trace]) cancelled = inflight_cancelled + unscheduled_cancelled if cancelled > 0: diff --git a/src/prime_rl/orchestrator/env_server/env_server.py b/src/prime_rl/orchestrator/env_server/env_server.py index 18dbcb46..19ad321b 100644 --- a/src/prime_rl/orchestrator/env_server/env_server.py +++ b/src/prime_rl/orchestrator/env_server/env_server.py @@ -1,7 +1,7 @@ from functools import partial from verifiers.v1 import pool_serve_kwargs -from verifiers.v1.serve import serve_env +from verifiers.v1.serve import env_config_data, serve_env from prime_rl.configs.env_server import EnvServerConfig from prime_rl.orchestrator.utils import setup_env_server_logging @@ -15,13 +15,13 @@ def run_server(config: EnvServerConfig): env = config.env address = env.address or "tcp://127.0.0.1:5000" # The env's ``pool`` (static or elastic) sizes the server; a v0/legacy env runs through - # the bridge, a v1 env is a native taskset — both serve vf.Trace over the same protocol, + # the bridge, a v1 env is a native env block — both speak the same serve protocol, # so the orchestrator is agnostic. serve_env applies the logging setup in this process # and in every spawned worker. server_kwargs = ( {"env_id": env.env_id, "env_args": env.args, "extra_env_kwargs": env.extra_env_kwargs} if env.is_legacy - else {"config": env} + else {"config_data": env_config_data(env.env)} ) serve_env( **pool_serve_kwargs(env.pool), diff --git a/src/prime_rl/orchestrator/envs.py b/src/prime_rl/orchestrator/envs.py index e9cf068f..9948d8f0 100644 --- a/src/prime_rl/orchestrator/envs.py +++ b/src/prime_rl/orchestrator/envs.py @@ -4,10 +4,10 @@ Each ``Env`` owns a v1 ``EnvServer`` (spawned as a child process, or an external one given by ``config.address``) and an ``EnvClient`` to drive it. The orchestrator never *runs* an environment: it asks the server for ``info`` (``num_tasks`` + whether group scoring is needed), then runs rollouts purely by -**task index**. The server returns a ``Trace`` (a plain ``model_dump`` — derived values are -properties, not serialized) which we validate into a ``Trace[WireTaskData]`` — a real ``vf.Trace`` -(never a loose dict) whose task keeps the env's -task-specific fields as extras (``WireTaskData`` allows them). The orchestrator never imports the +**task index**. The server answers one ``Episode`` per env-rollout, whose traces +we validate into ``Trace[WireTaskData]`` — real ``vf.Trace``\\ s (never loose +dicts) whose task keeps the env's task-specific +fields as extras (``WireTaskData`` allows them). The orchestrator never imports the env package: the env's *type* and *runtime* both live only in the server, and the orchestrator drives it purely by task index. (Nothing here reads typed env task fields — only ``task.idx`` and a full ``task.model_dump``, both of which ``WireTaskData`` preserves.) @@ -27,7 +27,7 @@ from pathlib import Path from typing import Generic, TypeVar import verifiers.v1 as vf -from verifiers.v1.serve import EnvClient +from verifiers.v1.serve import EnvClient, env_config_data from prime_rl.configs.orchestrator import EnvConfig, EvalEnvConfig, TrainEnvConfig from prime_rl.orchestrator.algo import Algorithm, build_algorithm @@ -135,7 +135,8 @@ class Env: extra_env_kwargs=self.config.extra_env_kwargs, ) if self.config.is_legacy - else dict(legacy=False, config=self.config) + # Picklable dict — the narrowed config class doesn't survive the spawn. + else dict(legacy=False, config_data=env_config_data(self.config.env)) ) process = ctx.Process( target=_run_env_server, @@ -168,17 +169,32 @@ class Env: sampling["extra_body"] = {**sampling.get("extra_body", {}), "cache_salt": cache_salt} return vf.SamplingConfig(**sampling) - async def run_rollout( + async def run( self, client: vf.ClientConfig, task_idx: int, model_name: str, cache_salt: str | None - ) -> Rollout: - """Run a single rollout for ``task_idx``; return a typed Trace.""" - wire = await self.env_client.run_rollout( + ) -> list[Rollout]: + """Run one episode for ``task_idx``; return its typed Traces. A zero-trace + episode raises (the dispatcher synthesizes the error marker); a not-``ok`` + episode marks its clean traces failed so partial episodes never train.""" + episode = await self.env_client.run( task_idx=task_idx, client=client, model=model_name, sampling=self._sampling(cache_salt), ) - return ROLLOUT_TYPE.model_construct(**dict(wire)) + if not episode.traces: + error = episode.error + detail = f"{error.type}: {error.message}" if error is not None else "no traces and no error recorded" + raise RuntimeError(f"env-rollout failed before any trace was minted — {detail}") + rollouts = [ROLLOUT_TYPE.model_construct(**dict(wire)) for wire in episode.traces] + for rollout in rollouts: + rollout.episode_id = episode.id + if not episode.ok and rollout.ok: + error = episode.error or vf.Error( + type="EpisodeFailed", message="A sibling trace in this episode failed" + ) + rollout.errors = [*rollout.errors, error] + rollout.ok = False + return rollouts async def run_group( self, client: vf.ClientConfig, task_idx: int, model_name: str, group_size: int, cache_salt: str | None diff --git a/src/prime_rl/orchestrator/eval_sink.py b/src/prime_rl/orchestrator/eval_sink.py index f9cbfeba..c02ebab7 100644 --- a/src/prime_rl/orchestrator/eval_sink.py +++ b/src/prime_rl/orchestrator/eval_sink.py @@ -3,12 +3,13 @@ Same shape as ``TrainSink``, but no tokenization / advantages / filters: 1. ``process_rollout`` — no-op. -2. ``process_group`` — at ``group_size`` arrivals, move the rollouts +2. ``process_group`` — at ``group_size`` episodes, move the rollouts (errored ones included) into the ``(env, eval_step)`` bucket. -3. ``process_batch`` — at ``num_examples × group_size`` arrivals, return an +3. ``process_batch`` — at ``num_examples × group_size`` episodes, return an ``EvalBatch`` with the full returned cohort (metrics are computed downstream). -``add()`` returns ``EvalBatch | None``. +``add()`` takes one episode (``list[Rollout]``) and returns ``EvalBatch | None``; +all accounting counts episodes, never loose traces. """ from __future__ import annotations @@ -28,20 +29,24 @@ class EvalSink: def __init__(self, *, eval_envs: EvalEnvs) -> None: self.eval_envs = eval_envs self.pending_groups: dict[uuid.UUID, list[Rollout]] = defaultdict(list) - # Bucket size IS the arrival count — ``process_group`` flushes - # everything in without filtering + # Episodes arrived per group / per batch bucket — the finalization counts. + self.pending_group_episodes: dict[uuid.UUID, int] = defaultdict(int) self.pending_batches: dict[tuple[str, int], list[Rollout]] = defaultdict(list) + self.pending_batch_episodes: dict[tuple[str, int], int] = defaultdict(int) - def add(self, rollout: Rollout) -> EvalBatch | None: - """Process one arrival; finalize the group on the ``group_size``-th - arrival and the per-env epoch on the ``num_examples × group_size``-th.""" - env_name = rollout.env_name - self.process_rollout(rollout) - bkey = (env_name, rollout.eval_step) - self.pending_groups[rollout.group_id].append(rollout) - if len(self.pending_groups[rollout.group_id]) >= self.group_size_for(env_name): - self.process_group(rollout.group_id) - if len(self.pending_batches[bkey]) >= self.batch_size_for(env_name): + def add(self, episode: list[Rollout]) -> EvalBatch | None: + """Process one episode arrival; finalize the group on the ``group_size``-th + episode and the per-env epoch on the ``num_examples × group_size``-th.""" + env_name = episode[0].env_name + group_id = episode[0].group_id + for rollout in episode: + self.process_rollout(rollout) + bkey = (env_name, episode[0].eval_step) + self.pending_groups[group_id].extend(episode) + self.pending_group_episodes[group_id] += 1 + if self.pending_group_episodes[group_id] >= self.group_size_for(env_name): + self.process_group(group_id) + if self.pending_batch_episodes[bkey] >= self.batch_size_for(env_name): return self.process_batch(bkey) return None @@ -49,7 +54,7 @@ class EvalSink: return self.eval_envs.get(env_name).config.group_size def batch_size_for(self, env_name: str) -> int: - """``num_examples × group_size`` — total rollouts expected for one + """``num_examples × group_size`` — total episodes expected for one epoch of ``env_name``.""" env = self.eval_envs.get(env_name) return len(env.examples) * env.config.group_size @@ -57,18 +62,18 @@ class EvalSink: def batch_progress(self) -> list[tuple[str, int, int, int, int]]: """One entry per accumulating ``(env, eval_step)`` batch: ``(env_name, eval_step, batch_count, expected, buffered)``. - ``batch_count`` is finalized-group survivors in ``pending_batches``; - ``buffered`` is partial-group arrivals from non-group-scoring envs.""" - batch_counts: dict[tuple[str, int], int] = {bkey: len(bucket) for bkey, bucket in self.pending_batches.items()} + ``batch_count`` is finalized-group episodes in ``pending_batches``; + ``buffered`` is partial-group episode arrivals from non-group-scoring envs.""" + batch_counts: dict[tuple[str, int], int] = dict(self.pending_batch_episodes) buffered: dict[tuple[str, int], int] = {} - for rollouts in self.pending_groups.values(): + for group_id, rollouts in self.pending_groups.items(): if not rollouts: continue env_name = rollouts[0].env_name if self.eval_envs.get(env_name).requires_group_scoring: continue bkey = (env_name, rollouts[0].eval_step) - buffered[bkey] = buffered.get(bkey, 0) + len(rollouts) + buffered[bkey] = buffered.get(bkey, 0) + self.pending_group_episodes.get(group_id, 0) return [ ( env_name, @@ -93,6 +98,7 @@ class EvalSink: def process_group(self, group_id: uuid.UUID) -> None: group = self.pending_groups.pop(group_id, []) + episodes = self.pending_group_episodes.pop(group_id, 0) if not group: return env_name = group[0].env_name @@ -100,6 +106,7 @@ class EvalSink: eval_step = group[0].eval_step bucket = self.pending_batches[(env_name, eval_step)] bucket.extend(group) + self.pending_batch_episodes[(env_name, eval_step)] += episodes survivors = [r for r in group if not r.has_error] num_errored = len(group) - len(survivors) @@ -117,4 +124,5 @@ class EvalSink: does no aggregation.""" env_name, step = key rollouts = self.pending_batches.pop(key, []) + self.pending_batch_episodes.pop(key, None) return EvalBatch(env_name=env_name, step=step, rollouts=EvalRollouts(rollouts)) diff --git a/src/prime_rl/orchestrator/metrics.py b/src/prime_rl/orchestrator/metrics.py index b2e38da3..859eec29 100644 --- a/src/prime_rl/orchestrator/metrics.py +++ b/src/prime_rl/orchestrator/metrics.py @@ -337,8 +337,9 @@ class EvalMetrics(RolloutMetrics): class TrainRollouts: - """A list of train rollouts (everything that came back, errored + filtered included). ``effective`` - is the clean subset (a view of the same traces); ``metrics`` builds ``TrainMetrics`` over them.""" + """A list of train rollouts (everything that came back, errored + filtered + untrainable + included). ``effective`` is the clean trainable subset (a view of the same traces); + ``metrics`` builds ``TrainMetrics`` over them.""" def __init__(self, rollouts: list[Rollout] | None = None) -> None: self.rollouts = rollouts if rollouts is not None else [] @@ -354,7 +355,7 @@ class TrainRollouts: @property def effective(self) -> TrainRollouts: - return TrainRollouts([r for r in self.rollouts if not r.has_error and not r.is_filtered]) + return TrainRollouts([r for r in self.rollouts if not r.has_error and not r.is_filtered and r.trainable]) def by_env(self) -> dict[str, TrainRollouts]: grouped: dict[str, list[Rollout]] = {} @@ -368,7 +369,8 @@ class TrainRollouts: class EvalRollouts: - """A list of eval rollouts (errored included). ``effective`` is the non-errored subset (a view). + """A list of eval rollouts (errored + untrainable included). ``effective`` is the + non-errored trainable subset (a view). ``group_size`` (rollouts per example, the ``avg@k`` k) is derived from the full epoch and carried onto ``effective`` so both subsets share one stable key; ``metrics`` builds ``EvalMetrics``.""" @@ -384,18 +386,21 @@ class EvalRollouts: @property def group_size(self) -> int: - """The largest group (equals the configured group size whenever one example kept all its - rollouts); a subview carries its parent's value so ``avg@k`` doesn't drift across subsets.""" + """The largest group in trainable (policy) traces — equals the configured group size + whenever one example kept all its rollouts; untrainable traces don't count, so a + multi-agent episode doesn't inflate ``k``. A subview carries its parent's value so + ``avg@k`` doesn't drift across subsets.""" if self._group_size is not None: return self._group_size counts: dict = {} for r in self.rollouts: - counts[r.group_id] = counts.get(r.group_id, 0) + 1 + if r.trainable: + counts[r.group_id] = counts.get(r.group_id, 0) + 1 return max(counts.values(), default=0) @property def effective(self) -> EvalRollouts: - return EvalRollouts([r for r in self.rollouts if not r.has_error], group_size=self.group_size) + return EvalRollouts([r for r in self.rollouts if not r.has_error and r.trainable], group_size=self.group_size) @property def metrics(self) -> EvalMetrics: diff --git a/src/prime_rl/orchestrator/orchestrator.py b/src/prime_rl/orchestrator/orchestrator.py index 5084de70..98663dc7 100644 --- a/src/prime_rl/orchestrator/orchestrator.py +++ b/src/prime_rl/orchestrator/orchestrator.py @@ -466,7 +466,7 @@ class Orchestrator: trim_process_memory() async def main_loop(self) -> None: - """Consume ``Rollout``\\ s from the dispatcher and route them + """Consume episodes (``list[Rollout]``) from the dispatcher and route them to the train / eval sink. Both sinks return a finalized batch (or ``None``) from ``add()``; we just dispatch on the result.""" while not self.stopped.is_set(): @@ -476,7 +476,7 @@ class Orchestrator: break try: - rollout: Rollout = await asyncio.wait_for(self.dispatcher.out_q.get(), timeout=0.5) + episode: list[Rollout] = await asyncio.wait_for(self.dispatcher.out_q.get(), timeout=0.5) except asyncio.TimeoutError: continue @@ -484,33 +484,36 @@ class Orchestrator: # ``all`` trace file the moment it arrives, so it survives crashes and drains. # Train rollouts belong to the batch window currently collecting (``progress.step``), # eval rollouts to the step whose eval triggered them. - step = rollout.eval_step if rollout.kind == "eval" else self.progress.step + kind = episode[0].kind + step = episode[0].eval_step if kind == "eval" else self.progress.step assert step is not None run: vf.RunInfo = ( vf.EvalRunInfo(id=self.monitor.run_id, step=step) - if rollout.kind == "eval" + if kind == "eval" else vf.TrainRunInfo(id=self.monitor.run_id, step=step) ) - rollout.stamp( - run, - env_name=rollout.env_name, - group_id=str(rollout.group_id), - policy_version=rollout.policy_version, - ) + for rollout in episode: + rollout.stamp( + run, + env_name=rollout.env_name, + group_id=str(rollout.group_id), + episode_id=rollout.episode_id, + policy_version=rollout.policy_version, + ) await asyncio.to_thread( save_rollouts, - [rollout.to_record()], - get_trace_path(self.config.output_dir, step, rollout.kind, "all"), + [rollout.to_record() for rollout in episode], + get_trace_path(self.config.output_dir, step, kind, "all"), ) - if rollout.kind == "eval": + if kind == "eval": assert self.eval_sink is not None # eval rollouts only emitted when eval is configured - eval_batch = self.eval_sink.add(rollout) + eval_batch = self.eval_sink.add(episode) if eval_batch is not None: await self.finalize_eval_batch(eval_batch) continue - train_batch = await self.train_sink.add(rollout) + train_batch = await self.train_sink.add(episode) # In drain mode any late-arriving train batch is dropped — we # don't want to ship past ``max_steps`` if train_batch is not None and not self.draining and not self.stopped.is_set(): diff --git a/src/prime_rl/orchestrator/train_sink.py b/src/prime_rl/orchestrator/train_sink.py index 310e3aea..2b135ae5 100644 --- a/src/prime_rl/orchestrator/train_sink.py +++ b/src/prime_rl/orchestrator/train_sink.py @@ -3,15 +3,17 @@ 1. ``process_rollout`` — eager per-rollout tokenization (overlaps with dispatcher producing more rollouts), then the env algorithm's ``finalize_rollout`` (rollout-local scoring + any reference I/O). Errored - rollouts skip this. -2. ``process_group`` — filters errored rollouts, hands survivors to the env - algorithm's ``finalize_group`` (advantages + per-sample wire stamping), - runs the pre-batch filter pass. + and untrainable rollouts skip this. +2. ``process_group`` — filters errored rollouts, hands the trainable + survivors to the env algorithm's ``finalize_group`` (advantages + + per-sample wire stamping), runs the pre-batch filter pass. 3. ``process_batch`` — applies post-batch filter annotations and assembles the trainer-bound ``TrainingSample`` list. Returns a ``TrainBatch``. -``add()`` returns ``TrainBatch | None``. I/O concerns (ship to trainer, -save_rollouts, monitor.log) live on the orchestrator. +``add()`` takes one episode (``list[Rollout]``) and returns +``TrainBatch | None``; group accounting counts episodes, never loose traces. +I/O concerns (ship to trainer, save_rollouts, monitor.log) live on the +orchestrator. """ from __future__ import annotations @@ -78,6 +80,9 @@ class TrainSink: # isn't unique — the same task can be re-sampled while an # earlier group is still in flight self.pending_groups: dict[uuid.UUID, list[Rollout]] = defaultdict(list) + # Episodes arrived per group — the finalization count (an episode may + # add several traces to ``pending_groups`` but counts once here). + self.pending_group_episodes: dict[uuid.UUID, int] = defaultdict(int) self.pending_batch: list[Rollout] = [] # Running payload-token total of ``pending_batch`` (token-batched # runs), kept in sync on append/pop so the readiness check never @@ -92,22 +97,6 @@ class TrainSink: def group_size_for(self, env_name: str) -> int: return self.train_envs.get(env_name).config.group_size - def in_progress_groups(self) -> list[list[Rollout]]: - """Per-rollout groups currently accumulating in ``pending_groups`` — - i.e. groups that haven't hit ``group_size`` yet, so the pipeline log - can reflect partial-group progress. Skips group-scoring envs (whose - rollouts only make sense as a unit — the user expects per-group - fill, not per-rollout, for those).""" - out: list[list[Rollout]] = [] - for rollouts in self.pending_groups.values(): - if not rollouts: - continue - env_name = rollouts[0].env_name - if self.train_envs.get(env_name).requires_group_scoring: - continue - out.append(rollouts) - return out - def batch_progress(self) -> tuple[int, int, str]: """``(current, target, unit)`` for the train batch — counts only ``pending_batch`` (survivors of finalized groups, queued for the @@ -119,9 +108,13 @@ class TrainSink: return self.pending_tokens, self.token_batch_size, "tokens" def buffered_count(self) -> int: - """Rollouts that have arrived but sit in not-yet-complete groups + """Episodes that have arrived but sit in not-yet-complete groups (non-group-scoring envs) — buffered in the sink ahead of the batch.""" - return sum(len(group) for group in self.in_progress_groups()) + return sum( + self.pending_group_episodes.get(group_id, 0) + for group_id, rollouts in self.pending_groups.items() + if rollouts and not self.train_envs.get(rollouts[0].env_name).requires_group_scoring + ) def pending_batch_by_env(self) -> dict[str, int]: """Per-env breakdown of ``batch_progress()`` (``pending_batch`` only); @@ -131,17 +124,20 @@ class TrainSink: counts[r.env_name] += 1 return dict(counts) - async def add(self, rollout: Rollout) -> TrainBatch | None: - """Process one arrival; finalize the group on the ``group_size``-th - arrival; return a ``TrainBatch`` if the finalization pushed (or left) - the batch over its threshold. Arrivals into still-incomplete groups - never ship a batch.""" - await self.process_rollout(rollout) - env_name = rollout.env_name - self.pending_groups[rollout.group_id].append(rollout) - if len(self.pending_groups[rollout.group_id]) < self.group_size_for(env_name): + async def add(self, episode: list[Rollout]) -> TrainBatch | None: + """Process one episode arrival; finalize the group on the + ``group_size``-th episode; return a ``TrainBatch`` if the finalization + pushed (or left) the batch over its threshold. Arrivals into + still-incomplete groups never ship a batch.""" + group_id = episode[0].group_id + env_name = episode[0].env_name + for rollout in episode: + await self.process_rollout(rollout) + self.pending_groups[group_id].extend(episode) + self.pending_group_episodes[group_id] += 1 + if self.pending_group_episodes[group_id] < self.group_size_for(env_name): return None - await self.process_group(rollout.group_id) + await self.process_group(group_id) # ``pending_batch`` only grows on group finalization, so readiness is # only re-checked here — the window of a shipped batch then always # contains at least the group that finalized it. @@ -158,8 +154,8 @@ class TrainSink: """Build training samples from the rollout's Trace (one per branch), walking the message graph. Training is renderer-only across all modes (RL/OPD student, SFT teacher), so every node already carries its tokens. Errored rollouts are dropped at the group - level, so skip them here.""" - if rollout.has_error: + level, so skip them here; untrainable traces never become training data.""" + if rollout.has_error or not rollout.trainable: return samples = await asyncio.to_thread( trace_to_samples, @@ -178,6 +174,7 @@ class TrainSink: when ``requires_group_scoring`` and any failed), assign advantages, run pre-batch filters, append survivors to ``pending_batch``.""" group = self.pending_groups.pop(group_id, []) + self.pending_group_episodes.pop(group_id, None) if not group: return # Window membership follows group finalization, not arrival: a rollout @@ -200,10 +197,12 @@ class TrainSink: f"rollouts={len(group)} (errored={num_errored}) | dropped: group-scored partial" ) return + # Untrainable traces carry no samples and must not skew the group baseline. + survivors = [r for r in survivors if r.trainable] if not survivors: get_logger().debug( f"Finished group | env={env_name} task_idx={task_idx} | " - f"rollouts={len(group)} (errored={num_errored}) | dropped: all failed" + f"rollouts={len(group)} (errored={num_errored}) | dropped: no trainable survivors" ) return diff --git a/src/prime_rl/orchestrator/types.py b/src/prime_rl/orchestrator/types.py index 79e283e5..2b3e3989 100644 --- a/src/prime_rl/orchestrator/types.py +++ b/src/prime_rl/orchestrator/types.py @@ -41,7 +41,7 @@ RolloutKind = Literal["train", "eval"] @dataclass class InflightRollout: """Per-task scheduling state in the dispatcher; one entry per in-flight - ``run_rollout`` / ``run_group`` task.""" + ``run`` / ``run_group`` task.""" kind: RolloutKind env_name: str @@ -88,6 +88,9 @@ class Rollout(vf.Trace[DataT], Generic[DataT]): kind: RolloutKind = Field(default="train", exclude=True) env_name: str = Field(default="", exclude=True) group_id: uuid.UUID = Field(default_factory=uuid.uuid4, exclude=True) + # Links the traces of one episode; stamped into ``info`` on arrival so + # saved records keep their grouping. + episode_id: str = Field(default="", exclude=True) policy_version: int = Field(default=0, exclude=True) off_policy_steps: int = Field(default=0, exclude=True) samples: list[TrainingSample] = Field(default_factory=list, exclude=True) diff --git a/src/prime_rl/utils/monitor/prime.py b/src/prime_rl/utils/monitor/prime.py index 82dc3216..176c51e2 100644 --- a/src/prime_rl/utils/monitor/prime.py +++ b/src/prime_rl/utils/monitor/prime.py @@ -336,7 +336,7 @@ class PrimeMonitor(Monitor): rows = [] for sample_id, rollout in enumerate(rollouts): - sample = trace_to_sample(rollout, rollout_number=sample_id + 1) + sample = trace_to_sample(rollout, rollout_number=sample_id + 1, episode_id=rollout.episode_id or None) trajectory = sample["trajectory"] if not trajectory: # no branches (e.g. a rollout that errored before any message) continue diff --git a/tests/unit/orchestrator/test_metrics.py b/tests/unit/orchestrator/test_metrics.py index c6826b60..3b417f56 100644 --- a/tests/unit/orchestrator/test_metrics.py +++ b/tests/unit/orchestrator/test_metrics.py @@ -24,6 +24,7 @@ def mk( rewards: dict | None = None, env_name: str = "env", group_id: str = "g0", + trainable: bool = True, is_trainable: bool = True, is_filtered: bool = False, filter_results: dict | None = None, @@ -51,6 +52,7 @@ def mk( metrics=metrics or {}, env_name=env_name, group_id=group_id, + trainable=trainable, is_trainable=is_trainable, is_filtered=is_filtered, filter_results=filter_results or {}, diff --git a/uv.lock b/uv.lock index 28651378..9a6ae4e6 100644 --- a/uv.lock +++ b/uv.lock @@ -94,6 +94,7 @@ members = [ "prime-rl", "programbench-v1", "prolog-v1", + "proposer-solver-v1", "r2e-gym-v1", "redsearcher-v1", "reverse-text-v1", @@ -5453,6 +5454,17 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/3a/ed/1cdcab6ba3d6ab7feca11fc14f0eeea80755bb53ef4e892079f31b10a25f/propcache-0.5.2-py3-none-any.whl", hash = "sha256:be1ddfcbb376e3de5d2e2db1d58d6d67463e6b4f9f040c000de8e300295465fe", size = 14036, upload-time = "2026-05-08T21:02:10.673Z" }, ] +[[package]] +name = "proposer-solver-v1" +version = "0.1.0" +source = { editable = "deps/verifiers/environments/proposer_solver_v1" } +dependencies = [ + { name = "verifiers" }, +] + +[package.metadata] +requires-dist = [{ name = "verifiers" }] + [[package]] name = "protobuf" version = "6.33.6" @@ -7893,6 +7905,7 @@ examples = [ { name = "glossary-v1", editable = "deps/verifiers/environments/glossary_v1" }, { name = "gsm8k-v1", editable = "deps/verifiers/environments/gsm8k_v1" }, { name = "openenv-wordle-v1", editable = "deps/verifiers/environments/openenv_wordle_v1" }, + { name = "proposer-solver-v1", editable = "deps/verifiers/environments/proposer_solver_v1" }, { name = "reverse-text-v1", editable = "deps/verifiers/environments/reverse_text_v1" }, { name = "scratchpad-v1", editable = "deps/verifiers/environments/scratchpad_v1" }, { name = "wiki-search-v1", editable = "deps/verifiers/environments/wiki_search_v1" },