feat: stamp platform trace metadata via verifiers Trace fields (#3061)
Docker Push / Push CUDA image to Docker (push) Canceled after 0s

* feat: stamp platform trace metadata via verifiers Trace fields

Companion to verifiers#2053 (RES-1078). Rollouts are stamped on arrival
in the orchestrator via vf.Trace.stamp - run_id (from the new
Monitor.run_id: platform id preferred, else wandb), tag, step as
first-class trace fields, env_name/group_id/policy_version into info -
replacing the Rollout.to_record override. Bumps deps/verifiers to the
trace-fields commit and deps/renderers to satisfy its >=0.1.8 floor.

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

* chore: bump verifiers to reshaped trace metadata

VersionInfo + AgentInfo (model, sampling, harness id), taskset_id
dropped upstream.

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

* chore: bump verifiers - run_id/tag grouped into Trace.run, schema_version renamed to version

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

* chore: bump verifiers - RunInfo discriminated union, stamp(run)

step lives on TrainRunInfo; inline-eval trigger step goes to
info.eval_step to keep eval records placeable.

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

* chore: bump verifiers to branch head (gepa stamping reverted)

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

* chore: bump verifiers - AgentInfo embeds full HarnessConfig

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

* chore: bump verifiers - eval trigger step moves to EvalRunInfo.step

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

* chore: bump verifiers - verifiers_commit foreign-repo guard

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

* chore: bump verifiers to branch head

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

* chore: bump verifiers past the openenv restructure

openenv is a built-in taskset behind verifiers[openenv] now (vf#2059),
so the deps/verifiers/packages/* workspace glob goes away again.

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Mika Senghaas
2026-07-17 10:15:28 -07:00
committed by GitHub
co-authored by Claude Fable 5
parent 5f7e3ffcaa
commit 18665f7d58
9 changed files with 505 additions and 427 deletions
+1 -1
+1 -1
+4 -3
View File
@@ -141,13 +141,14 @@ JSONL files of `vf.Trace` records (training tensors excluded). `all` gets every
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
`kind`, `env_name`, `group_id`, `policy_version`, and `eval_step`, plus `runtime` (config +
provisioned resource id, e.g. the sandbox id).
`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`.
```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_name, runtime}' {output_dir}/rollouts/step_*/train/all/traces.jsonl
jq 'select(.errors != []) | {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.
+12
View File
@@ -27,6 +27,7 @@ import time
from typing import TYPE_CHECKING
import tomli_w
import verifiers.v1 as vf
if TYPE_CHECKING:
from renderers.base import Renderer
@@ -485,6 +486,17 @@ class Orchestrator:
# eval rollouts to the step whose eval triggered them.
step = rollout.eval_step if rollout.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"
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,
)
await asyncio.to_thread(
save_rollouts,
[rollout.to_record()],
+4 -15
View File
@@ -73,8 +73,10 @@ class Rollout(vf.Trace[DataT], Generic[DataT]):
"""A completed rollout: the env's typed ``vf.Trace`` *is* the rollout — prime-rl's
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;
:meth:`to_record` adds the small metadata fields back for the on-disk trace files.
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
``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.
It is also the single currency the scoring hooks receive: a hook reads the trace
directly (``rollout.reward``, ``rollout.nodes``, ``rollout.num_turns``) and writes
@@ -98,19 +100,6 @@ class Rollout(vf.Trace[DataT], Generic[DataT]):
filter_results: dict[str, bool] = Field(default_factory=dict, exclude=True)
eval_step: int | None = Field(default=None, exclude=True)
def to_record(self) -> dict:
"""The plain trace record plus the orchestration metadata (excluded from the pydantic
dump), so a record stays fully placeable — kind, env, policy — even when trace files
are merged or read away from their paths. ``eval_step`` is the eval trigger step (None
for train rollouts)."""
return super().to_record() | {
"kind": self.kind,
"env_name": self.env_name,
"group_id": str(self.group_id),
"policy_version": self.policy_version,
"eval_step": self.eval_step,
}
def assign_advantages(self, values: float | list[float]) -> None:
"""Write the rl advantage stream: a scalar broadcast over the
rollout's trainable (mask-True) tokens (0.0 elsewhere), or a per-token
+3
View File
@@ -37,6 +37,9 @@ class Monitor(ABC):
to store logged metrics.
"""
run_id: str | None = None
"""External identifier of the run this monitor reports to (platform / W&B), when it has one."""
@abstractmethod
def log(self, metrics: dict[str, Any], step: int) -> None:
pass
+4
View File
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Any
from prime_rl.utils.logger import get_logger
from prime_rl.utils.monitor.base import Monitor
from prime_rl.utils.monitor.prime import PrimeMonitor
if TYPE_CHECKING:
from prime_rl.orchestrator.types import Rollout
@@ -15,6 +16,9 @@ class MultiMonitor(Monitor):
def __init__(self, monitors: list[Monitor]):
self.monitors = monitors
self.logger = get_logger()
# Prefer the platform run id over W&B's when both report one.
prime = next((m for m in monitors if isinstance(m, PrimeMonitor)), None)
self.run_id = (prime.run_id if prime else None) or next((m.run_id for m in monitors if m.run_id), None)
@property
def history(self) -> list[dict[str, Any]]:
+1
View File
@@ -135,6 +135,7 @@ class WandbMonitor(Monitor):
# Everyone else still retries to absorb transient W&B server errors (e.g. 404 on upsertBucket).
max_retries = 30 if shared_mode and not primary else 5
self.wandb = init_wandb(max_retries)
self.run_id = self.wandb.id
wandb.define_metric("*", step_metric="step")
Generated
+475 -407
View File
File diff suppressed because it is too large Load Diff