Compare commits

...
Author SHA1 Message Date
e0638c7eb6 chore: adapt to the verifiers trace record cleanups (#3157)
* rename training environments to sources

* fix CPU test config fixtures

* rename evaluation environments to sources

* chore(orchestrator)!: rename max_inflight_rollouts to max_inflight_episodes

A dispatcher permit has always bought one episode, not one rollout: for a v1
env one `run` request is one episode (however many agents play it), and a
legacy group-scoring call reserves one permit per bridged v0 rollout, each of
which is its own single-agent episode. Name the knob what it counts.

`max_inflight_rollouts` still parses as an alias, as `rollouts_per_example`
does for `group_size`.

* feat(orchestrator)!: compose the verifiers env, serve and legacy blocks

verifiers split `EnvServerConfig` into three blocks, so an env entry composes
them instead of inheriting one class:

    [[orchestrator.train.source]]
    env    = { taskset = { id = "..." } }   # what runs
    serve  = { pool = { ... }, address, max_concurrent }   # how it's hosted
    legacy = { id, args }                   # a classic v0 env instead

`serve.pool` sizes the spawned server (was `pool`), `serve.address` points at an
external one (was `address`), and `serve.max_concurrent` bounds one worker's
episodes in flight — usually left unset, since `max_inflight_episodes` is the
run's bound. Each moved key raises with a pointer home, including the
`num_workers` shorthand the old validator migrated silently.

BREAKING: `pool` / `address` / `num_workers` on an env entry move under `serve`,
and a v0 env's `id` / `args` / `extra_env_kwargs` move under `legacy`.

TEMPORARY: `deps/verifiers` points at the `feat/one-agent-per-episode` branch
(PrimeIntellect-ai/verifiers#2157) so the two sides can be run together; re-pin
to a merged `main` commit before this lands.

* fix the source-config readers the compose commit missed

The Prime monitor still built its run-registration payload from `env.id`, which
the composed entry doesn't have — `AttributeError` at registration whenever
Prime monitoring is on. It reads `env_id` now, the property that spans both the
v1 and the v0 shape.

The packer's fixture still used the bare `id` shorthand, so its three runs were
rejected at config parse and skipped by `discover_runs`. Full CPU unit suite:
416 passed.

Re-pins `deps/verifiers` to the branch tip of verifiers#2157, which fixes the
same class of stale access on that side (`config.legacy.id`). Still a branch
commit — re-pin to a merged `main` before this lands.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* spell the env annotation out instead of vf.EnvField

verifiers dropped the `EnvField` alias, which was only ever
`SerializeAsAny[EnvConfig]` under a name that collided with `env_field()`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* declare the env default with the factory verifiers exports

`vf.env_field()` is gone: it only wrapped `Field(default_factory=...)`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* inline the legacy helpers, use the config class as the default

Follows verifiers dropping the three `configs/legacy.py` helpers and the
`single_agent_env_config` factory: `is_legacy` and `env_id` are one-liners here,
the mixed-run refusal is spelled out in `validate_env`, and the `env` default is
`vf.SingleAgentEnvConfig()`. `env.max_concurrent` now works as an alias for
`env.max_concurrent_agents`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* drop the serving-key pointers here too

The same call as verifiers a0ebc408: `num_workers` / `pool` / `address` on a source
entry now fail as an ordinary `extra_forbidden` instead of naming their new home.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* bump verifiers: no max_concurrent alias on the env block

`env.max_concurrent` used to bound a served worker's agent runs across episodes, so
accepting it as `max_concurrent_agents` multiplied it by the episodes in flight. It
errors now, like every other moved key. 416 unit tests pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* bump verifiers to 0.2.2.dev43 (merged main)

deps/verifiers d0bb0ffe5 -> fcb48822e, which is the squash-merge of the composed
env/serve/legacy config blocks (#2157) plus everything else since the last bump:
Harbor 0.20.0 (#2161), runtime-blamed box failures (#2156), standalone MCP clients
pinned to v1 (#2155), and the v1 test/E2E split (#2127).

Lock: harbor 0.14.0 -> 0.20.0, which drops claude-agent-sdk and datasets from its
own deps and adds filelock/platformdirs, so those move with it.

Replaces the temporary branch pin this PR carried.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix: spawn the env server again, and let a pip-only install resolve verifiers

Two CI failures from the compose commit.

The orchestrator stopped spawning env servers. It decides spawn-vs-connect by
`address is None`, and prime-rl's own field defaulted to None; `vf.ServingConfig`
defaults to `tcp://127.0.0.1:5000`, so every env looked external and the run waited
120s for a server nobody started. It now asks whether the address was *pinned*
(`model_fields_set`), so an unset `[serve]` spawns on a free port as before, and
pinning any address — including verifiers' own default — connects.

The slim `prime-rl-configs` wheel is installed from /tmp with no workspace context,
so `verifiers` resolves from PyPI, where `>=0.2.1` picks stable 0.2.1 — no
`SingleAgentEnvConfig`. Floor is `>=0.2.2.dev43` now, a pre-release specifier so the
dev release is eligible.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore: adapt to the verifiers trace record cleanups

Companion to PrimeIntellect-ai/verifiers#2172: record_* mutators, required
agent seat and RunInfo.id, last_error, and agent.name/.trainable reads.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* chore: re-pin verifiers to merged main (f646beb37)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: hallerite <git@hallerite.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:34:53 -07:00
14 changed files with 49 additions and 27 deletions
+1 -1
@@ -29,10 +29,10 @@ class HierarchicalGRPOAlgorithm(Algorithm):
self.episode_agents = set(config.episode_agents)
async def score_group(self, group: list[Rollout]) -> None:
peers: dict[tuple[str | None, str | None], list[Rollout]] = defaultdict(list)
peers: dict[tuple[str, str | None], list[Rollout]] = defaultdict(list)
for rollout in group:
episode_scoped = rollout.agent_name in self.episode_agents
key = (rollout.agent_name, rollout.episode_id if episode_scoped else None)
episode_scoped = rollout.agent.name in self.episode_agents
key = (rollout.agent.name, rollout.episode_id if episode_scoped else None)
peers[key].append(rollout)
for members in peers.values():
baseline = sum(rollout.reward for rollout in members) / len(members)
+3 -3
View File
@@ -32,10 +32,10 @@ class RAEAlgorithm(Algorithm):
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)
self.baselines: dict[str, float] = defaultdict(float)
async def score_group(self, group: list[Rollout]) -> None:
for rollout in group:
baseline = self.baselines[rollout.agent_name]
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
self.baselines[rollout.agent.name] = self.decay * baseline + (1.0 - self.decay) * rollout.reward
+10 -5
View File
@@ -8,7 +8,7 @@
- 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.
``trace.last_error`` set; sinks decide drop / partial-train policy.
- ``DispatcherMode.PREFER_TRAIN`` / ``PREFER_EVAL`` controls which kind to
schedule next. Transitions are level-triggered (driven by the eval
source's emptiness), so in-flight rollouts of the opposite kind drain
@@ -521,11 +521,14 @@ class RolloutDispatcher:
get_logger().warning(f"Rollout task failed in group {meta.group_id} ({meta.env_name}): {exc!r}")
task_idx = group.task_idx if group is not None else -1
rollouts = [
Rollout(task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)))
Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
)
for _ in range(meta.rollout_count)
]
for r in rollouts:
r.capture_error(exc)
r.record_error(exc)
is_synth_exception = True
for r in rollouts:
@@ -537,9 +540,9 @@ class RolloutDispatcher:
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 and r.error is not None:
if not is_synth_exception and r.last_error is not None:
get_logger().warning(
f"Rollout failed in group {meta.group_id} ({meta.env_name}) — {r.error.type}: {r.error.message}"
f"Rollout failed in group {meta.group_id} ({meta.env_name}) — {r.last_error.type}: {r.last_error.message}"
)
if meta.rollout_count == 1:
# A ``run`` task: the whole result is one episode.
@@ -601,6 +604,7 @@ class RolloutDispatcher:
for _ in range(meta.rollout_count):
trace = Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
ok=False,
errors=[vf.Error(type="Cancelled", message="Off-policy cancel")],
stop_condition="error",
@@ -628,6 +632,7 @@ class RolloutDispatcher:
for _ in range(unscheduled_cancelled):
trace = Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=task_idx, prompt=None)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
ok=False,
errors=[vf.Error(type="Cancelled", message="Off-policy cancel")],
stop_condition="error",
+6 -4
View File
@@ -226,7 +226,7 @@ class RolloutMetrics:
def error_types(self) -> dict[str, int]:
"""Count of errored rollouts by error type (the rollout's last error — e.g. ``Cancelled``,
``ProviderError``)."""
types = [r.error.type for r in self.rollouts if r.has_error]
types = [r.last_error.type for r in self.rollouts if r.has_error and r.last_error is not None]
return {t: types.count(t) for t in sorted(set(types))}
def solve_rates(self) -> dict[str, float]:
@@ -360,7 +360,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 and r.trainable])
return TrainRollouts([r for r in self.rollouts if not r.has_error and not r.is_filtered and r.agent.trainable])
def by_env(self) -> dict[str, TrainRollouts]:
grouped: dict[str, list[Rollout]] = {}
@@ -399,13 +399,15 @@ class EvalRollouts:
return self._group_size
counts: dict = {}
for r in self.rollouts:
if r.trainable:
if r.agent.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 and r.trainable], group_size=self.group_size)
return EvalRollouts(
[r for r in self.rollouts if not r.has_error and r.agent.trainable], group_size=self.group_size
)
@property
def metrics(self) -> EvalMetrics:
+7 -3
View File
@@ -24,6 +24,7 @@ from __future__ import annotations
import asyncio
import os
import time
import uuid
from typing import TYPE_CHECKING
import tomli_w
@@ -241,6 +242,9 @@ class Orchestrator:
train_env_names=[env.resolved_name for env in config.train.source],
eval_env_names=[source.resolved_name for source in config.eval.source] if config.eval is not None else [],
)
# ``RunInfo.id`` is required on the trace: fall back to a run-local uuid
# when no external monitor identity (W&B) exists.
self.run_id = self.monitor.run_id or uuid.uuid4().hex
if config.heartbeat is not None:
self.heart = Heartbeat(config.heartbeat.url)
@@ -527,12 +531,12 @@ class Orchestrator:
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)
vf.EvalRunInfo(id=self.run_id, step=step)
if kind == "eval"
else vf.TrainRunInfo(id=self.monitor.run_id, step=step)
else vf.TrainRunInfo(id=self.run_id, step=step)
)
for rollout in episode:
rollout.stamp(
rollout.record_run(
run,
env_name=rollout.env_name,
group_id=str(rollout.group_id),
+2 -2
View File
@@ -155,7 +155,7 @@ class TrainSink:
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; untrainable traces never become training data."""
if rollout.has_error or not rollout.trainable:
if rollout.has_error or not rollout.agent.trainable:
return
samples = await asyncio.to_thread(
trace_to_samples,
@@ -198,7 +198,7 @@ class TrainSink:
)
return
# Untrainable traces carry no samples and must not skew the group baseline.
survivors = [r for r in survivors if r.trainable]
survivors = [r for r in survivors if r.agent.trainable]
if not survivors:
get_logger().debug(
f"Finished group | env={env_name} task_idx={task_idx} | "
+1 -1
View File
@@ -77,7 +77,7 @@ class Rollout(vf.Trace[DataT], Generic[DataT]):
orchestration metadata lives on it directly (set by the dispatcher once the rollout
returns), so there's no wrapper. Train vs eval is the ``kind`` discriminator. All metadata
fields are ``exclude=True``, so dumping a Rollout yields a plain trace on the wire; the
orchestrator mirrors them onto the trace's own fields via ``vf.Trace.stamp`` (``kind`` as
orchestrator mirrors them onto the trace's own fields via ``vf.Trace.record_run`` (``kind`` as
``run.type``, the run id, the step, and ``env_name``/``group_id``/``policy_version`` into
``info``) when a rollout arrives, so the on-disk records stay fully placeable.
@@ -99,6 +99,7 @@ def _build_rollout(
rollout = Rollout[vf.TaskData](
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
nodes=nodes,
calls=calls,
rewards={"reward": vf.Reward(score=reward)},
+7 -1
View File
@@ -162,7 +162,11 @@ def _make_rollout(
advantages: list[float] | None = None,
) -> Rollout:
rollout = Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)), nodes=[], rewards={}, env_name="test-env"
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
nodes=[],
rewards={},
env_name="test-env",
)
rollout.samples = samples
rollout.advantages = advantages
@@ -257,6 +261,7 @@ def _two_turn_rollout(observation_role: str = "tool") -> Rollout:
]
rollout = Rollout(
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt=None)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
nodes=nodes,
rewards={"r": vf.Reward(score=1.0)},
env_name="test-env",
@@ -308,6 +313,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)),
agent=vf.AgentInfo(config=vf.AgentConfig()),
nodes=nodes,
rewards={"r": vf.Reward(score=1.0)},
env_name="test-env",
+2
View File
@@ -59,6 +59,7 @@ def _make_rollout(
nodes = [_assistant_node(completion_ids, completion_logprobs)]
rollout = Rollout[vf.TaskData](
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=0, prompt="")),
agent=vf.AgentInfo(config=vf.AgentConfig()),
nodes=nodes,
rewards={"reward": vf.Reward(score=reward)},
)
@@ -141,6 +142,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="")),
agent=vf.AgentInfo(config=vf.AgentConfig()),
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)},
)
+2 -2
View File
@@ -48,12 +48,12 @@ def mk(
is_truncated=is_truncated,
is_completed=is_completed,
has_error=has_error,
error=SimpleNamespace(type=error_type) if has_error else None,
last_error=SimpleNamespace(type=error_type) if has_error else None,
stop_condition=stop_condition,
metrics=metrics or {},
env_name=env_name,
group_id=group_id,
trainable=trainable,
agent=SimpleNamespace(trainable=trainable),
is_trainable=is_trainable,
is_filtered=is_filtered,
filter_results=filter_results or {},
+3 -1
View File
@@ -37,6 +37,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}")),
agent=vf.AgentInfo(config=vf.AgentConfig()),
nodes=nodes,
rewards={"reward": vf.Reward(score=reward)},
)
@@ -81,7 +82,8 @@ def test_rollouts_to_parquet_bytes_skips_rollouts_without_trajectory():
rollout_with_branches = _build_rollout(example_id=1, reward=1.0, task="task-a")
rollout_without_branches = Rollout[vf.TaskData](
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=2, prompt="missing-trajectory"))
task=vf.TraceTask(type="Task", data=vf.TaskData(idx=2, prompt="missing-trajectory")),
agent=vf.AgentInfo(config=vf.AgentConfig()),
)
assert rollout_without_branches.branches == []
Generated
+1 -1
View File
@@ -7899,7 +7899,7 @@ requires-dist = [
{ name = "python-dotenv", marker = "extra == 'browser'", specifier = ">=1.0.0" },
{ name = "pyzmq", specifier = ">=27.1.0" },
{ name = "reasoning-gym", marker = "extra == 'rg'", specifier = ">=0.1.8" },
{ name = "renderers", specifier = ">=0.1.8" },
{ name = "renderers", specifier = ">=0.1.9.dev9" },
{ name = "requests" },
{ name = "rich", specifier = ">=11.0.0" },
{ name = "setproctitle", specifier = ">=1.3.0" },