Compare commits

..
2 Commits
Author SHA1 Message Date
carsten 6087c3addb Add LoRA adapter warm start and longer adapter reload timeouts
- model.lora.init_path on trainer and orchestrator initializes a fresh
  optimizer run from an attention-only PEFT adapter (strict shape, key,
  and finiteness checks).
- Adapter reload read timeout 30s -> 300s and retry budget 120s -> 600s;
  loaded TP2/DP3 servers can take minutes to apply an update.
2026-10-14 12:24:08 +00:00
carsten 99957ccd93 Point renderers submodule at dphn/renderers trinity branch
Pulls in the text-level Hermes tool-call parser Trinity needs.
2026-10-14 12:24:08 +00:00
71 changed files with 194 additions and 376 deletions
+5 -13
View File
@@ -113,24 +113,16 @@ jobs:
exit 0
fi
# No dispatch input: auto-resolve the newest v*.dev* tag on
# GHCR (the point of a nightly is to catch regressions on
# tip-of-main). The GHCR versions API can list a tag before
# its manifest is actually pullable (build in-flight, or
# manifest step didn't finish), so pull the top N candidates
# and verify each with a manifest HEAD via the anonymous
# registry token flow; take the newest one that resolves.
# Disable pipefail locally: `grep` may exit 1 on no matches
# (empty tag list) and `head` may SIGPIPE `sort` after
# reading its 10 lines. Both would abort the step before the
# explicit no-candidates guard below runs.
set +o pipefail
# The GHCR versions API can list a tag before its manifest is
# actually pullable (build in-flight, or manifest step didn't
# finish). So: pull the top N candidate tags, then verify each
# with a manifest HEAD via the anonymous registry token flow;
# take the newest one that resolves.
candidates=$(gh api --paginate \
"/orgs/primeintellect-ai/packages/container/prime-rl/versions" \
--jq '.[].metadata.container.tags[]' \
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+$' \
| sort -Vru | head -n 10)
set -o pipefail
if [ -z "$candidates" ]; then
echo "No v*.dev* tag listed on GHCR." >&2
exit 1
+2 -1
View File
@@ -3,7 +3,8 @@
url = git@github.com:PrimeIntellect-ai/verifiers.git
[submodule "renderers"]
path = deps/renderers
url = git@github.com:PrimeIntellect-ai/renderers.git
url = ../renderers.git
branch = trinity
[submodule "research-environments"]
path = deps/research-environments
url = git@github.com:PrimeIntellect-ai/research-environments.git
+1 -2
View File
@@ -35,8 +35,7 @@ max_completion_tokens = 768
[[orchestrator.train.env]]
name = "alphabet-sort"
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[ckpt] # Checkpoint at the end of training
+1 -2
View File
@@ -22,8 +22,7 @@ seq_len = 8192
[[orchestrator.train.env]]
name = "hendrycks-math"
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.model]
seq_len = 16384
+1 -2
View File
@@ -25,8 +25,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+1 -2
View File
@@ -43,8 +43,7 @@ max_completion_tokens = 512
[[orchestrator.train.env]]
name = "wiki-search"
env.taskset = { id = "wiki-search-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[ckpt] # Checkpoint at the end of training
+1 -2
View File
@@ -24,8 +24,7 @@ group_size = 8
[[orchestrator.train.env]]
name = "wordle"
env.taskset = { id = "wordle-v1" }
env.player.harness = { id = "null" }
env.player.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 1024
+1 -2
View File
@@ -25,8 +25,7 @@ max_completion_tokens = 384
[[orchestrator.train.env]]
name = "alphabet-sort"
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" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
@@ -29,8 +29,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
enable_lora = true
@@ -28,8 +28,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
enable_lora = true
@@ -28,8 +28,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
gpu_memory_utilization = 0.7
@@ -17,8 +17,7 @@ max_completion_tokens = 128
[[train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[ckpt]
interval = 10
@@ -40,8 +40,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -53,8 +52,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
@@ -46,8 +46,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -59,8 +58,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
@@ -26,8 +26,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
@@ -25,8 +25,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference]
+1 -2
View File
@@ -21,8 +21,7 @@ group_size = 16
[[orchestrator.train.env]]
name = "alphabet-sort"
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 768
+2 -4
View File
@@ -21,8 +21,7 @@ seq_len = 8192
[[orchestrator.train.env]]
name = "hendrycks-math"
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 50
@@ -30,8 +29,7 @@ interval = 50
[[orchestrator.eval.env]]
name = "aime2024"
env.taskset = { id = "aime24-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
group_size = 32
[trainer]
+1 -2
View File
@@ -21,8 +21,7 @@ group_size = 16
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 128
+1 -2
View File
@@ -26,8 +26,7 @@ enforce = true
[[orchestrator.train.env]]
name = "wiki-search"
env.taskset = { id = "wiki-search-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 512
+1 -2
View File
@@ -21,8 +21,7 @@ group_size = 16
[[orchestrator.train.env]]
name = "wordle"
env.taskset = { id = "wordle-v1" }
env.player.harness = { id = "null" }
env.player.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 1024
@@ -23,8 +23,7 @@ max_completion_tokens = 64
[[orchestrator.train.env]]
name = "color-codeword"
env.taskset = { id = "color-codeword-v1", images_per_turn = 1 }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer]
+1 -2
View File
@@ -27,8 +27,7 @@ alpha = 0.1
[[orchestrator.train.env]]
name = "alphabet-sort"
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 512
+2 -4
View File
@@ -24,8 +24,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -37,8 +36,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+2 -4
View File
@@ -24,8 +24,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -37,8 +36,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+3 -6
View File
@@ -34,14 +34,12 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text-grpo"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.train.env]]
name = "reverse-text-opd"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.env.algo]
type = "opd"
@@ -60,8 +58,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+2 -4
View File
@@ -36,8 +36,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -49,8 +48,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+2 -4
View File
@@ -36,8 +36,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -49,8 +48,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 1e-4
-53
View File
@@ -1,53 +0,0 @@
max_steps = 20
seq_len = 4096
[model]
name = "Qwen/Qwen3-0.6B"
[wandb]
project = "algorithms-debug"
name = "debug-rae"
[orchestrator]
batch_size = 32
group_size = 1
[orchestrator.algo]
type = "rae"
[orchestrator.renderer]
name = "prime-qwen3"
[orchestrator.train.sampling]
max_completion_tokens = 512
[[orchestrator.train.env]]
name = "kuhn-poker"
env.taskset = { id = "kuhn-poker-v1" }
env.player0.harness = { id = "null" }
env.player0.runtime = { type = "subprocess" }
env.player1.harness = { id = "null" }
env.player1.runtime = { type = "subprocess" }
[orchestrator.eval]
interval = 1
num_examples = 16
[orchestrator.eval.sampling]
max_completion_tokens = 512
[[orchestrator.eval.env]]
name = "kuhn-poker"
env.taskset = { id = "kuhn-poker-v1" }
env.player0.harness = { id = "null" }
env.player0.runtime = { type = "subprocess" }
env.player1.harness = { id = "null" }
env.player1.runtime = { type = "subprocess" }
[trainer.optim]
lr = 3e-6
[ckpt]
[inference]
gpu_memory_utilization = 0.5
+2 -4
View File
@@ -32,8 +32,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -45,8 +44,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+2 -4
View File
@@ -41,8 +41,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -54,8 +53,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+2 -4
View File
@@ -41,8 +41,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 1
@@ -54,8 +53,7 @@ max_completion_tokens = 128
[[orchestrator.eval.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 1e-4
+1 -1
+1 -1
+3 -30
View File
@@ -17,7 +17,6 @@ This page covers the math and the configurable algorithmic components: the algor
- [Custom Loss](#custom-loss)
- [Advantage](#advantage)
- [Default Advantage](#default-advantage)
- [Self-Play Advantage (RAE)](#self-play-advantage-rae)
- [Authoring an Algorithm](#authoring-an-algorithm)
- [Reference Scoring](#reference-scoring)
- [Filters](#filters)
@@ -68,7 +67,6 @@ type = "grpo" # the default
|---|---|---|---|
| `grpo` | policy | `rl` on actions | Standard group-relative RL. |
| `max_rl` | policy | `rl` on actions | MaxRL ([arXiv:2602.02710](https://arxiv.org/abs/2602.02710)): GRPO's centered reward normalized by the group **mean** instead of the standard deviation — the gradient is unbiased for the order-`group_size` truncation of the maximum-likelihood objective, upweighting hard examples like `1/p`. |
| `rae` | policy | `rl` on actions | RAE (SPIRAL, [arXiv:2506.24119](https://arxiv.org/abs/2506.24119)): reward minus a per-agent EMA baseline of that agent's own rewards — the estimator for multi-agent self-play envs, where the group mean would mix the agents' opposite reward scales. See [Self-Play Advantage](#self-play-advantage-rae). |
| `opd` | policy | `ref_kl` on actions | On-policy distillation ([Thinking Machines](https://thinkingmachines.ai/blog/on-policy-distillation/)): the policy samples, per-token reverse KL against a reference model as the gradient signal. Needs a `teacher`. |
| `sft` | *(the teacher)* | `ce` on actions | Hard distillation: a frozen model generates rollouts, the policy trains with CE on its tokens. Needs a frozen `sampling.source` (the teacher it samples from). |
| `opsd` | policy | `ref_kl` on actions | SDFT ([arXiv:2601.19897](https://arxiv.org/abs/2601.19897)): the model is its own reference, conditioned on an expert demonstration. The teacher *is* the live policy (the paper's setting, no extra deployment) — no model to configure. |
@@ -121,15 +119,13 @@ type = "grpo"
[[orchestrator.train.env]]
name = "math"
taskset = { id = "math-v1" }
harness = { id = "null" }
runtime = { type = "subprocess" }
harness = { id = "null", runtime = { type = "subprocess" } }
# inherits the top-level grpo
[[orchestrator.train.env]]
name = "terminal"
taskset = { id = "terminal-v1" }
harness = { id = "bash" }
runtime = { type = "subprocess" }
harness = { id = "bash", runtime = { type = "subprocess" } }
algo = { type = "echo" } # this env runs its own algorithm
```
@@ -142,7 +138,6 @@ At runtime, each env's resolved config builds two objects: a `Sampler` (`prime_r
| `grpo` | `GRPOAlgorithm` | `score_group`: group-norm credit (optional length penalty) |
| `echo` | `EchoAlgorithm` | `score_rollout`: weighted ce on observation tokens; `score_group`: group-norm credit (inherited) |
| `max_rl` | `MaxRLAlgorithm` | `score_group`: mean-normalized group credit |
| `rae` | `RAEAlgorithm` | `score_group`: per-agent EMA-baseline credit |
| `opd` | `OPDAlgorithm` | `score_rollout`: own-context prefill under the teacher |
| `opsd` | `OPSDAlgorithm` | `score_rollout`: demo-conditioned prefill under the live policy |
| `sft` | `SFTDistillAlgorithm` | `score_group`: group-norm credit (feeds filters) |
@@ -179,7 +174,7 @@ $$
\mathcal{L} = \frac{\sum \mathcal{L}_{rl}}{N_{rl}} + \frac{\sum \mathcal{L}_{ce}}{N_{ce}} + \frac{\sum \mathcal{L}_{ref\_kl}}{N_{ref\_kl}}
$$
- `rl` — the configured RL loss (`[trainer.loss]`): DPPO + KL by default, or a [custom loss](#custom-loss). Fed by the advantage-assigning algorithms (`grpo`, `max_rl`, `rae`, and `echo`'s action tokens).
- `rl` — the configured RL loss (`[trainer.loss]`): DPPO + KL by default, or a [custom loss](#custom-loss). Fed by the group-relative algorithms (`grpo`, `max_rl`, and `echo`'s action tokens).
- `ce` — masked NLL. Used for frozen-model tokens (`sft`) and env-observation tokens (`echo`).
- `ref_kl` — the per-token reverse KL to a reference model ($\log \pi_{\text{ref}} - \log \pi$) as the policy-gradient signal, importance-ratio corrected with a one-sided trust region (`opd`, `opsd`). Requires `ref_logprobs` from a [reference scoring](#reference-scoring); the scoring model must be a vLLM server (it's the only one that exposes `prompt_logprobs`).
@@ -281,7 +276,6 @@ The per-token training signal is set by `algo.type` and the [algorithm](#the-alg
|---|---|---|
| `grpo` | `rl` | Group-norm: reward minus per-group baseline, optional length penalty. |
| `max_rl` | `rl` | Mean-normalized group credit (maximum-likelihood RL). |
| `rae` | `rl` | Reward minus a per-agent EMA baseline (SPIRAL's role-conditioned advantage estimation) — for multi-agent self-play envs. |
| `echo` | `rl` + `ce` | Group-norm on action tokens, plus weighted CE on env-provided tokens selected by message role (each role's `alpha` is its ECHO λ), optionally narrowed by a user filter. |
| `opd` | `ref_kl` | On-policy distillation: per-token reverse KL to a reference model (`teacher`, an inline frozen hosted model), evaluated in the trainer from shipped reference logprobs. No credit — rollouts keep `advantages = None` (advantage-based filters never fire) and ship no advantage stream; `group_size` only fans out sampling. |
| `opsd` | `ref_kl` | SDFT: per-token reverse KL to a demo-conditioned reference. No credit — rollouts keep `advantages = None` (advantage-based filters never fire) and ship no advantage stream. |
@@ -303,27 +297,6 @@ type = "grpo"
type = "linear"
```
### Self-Play Advantage (RAE)
Group-relative baselines assume the group is exchangeable attempts by one agent. A multi-agent self-play env breaks that: one episode yields one trace per agent, all trainable, and in a zero-sum game the rewards sum to ~0 whatever the policy does — the group mean carries no information, and centering against it converts any structural asymmetry (a first-mover edge) into permanent credit for one agent.
`rae` implements SPIRAL's role-conditioned advantage estimation ([arXiv:2506.24119](https://arxiv.org/abs/2506.24119)): each agent keeps an exponential-moving-average baseline of its own rewards, and every trace's advantage is its reward minus its agent's baseline — measured against the *pre-update* baseline (the unbiased order), then folded in at `decay` (SPIRAL's α, default 0.95). The algorithm instance is per-env, so baselines are keyed per (env, agent) — the paper's per (game, role). Advantages are not normalized, and `group_size` is free (RAE needs no sibling rollouts; `group_size = 1` is fine). Baselines live in orchestrator memory and re-warm from 0 over ~`1/(1 − decay)` traces per agent after a restart.
```toml
[orchestrator.algo]
type = "rae"
decay = 0.95
[[orchestrator.train.env]]
name = "kuhn-poker"
env.taskset = { id = "kuhn-poker-v1" }
env.player0.harness = { id = "null" }
env.player0.runtime = { type = "subprocess" }
env.player1.harness = { id = "null" }
env.player1.runtime = { type = "subprocess" }
```
Both of `kuhn-poker-v1`'s agents late-bind to the run's own model — shared-policy self-play against a continuously improving opponent. Pin one agent to a frozen endpoint (`env.player1.model = ...`) for asymmetric play; its traces are marked untrainable by the env and never reach the advantage computation. A single-agent env under `rae` degrades to REINFORCE with an EMA baseline.
### Authoring an Algorithm
+3 -6
View File
@@ -150,22 +150,19 @@ Training environments are an array of tables — set one per env, optionally wit
[[orchestrator.train.env]]
name = "gsm8k"
env.taskset = { id = "gsm8k-v1", split = "train" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
ratio = 3 # 75% of batches
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
ratio = 1 # default — 25% of batches
[[orchestrator.eval.env]]
name = "gsm8k-eval"
env.taskset = { id = "gsm8k-v1", split = "test" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
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.
+1 -2
View File
@@ -59,7 +59,7 @@ A condensed view of the knobs you'll most often tune. For trainer-side paralleli
| `orchestrator.batch_size` | Tasks per trainer step. |
| `orchestrator.group_size` | Rollouts generated per task. |
| `orchestrator.max_off_policy_steps` | How many distinct policies may have contributed to one rollout before it's discarded (default 8). The main off-policy dial on long agentic rollouts — bump for throughput, lower for tighter on-policyness. Watch `errored_rollouts` and `mismatch_kl/all/mean` when tuning. |
| `[orchestrator.algo]` | Training algorithm — its `type` names it (`grpo` default, `max_rl`, `rae`, `opd`, `opsd`, `sft`, `echo`). See [Algorithms](#algorithms). |
| `[orchestrator.algo]` | Training algorithm — its `type` names it (`grpo` default, `max_rl`, `opd`, `opsd`, `sft`, `echo`). See [Algorithms](#algorithms). |
| `[[orchestrator.train.env]]` | Training environments. List multiple tables for multi-env training; weight them via `ratio`. See [Configuration § Environments](configuration.md#environments-orchestratortrainenv). |
| `[[orchestrator.eval.env]]` + `orchestrator.eval.interval` | Eval environments and cadence (default every 100 steps). |
@@ -89,7 +89,6 @@ The RL entrypoint supports several training algorithms, switched via `[orchestra
|---|---|---|
| `grpo` (default) | None | Standard group-relative RL |
| `max_rl` | None | [MaxRL](https://arxiv.org/abs/2602.02710): GRPO with mean-normalized advantages (maximum-likelihood RL) |
| `rae` | None | [SPIRAL](https://arxiv.org/abs/2506.24119)'s role-conditioned advantage estimation: reward minus a per-agent EMA baseline, for multi-agent self-play envs (e.g. `kuhn-poker-v1`) |
| `opd` | Required, must be vLLM (needs `prompt_logprobs`) | [On-policy distillation](https://thinkingmachines.ai/blog/on-policy-distillation/): the policy generates rollouts, the trainer minimizes per-token reverse KL to a reference model |
| `sft` | Required, any OpenAI-compatible endpoint | Hard-distill: a frozen model generates rollouts, the policy trains on its tokens |
| `opsd` | None — the live policy is its own reference (no deployment) | [SDFT](https://arxiv.org/abs/2601.19897): the model is its own reference conditioned on expert demonstrations |
+3 -6
View File
@@ -95,8 +95,7 @@ num_turns_weight = 0.0
# the plugged BC-style prompt is replaced by the reference judge's stock prompt).
[[orchestrator.train.env]]
name = "openseeker"
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072] }
env.agent.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.env.taskset]
id = "openseeker-v1"
@@ -118,8 +117,7 @@ choices = ["A", "B"]
[[orchestrator.train.env]]
name = "redsearcher"
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = [65536, 131072] }
env.agent.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.env.taskset]
id = "redsearcher-v1" # optional `difficulty` filter (easy/medium/hard)
@@ -147,8 +145,7 @@ interval = 20
[[orchestrator.eval.env]]
name = "browsecomp"
num_examples = 500 # full set is 1266; cap eval at 500
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"], summarize_at_tokens = 98304 }
env.agent.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 = 98304, runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-search"] } }
env.agent.timeout = { rollout = 3600 }
[orchestrator.eval.env.env.taskset]
+2 -4
View File
@@ -100,8 +100,7 @@ thinking_retention = "all"
[[orchestrator.train.env]]
name = "scaleswe"
env.taskset = { id = "scaleswe-v1" }
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072] }
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] }
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072], runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] } }
[orchestrator.prime_monitor]
@@ -113,8 +112,7 @@ interval = 20
[[orchestrator.eval.env]]
name = "swebench-verified"
env.taskset = { id = "swebench-verified-v1" }
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-swe"] }
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 ---
+3 -6
View File
@@ -93,8 +93,7 @@ num_turns_weight = 0.1
[[orchestrator.train.env]]
name = "tmax"
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072] }
env.agent.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.env.taskset]
id = "tmax-v1"
@@ -121,8 +120,7 @@ interval = 20
[[orchestrator.eval.env]]
name = "swebench-verified"
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] }
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.env.taskset]
@@ -145,8 +143,7 @@ id = "swebench-verified-v1"
[[orchestrator.eval.env]]
name = "terminal-bench-2"
group_size = 4 # avg@4
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["glm45air-terminal"] }
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.env.taskset]
+1 -2
View File
@@ -99,8 +99,7 @@ extra_body = {chat_template_kwargs = {clear_thinking = false}}
[[orchestrator.train.env]]
name = "r2e"
env.taskset = { id = "r2e-gym-v1" }
env.agent.harness = { id = "rlm" }
env.agent.runtime = { type = "prime", labels = ["glm5-llmd"] }
env.agent.harness = { id = "rlm", runtime = { type = "prime", labels = ["glm5-llmd"] } }
[inference]
enable_expert_parallel = true
+1 -2
View File
@@ -74,8 +74,7 @@ interval = 20
[[orchestrator.eval.env]]
name = "swe-bench-verified"
env.taskset = { id = "swebench-verified-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["glm5-pd-disag", "swe-bench-verified"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["glm5-pd-disag", "swe-bench-verified"] } }
[[orchestrator.post_batch_filters]]
type = "gibberish"
+7 -14
View File
@@ -51,36 +51,31 @@ oversampling_factor = 2
name = "swe"
ratio = 0.3
env.taskset = { id = "r2e-gym-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["intellect-3.1", "swe"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["intellect-3.1", "swe"] } }
[[orchestrator.train.env]]
name = "deepdive"
ratio = 0.2
env.taskset = { id = "deepdive-v1" }
env.agent.harness = { id = "rlm", skills = ["search"], forward_env = ["SERPER_API_KEY"] }
env.agent.runtime = { type = "prime", labels = ["intellect-3.1", "deepdive"] }
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
env.taskset = { id = "i3_math_v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.train.env]]
name = "logic"
ratio = 0.2
env.taskset = { id = "i3_logic_v1", filter = { max = 0.874 } }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.train.env]]
name = "code"
ratio = 0.2
env.taskset = { id = "i3_code_v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[[orchestrator.pre_batch_filters]]
type = "zero_advantage"
@@ -92,14 +87,12 @@ interval = 25
[[orchestrator.eval.env]]
name = "swe-bench-verified"
env.taskset = { id = "swebench-verified-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["intellect-3.1", "swe-bench-verified"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["intellect-3.1", "swe-bench-verified"] } }
[[orchestrator.eval.env]]
name = "aime2025"
env.taskset = { id = "aime25-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference.parallel]
tp = 8
+2 -4
View File
@@ -52,8 +52,7 @@ max_off_policy_steps = 16
[[orchestrator.train.env]]
name = "swe"
env.taskset = { id = "r2e-gym-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["minimax-swe", "swe"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["minimax-swe", "swe"] } }
[orchestrator.eval]
interval = 25
@@ -61,8 +60,7 @@ interval = 25
[[orchestrator.eval.env]]
name = "swe-bench-verified"
env.taskset = { id = "swebench-verified-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["minimax-swe", "swe-bench-verified"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["minimax-swe", "swe-bench-verified"] } }
[inference.parallel]
tp = 8
+2 -4
View File
@@ -84,8 +84,7 @@ truncate_history_thinking = false
[[orchestrator.train.env]]
name = "scaleswe"
env.taskset = { id = "scaleswe-v1" }
env.agent.harness = { id = "rlm", summarize_at_tokens = [65536, 131072] }
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] }
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]
@@ -95,8 +94,7 @@ interval = 20
[[orchestrator.eval.env]]
name = "swebench-verified"
env.taskset = { id = "swebench-verified-v1" }
env.agent.harness = { id = "rlm", summarize_at_tokens = 98304 }
env.agent.runtime = { type = "prime", vm = true, idle_timeout = "None", labels = ["nemotron-3-super-swe"] }
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]
+3 -5
View File
@@ -51,8 +51,7 @@ max_completion_tokens = 32768
[[orchestrator.train.env]]
name = "math"
env.taskset = { id = "i3_math_v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 25
@@ -60,8 +59,7 @@ interval = 25
[[orchestrator.eval.env]]
name = "aime2025"
env.taskset = { id = "aime25-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference.parallel]
tp = 8
tp = 8
+3 -5
View File
@@ -49,8 +49,7 @@ max_off_policy_steps = 16
[[orchestrator.train.env]]
name = "swe"
env.taskset = { id = "r2e-gym-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["qwen30b-swe", "swe"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["qwen30b-swe", "swe"] } }
[orchestrator.eval]
interval = 25
@@ -58,8 +57,7 @@ interval = 25
[[orchestrator.eval.env]]
name = "swe-bench-verified"
env.taskset = { id = "swebench-verified-v1" }
env.agent.harness = { id = "bash" }
env.agent.runtime = { type = "prime", labels = ["qwen30b-swe", "swe-bench-verified"] }
env.agent.harness = { id = "bash", runtime = { type = "prime", labels = ["qwen30b-swe", "swe-bench-verified"] } }
[inference.parallel]
tp = 8
tp = 8
+1 -2
View File
@@ -37,8 +37,7 @@ max_off_policy_steps = 32
[[orchestrator.train.env]]
env.taskset = { id = "general-agent-v1", task = { tools = { colocated = true } }, min_tier = 1 }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "modal" }
env.agent.harness = { id = "null", runtime = { type = "modal" } }
[inference]
gpu_memory_utilization = 0.85
+1 -2
View File
@@ -34,7 +34,6 @@ max_completion_tokens = 768
[[orchestrator.train.env]]
name = "alphabet-sort"
env.taskset = { id = "alphabet-sort-v1", min_turns = 3, max_turns = 5, task = { power_per_turn = false } }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[inference] # Default inference config
+2 -4
View File
@@ -19,8 +19,7 @@ seq_len = 8192
[[orchestrator.train.env]]
name = "hendrycks-math"
env.taskset = { id = "math-env-v1", dataset_name = "mikasenghaas/Sanity-Test-R1D-1.5B", dataset_subset = "default" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.eval]
interval = 50
@@ -28,8 +27,7 @@ interval = 50
[[orchestrator.eval.env]]
name = "aime2024"
env.taskset = { id = "aime24-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
group_size = 32
[trainer.model]
+1 -2
View File
@@ -18,8 +18,7 @@ max_completion_tokens = 128
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[trainer.optim]
lr = 3e-6
+1 -2
View File
@@ -136,8 +136,7 @@ The V1 taskset fixes the question bank and searchable corpus. You can replace it
[[orchestrator.train.env]]
name = "wiki-search"
taskset = { id = "wiki-search-v1", task = { judges = [{ id = "reference", model = "openai/gpt-5.4-nano" }] } }
harness = { id = "null" }
runtime = { type = "subprocess" }
harness = { id = "null", runtime = { type = "subprocess" } }
```
## Notes
+1 -2
View File
@@ -47,8 +47,7 @@ enforce = true
[[orchestrator.train.env]]
name = "wiki-search"
env.taskset = { id = "wiki-search-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[ckpt] # Checkpoint at the end of training
+1 -2
View File
@@ -21,8 +21,7 @@ group_size = 16
[[orchestrator.train.env]]
name = "wordle"
env.taskset = { id = "wordle-v1" }
env.player.harness = { id = "null" }
env.player.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
[orchestrator.train.sampling]
max_completion_tokens = 1024
@@ -232,27 +232,6 @@ class MaxRLAlgoConfig(BaseAlgoConfig):
action_loss_type: ClassVar[ActionLossType] = "rl"
class RAEAlgoConfig(BaseAlgoConfig):
type: Literal["rae"] = "rae"
"""RAE — role-conditioned advantage estimation (SPIRAL,
https://arxiv.org/abs/2506.24119): scalar advantage = reward minus a
per-agent EMA baseline of that agent's own rewards, consumed by the ``rl``
loss component. The advantage estimator for multi-agent self-play envs
(``kuhn-poker-v1`` and friends): in a zero-sum game the group mean is ~0
whatever the policy does, so a group-relative baseline mixes the agents'
opposite reward scales — a structural first-mover edge would read as
permanent credit. Per-agent baselines measure each agent against its own
expected reward instead. Works with any ``group_size`` (including 1)."""
action_loss_type: ClassVar[ActionLossType] = "rl"
decay: float = Field(0.95, ge=0.0, lt=1.0)
"""EMA decay of the per-agent baselines (SPIRAL's α): after a trace is
scored, its agent's baseline moves as ``baseline ← decay · baseline +
(1 − decay) · reward``. Baselines start at 0 and live in orchestrator
memory — a restart re-warms them over ~1/(1 − decay) traces per agent."""
class OPDAlgoConfig(BaseAlgoConfig):
type: Literal["opd"] = "opd"
"""On-policy distillation: the per-token signal is the reverse KL to
@@ -326,7 +305,7 @@ class SFTAlgoConfig(BaseAlgoConfig):
AlgoConfig: TypeAlias = Annotated[
GRPOAlgoConfig | EchoAlgoConfig | MaxRLAlgoConfig | RAEAlgoConfig | OPDAlgoConfig | OPSDAlgoConfig | SFTAlgoConfig,
GRPOAlgoConfig | EchoAlgoConfig | MaxRLAlgoConfig | OPDAlgoConfig | OPSDAlgoConfig | SFTAlgoConfig,
Field(discriminator="type"),
]
"""The training algorithm: sampling plus the per-token training signal (credit
@@ -335,7 +314,6 @@ its class defaults are the vetted setting.
- ``grpo`` — policy group sampling, group-relative advantage, RL loss (the default).
- ``max_rl`` — GRPO with mean-normalized advantages (maximum-likelihood RL).
- ``rae`` — reward minus a per-agent EMA baseline (SPIRAL), for multi-agent self-play envs.
- ``opd`` — on-policy distillation: policy samples, per-token reverse KL against a reference model. Needs ``teacher``.
- ``opsd`` — SDFT: policy samples, demo-conditioned reverse KL against the live policy (the teacher is the policy itself).
- ``sft`` — a frozen model samples, the policy trains with CE on its tokens. Needs a frozen ``sampling.source``.
@@ -32,6 +32,9 @@ class OptimizerConfig(BaseConfig):
class LoRAConfig(BaseConfig):
init_path: Path | None = None
"""Initial adapter for a fresh optimizer run; full checkpoint resume takes precedence."""
name: str | None = None
"""LoRA adapter name. If None, auto-generated from rank and alpha."""
@@ -73,6 +73,9 @@ class IndexCacheConfig(BaseConfig):
class LoRAConfig(BaseConfig):
init_path: Path | None = None
"""Initialize adapter weights from a PEFT directory when not resuming a full checkpoint."""
rank: int = Field(16, ge=1)
"""Rank of the low-rank decomposition matrices."""
+2 -3
View File
@@ -44,8 +44,7 @@ Incompatible combinations (e.g. CP requires flash attention) must raise in a `mo
[[orchestrator.train.env]]
name = "reverse-text"
env.taskset = { id = "reverse-text-v1" }
env.agent.harness = { id = "null" }
env.agent.runtime = { type = "subprocess" }
env.agent.harness = { id = "null", runtime = { type = "subprocess" } }
```
CLI: `--orchestrator.train.env.0.env.taskset.id reverse-text-v1`.
@@ -54,7 +53,7 @@ CLI: `--orchestrator.train.env.0.env.taskset.id reverse-text-v1`.
**Discriminated unions** — set the `type` field to pick the variant (`[orchestrator.algo] type = "max_rl"`). Omit `type` to keep the default variant.
**Algorithms** — `[orchestrator.algo] type = "grpo" | "max_rl" | "rae" | "opd" | "opsd" | "sft" | "echo"` — the type names the algorithm (credit assignment + loss routing, fused), and each type's class defaults are its vetted setting; any other key you set is your own assembly (e.g. `[orchestrator.algo.roles.user] alpha = 0.1` for echo — setting any echo role replaces the whole role table). There is no preset layer, and no config hook that points at user code — a new algorithm is a named class in the repo (subclass `Algorithm`, register it). Per-env override: `[orchestrator.train.env.algo] type = "opd"` (the env assembles its own algorithm). prime-rl only hosts the trainable policy; frozen models are inline external endpoints on the algorithm, named where the model is used — `[orchestrator.algo.teacher]` for opd (the frozen model scored against), `[orchestrator.algo.sampling.source]` for sft (the model it samples from), each with `name` + `base_url`. There is no shared `teacher` slot. opsd declares no model — it self-distills against the live policy. See `docs/algorithms.md`.
**Algorithms** — `[orchestrator.algo] type = "grpo" | "max_rl" | "opd" | "opsd" | "sft" | "echo"` — the type names the algorithm (credit assignment + loss routing, fused), and each type's class defaults are its vetted setting; any other key you set is your own assembly (e.g. `[orchestrator.algo.roles.user] alpha = 0.1` for echo — setting any echo role replaces the whole role table). There is no preset layer, and no config hook that points at user code — a new algorithm is a named class in the repo (subclass `Algorithm`, register it). Per-env override: `[orchestrator.train.env.algo] type = "opd"` (the env assembles its own algorithm). prime-rl only hosts the trainable policy; frozen models are inline external endpoints on the algorithm, named where the model is used — `[orchestrator.algo.teacher]` for opd (the frozen model scored against), `[orchestrator.algo.sampling.source]` for sft (the model it samples from), each with `name` + `base_url`. There is no shared `teacher` slot. opsd declares no model — it self-distills against the live policy. See `docs/algorithms.md`.
**`BaseModel | None` fields** — bare flag enables defaults; nested override enables and sets:
+1 -4
View File
@@ -5,7 +5,7 @@ is — a bundle of sampling and the per-token training signal. This package
turns the signal half into runtime objects (the sampling half is the env's
:class:`~prime_rl.orchestrator.sampler.Sampler`):
- one module per algorithm (``grpo``, ``echo``, ``max_rl``, ``rae``, ``opd``,
- one module per algorithm (``grpo``, ``echo``, ``max_rl``, ``opd``,
``opsd``, ``sft``) — each named class owns its scoring hooks
(``score_rollout`` / ``score_group``) and declares what it needs (loss
component, a "teacher", ...). One instance per env, built by
@@ -34,7 +34,6 @@ from prime_rl.orchestrator.algo.grpo import GRPOAlgorithm
from prime_rl.orchestrator.algo.max_rl import MaxRLAlgorithm
from prime_rl.orchestrator.algo.opd import OPDAlgorithm
from prime_rl.orchestrator.algo.opsd import OPSDAlgorithm
from prime_rl.orchestrator.algo.rae import RAEAlgorithm
from prime_rl.orchestrator.algo.routing import stamp_advantages, stamp_loss_routing
from prime_rl.orchestrator.algo.sft import SFTDistillAlgorithm
from prime_rl.orchestrator.types import Rollout
@@ -49,7 +48,6 @@ ALGORITHM_CLASSES: dict[str, type[Algorithm]] = {
"grpo": GRPOAlgorithm,
"echo": EchoAlgorithm,
"max_rl": MaxRLAlgorithm,
"rae": RAEAlgorithm,
"opd": OPDAlgorithm,
"opsd": OPSDAlgorithm,
"sft": SFTDistillAlgorithm,
@@ -74,7 +72,6 @@ __all__ = [
"MaxRLAlgorithm",
"OPDAlgorithm",
"OPSDAlgorithm",
"RAEAlgorithm",
"Rollout",
"SFTDistillAlgorithm",
"build_algorithm",
-41
View File
@@ -1,41 +0,0 @@
from __future__ import annotations
from collections import defaultdict
from typing import TYPE_CHECKING
from prime_rl.configs.algorithm import RAEAlgoConfig
from prime_rl.orchestrator.algo.base import Algorithm
if TYPE_CHECKING:
from prime_rl.orchestrator.types import Rollout
from prime_rl.utils.client import InferencePool
class RAEAlgorithm(Algorithm):
"""Role-conditioned advantage estimation (SPIRAL, arXiv:2506.24119):
credit = reward minus a per-agent EMA baseline of that agent's rewards.
The advantage estimator for multi-agent self-play envs (kuhn-poker-v1 and
friends): in a zero-sum game the group mean is ~0 whatever the policy does,
and centering all agents against it mixes their opposite reward scales — a
structural first-mover edge would read as permanent credit for one agent.
A per-agent baseline tracks each agent's own expected reward instead, so
credit measures improvement over that agent's usual result. The instance is
per-env, so baselines are keyed per (env, agent) — the paper's per
(game, role). A single-agent env degrades to REINFORCE with an EMA baseline.
Each trace is scored against the baseline *before* its reward updates it
(the reference implementation's unbiased order). Baselines start at 0 and
live in orchestrator memory: a restart re-warms them over ~1/(1 − decay)
traces per agent."""
def __init__(self, config: RAEAlgoConfig, policy_pool: InferencePool):
super().__init__(config, policy_pool)
self.decay = config.decay
self.baselines: dict[str | None, float] = defaultdict(float)
async def score_group(self, group: list[Rollout]) -> None:
for rollout in group:
baseline = self.baselines[rollout.agent_name]
rollout.assign_advantages(rollout.reward - baseline)
self.baselines[rollout.agent_name] = self.decay * baseline + (1.0 - self.decay) * rollout.reward
+6 -11
View File
@@ -12,7 +12,7 @@ is flat over the rollout list except the solve rates, which group by ``group_id`
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal
from typing import TYPE_CHECKING, Iterator, Literal
from prime_rl.orchestrator.utils import compute_pass_metrics
@@ -134,20 +134,16 @@ class TimingMetrics(StatGroup):
class CustomMetrics(StatGroup):
"""Per-key ``Stat``s over a dynamic per-rollout dict attribute (env ``@metric``s or reward
components), each averaged over the rollouts that report the key. ``value`` extracts the
float from each entry (rewards are ``vf.Reward`` records; metrics are plain floats)."""
components), each averaged over the rollouts that report the key."""
def __init__(self, rollouts: list[Rollout], attr: str, value: Callable[[Any], float] = float) -> None:
def __init__(self, rollouts: list[Rollout], attr: str) -> None:
super().__init__(rollouts)
self.attr = attr
self.value = value
def stats(self) -> dict[str, Stat]:
names = sorted({name for r in self.rollouts for name in getattr(r, self.attr)})
return {
name: Stat(
[self.value(getattr(r, self.attr)[name]) for r in self.rollouts if name in getattr(r, self.attr)]
)
name: Stat([getattr(r, self.attr)[name] for r in self.rollouts if name in getattr(r, self.attr)])
for name in names
}
@@ -192,9 +188,8 @@ class RolloutMetrics:
@property
def rewards(self) -> CustomMetrics:
"""Per-component reward breakdown, keyed by name (each entry's weighted ``value``,
summed into the scalar ``reward``)."""
return CustomMetrics(self.rollouts, "rewards", value=lambda reward: reward.value)
"""Per-component reward breakdown, keyed by name (summed into the scalar ``reward``)."""
return CustomMetrics(self.rollouts, "rewards")
# Boolean rate metrics (0/1 distributions — ``.mean()`` is the rate)
@property
@@ -380,6 +380,15 @@ class Orchestrator:
self.policy.model_name = self.lora_name
self.policy.version = sync_version
elif config.model.lora is not None and config.model.lora.init_path is not None:
await self.policy_inference.update_weights(
config.model.lora.init_path, lora_name=self.lora_name, step=0
)
self.policy_inference.update_model_name(self.lora_name)
self.policy.model_name = self.lora_name
self.policy.version = 0
get_logger().info(f"Initialized policy v0 from adapter {config.model.lora.init_path}")
self.train_source = TrainSource(self.train_envs, seed=42)
self.eval_source: EvalSource | None = (
EvalSource(
+53
View File
@@ -0,0 +1,53 @@
"""Strict attention-only PEFT initialization without optimizer restoration."""
import json
import torch
from safetensors.torch import load_file
from torch.distributed.tensor import DTensor, distribute_tensor
from prime_rl.utils.logger import get_logger
def load_attention_adapter(model, config):
adapter = config.lora
path = adapter.init_path
metadata = json.loads((path / "adapter_config.json").read_text())
allowed = {"q_proj", "k_proj", "v_proj", "o_proj"}
if set(adapter.target_modules) != allowed or adapter.modules_to_save:
raise ValueError("Adapter warm start supports only attention q/k/v/o with no modules_to_save")
if (metadata.get("r") != adapter.rank or metadata.get("lora_alpha") != adapter.alpha
or metadata.get("lora_dropout", 0.0) != adapter.dropout
or set(metadata.get("target_modules", [])) != allowed
or metadata.get("modules_to_save") or metadata.get("bias", "none") != "none"
or metadata.get("base_model_name_or_path") != config.name):
raise ValueError("Warm-start adapter metadata does not match trainer configuration")
saved = {k.removeprefix("base_model.model."): v for k, v in
load_file(str(path / "adapter_model.safetensors"), device="cpu").items()}
targets = {}
for name, param in model.named_parameters():
if ".lora_A." not in name and ".lora_B." not in name:
continue
name = name.replace("._orig_mod", "")
if not name.endswith(".0"):
raise ValueError("Adapter warm start supports one adapter slot only")
key = name[:-2] + ".weight"
if key in targets:
raise ValueError(f"Duplicate adapter destination: {key}")
targets[key] = param
if set(saved) != set(targets):
raise ValueError(f"Adapter key mismatch: missing={set(targets)-set(saved)}, extra={set(saved)-set(targets)}")
for key, param in targets.items():
if saved[key].shape != param.shape or not torch.isfinite(saved[key]).all():
raise ValueError(f"Invalid adapter tensor: {key}")
with torch.no_grad():
for key, param in targets.items():
value = saved[key].to(device=param.device, dtype=param.dtype)
if isinstance(param, DTensor):
value = distribute_tensor(value, param.device_mesh, param.placements)
param.copy_(value)
actual = param.to_local() if isinstance(param, DTensor) else param
expected = value.to_local() if isinstance(value, DTensor) else value
if not torch.equal(actual, expected):
raise ValueError(f"Adapter copy verification failed: {key}")
get_logger().success(f"Warm-started {len(targets)} adapter tensors from {path}; optimizer state is fresh")
+7
View File
@@ -173,7 +173,14 @@ def train(config: TrainerConfig):
cpu_offload=config.model.optim_cpu_offload,
)
scheduler = setup_scheduler(optimizer, config.scheduler, config.max_steps, config.optim.lr)
# Run creation resets adapters; initialize only after that reset has finished.
if checkpoint_step is None and config.model.lora is not None and config.model.lora.init_path is not None:
from prime_rl.trainer.lora_init import load_attention_adapter
load_attention_adapter(model, config.model)
else:
if config.model.lora is not None and config.model.lora.init_path is not None:
raise ValueError("Adapter warm start requires max_concurrent_runs=1")
optimizer = setup_multi_optimizer(config.optim, parallel_dims)
scheduler = setup_multi_scheduler(optimizer, config.scheduler, config.max_steps)
+5 -9
View File
@@ -457,15 +457,11 @@ def _is_retryable_lora_error(exception: BaseException) -> bool:
return False
# Per-attempt and total bounds for `/load_lora_adapter`. A LoRA load is fast
# (small adapter file + KV cache reset, single-digit seconds in practice) but
# the global admin AsyncClient uses `timeout=None`, so a stuck server hangs
# the orchestrator forever inside `ElasticInferencePool._sync_server_adapter`.
# `_PER_ATTEMPT` converts a hang into a TimeoutException so tenacity retries;
# `_TOTAL` is the wall-clock budget across all retries — pick whichever
# stop condition fires first.
LORA_LOAD_READ_TIMEOUT_S = 30.0
LORA_LOAD_TOTAL_TIMEOUT_S = 120.0
# Loaded multi-DP servers can take minutes to finish an adapter update. Keep
# finite timeouts without retrying a healthy update after only a few seconds.
# The retry budget is checked between attempts, not as a hard outer deadline.
LORA_LOAD_READ_TIMEOUT_S = 300.0
LORA_LOAD_TOTAL_TIMEOUT_S = 600.0
async def load_lora_adapter(admin_clients: list[AsyncClient], lora_name: str, lora_path: Path) -> None:
+1 -1
View File
@@ -101,7 +101,7 @@ def _build_rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
nodes=nodes,
calls=calls,
rewards={"reward": vf.Reward(score=reward)},
rewards={"reward": reward},
metrics=metrics or {},
)
rollout.env_name = env_name
+2 -2
View File
@@ -258,7 +258,7 @@ def _two_turn_rollout(observation_role: str = "tool") -> Rollout:
rollout = Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
nodes=nodes,
rewards={"r": vf.Reward(score=1.0)},
rewards={"r": 1.0},
env_name="test-env",
)
rollout.samples = trace_to_samples(rollout, env_name="test-env")
@@ -309,7 +309,7 @@ def test_echo_weights_only_content_tokens_when_is_content_present():
rollout = Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
nodes=nodes,
rewards={"r": vf.Reward(score=1.0)},
rewards={"r": 1.0},
env_name="test-env",
)
rollout.samples = trace_to_samples(rollout, env_name="test-env")
+2 -4
View File
@@ -58,9 +58,7 @@ def _make_rollout(
else:
nodes = [_assistant_node(completion_ids, completion_logprobs)]
rollout = Rollout[vf.TaskData](
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt="")),
nodes=nodes,
rewards={"reward": vf.Reward(score=reward)},
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt="")), nodes=nodes, rewards={"reward": reward}
)
rollout.env_name = "test"
rollout.group_id = uuid.uuid4()
@@ -142,7 +140,7 @@ def test_gibberish_aligns_logprobs_under_generation_prompt_scaffold():
rollout = Rollout[vf.TaskData](
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt="")),
nodes=[_scaffold_assistant_node([50, 80, 120_000], [-1.0, -0.5, gibberish_filter.logprob_threshold - 1.0])],
rewards={"reward": vf.Reward(score=1.0)},
rewards={"reward": 1.0},
)
result = gibberish_filter.check(rollout)
+2 -3
View File
@@ -2,7 +2,6 @@ import math
from types import SimpleNamespace
import pytest
import verifiers.v1 as vf
from prime_rl.orchestrator.metrics import EvalRollouts, Stat, TrainRollouts
from prime_rl.orchestrator.utils import compute_pass_metrics
@@ -142,8 +141,8 @@ def test_stop_condition_breakdown():
def test_nested_metrics_and_rewards():
rollouts = [
mk(metrics={"acc": 1.0}, rewards={"correct": vf.Reward(score=1.0), "format": vf.Reward(score=0.0)}),
mk(metrics={"acc": 3.0, "fmt": 5.0}, rewards={"correct": vf.Reward(score=0.0), "format": vf.Reward(score=1.0)}),
mk(metrics={"acc": 1.0}, rewards={"correct": 1.0, "format": 0.0}),
mk(metrics={"acc": 3.0, "fmt": 5.0}, rewards={"correct": 0.0, "format": 1.0}),
]
m = TrainRollouts(rollouts).metrics
assert m.metrics["acc"].mean() == 2.0 and m.rewards["correct"].mean() == 0.5 # nested group access
+1 -1
View File
@@ -38,7 +38,7 @@ def _build_rollout(*, example_id: int, reward: float, task: str) -> Rollout:
rollout = Rollout[vf.TaskData](
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=example_id, prompt=f"prompt-{example_id}")),
nodes=nodes,
rewards={"reward": vf.Reward(score=reward)},
rewards={"reward": reward},
)
rollout.env_name = task
# Per-token advantage stream (full-length-N): 0.0 on the 3 prompt tokens,
Generated
+4 -17
View File
@@ -67,7 +67,6 @@ members = [
"i3-science-v1",
"ifbench-v1",
"ifeval-v1",
"kuhn-poker-v1",
"lean-v1",
"livecodebench-v1",
"longbenchpro-v1",
@@ -3230,17 +3229,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/46/2c/5c160dbdef7123f8cc97fd8ece7e0198627a426a2a49614845e9086feb8d/kubernetes-36.0.2-py2.py3-none-any.whl", hash = "sha256:faf9b5241b58de0c4a5069f2a0ffc8ac06fece7215156cd3d3ba081a78a858b6", size = 4617568, upload-time = "2026-06-01T18:20:28.737Z" },
]
[[package]]
name = "kuhn-poker-v1"
version = "0.1.0"
source = { editable = "deps/verifiers/environments/kuhn_poker_v1" }
dependencies = [
{ name = "verifiers" },
]
[package.metadata]
requires-dist = [{ name = "verifiers" }]
[[package]]
name = "langdetect"
version = "1.0.9"
@@ -5337,7 +5325,7 @@ requires-dist = [
[[package]]
name = "prime-sandboxes"
version = "0.2.33"
version = "0.2.32"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "aiofiles" },
@@ -5347,9 +5335,9 @@ dependencies = [
{ name = "pydantic" },
{ name = "tenacity" },
]
sdist = { url = "https://files.pythonhosted.org/packages/15/a9/880685cefd503aa92d2b49da46b60ba807015f8839c344a83d8c5bc02f30/prime_sandboxes-0.2.33.tar.gz", hash = "sha256:4253a3c345ccf6c07b41a81790f8515763333f094d20bc405a257432461e81d8", size = 81228, upload-time = "2026-07-22T23:23:55.715Z" }
sdist = { url = "https://files.pythonhosted.org/packages/62/fd/f57ad87b273ae1696ca620deaac2c56e28a54905d2d2791a5b9a387f443c/prime_sandboxes-0.2.32.tar.gz", hash = "sha256:ea3d6230cdfb5af2e4542814996257bad60fc9913f15f776a65ca1ef05f4f504", size = 77656, upload-time = "2026-07-17T17:41:02.296Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/f8/1b/10b1044b8aaef561c32a34140f4a13c7310f73f92f9546337e2e8e6a5239/prime_sandboxes-0.2.33-py3-none-any.whl", hash = "sha256:92c9647557e76191ba926ac8ed01708de9ec4450142131b673cd5cf8d9d7ea56", size = 42773, upload-time = "2026-07-22T23:23:54.381Z" },
{ url = "https://files.pythonhosted.org/packages/75/a3/c345509abf8f7707c0c3e9d6badba2e057781d1c05a88a46733ab67521e5/prime_sandboxes-0.2.32-py3-none-any.whl", hash = "sha256:4fe730622e51c489f8f86e7ad959fd8320db6d7a9fe22442ae3c680687da4c22", size = 40897, upload-time = "2026-07-17T17:41:00.935Z" },
]
[[package]]
@@ -7871,7 +7859,7 @@ requires-dist = [
{ name = "openai-agents", specifier = ">=0.8.2" },
{ name = "openenv", marker = "extra == 'openenv'", specifier = ">=0.4.1" },
{ name = "prime-pydantic-config", extras = ["toml"], specifier = ">=0.4.2" },
{ name = "prime-sandboxes", specifier = ">=0.2.33" },
{ name = "prime-sandboxes", specifier = ">=0.2.31" },
{ name = "prime-tunnel", specifier = ">=0.1.8" },
{ name = "pydantic", specifier = ">=2.12.3" },
{ name = "python-dotenv", marker = "extra == 'browser'", specifier = ">=1.0.0" },
@@ -7914,7 +7902,6 @@ examples = [
{ name = "deepwiki-v1", editable = "deps/verifiers/environments/deepwiki_v1" },
{ name = "glossary-v1", editable = "deps/verifiers/environments/glossary_v1" },
{ name = "gsm8k-v1", editable = "deps/verifiers/environments/gsm8k_v1" },
{ name = "kuhn-poker-v1", editable = "deps/verifiers/environments/kuhn_poker_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" },