Compare commits

...
Author SHA1 Message Date
1fd2d732c2 fix: read overview quality metrics from effective subset (#3159)
* fix: read overview quality metrics from effective subset

The all subset counts errored rollouts as zeros for num_branches,
num_turns, num_total_tokens, and is_truncated, which skews the
distributions and makes the panels uninterpretable. Point the wandb
overview panels and the eval success line at the effective subset;
has_error stays on all since effective drops errors by construction.

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

* fix: reword zero-skew rationale, drop subset guidance from skill

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

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:36:13 -07:00
6a9969e61a chore: bump renderers to 0.1.9.dev9 (#3158)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-29 16:06:49 -07:00
1385e0722c fix: compute trainable rate over effective rollouts (#3152)
* fix(orchestrator): compute trainable rate over effective rollouts

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

* chore: drop comment

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 23:52:21 -07:00
e2ad3beaaa feat(monitor): effective reward/score in wandb overview (#3153)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-28 23:40:39 -07:00
5 changed files with 46 additions and 33 deletions
+1 -1
+6 -6
View File
@@ -93,13 +93,13 @@ All metrics print to the console log (and W&B when configured).
| Metric | Description |
|--------|-------------|
| `train/agg/all/reward/mean` | mean training reward (per env: `train/<env>/all/reward/mean`) |
| `train/agg/all/num_total_tokens/mean` | avg tokens per rollout (also `num_input_tokens`, `num_output_tokens`) |
| `train/agg/all/num_turns/mean` | avg turns per rollout (multi-turn only) |
| `train/agg/all/is_truncated/mean` | fraction truncated |
| `train/agg/effective/reward/mean` | mean training reward (per env: `train/<env>/effective/reward/mean`) |
| `train/agg/effective/num_total_tokens/mean` | avg tokens per rollout (also `num_input_tokens`, `num_output_tokens`) |
| `train/agg/effective/num_turns/mean` | avg turns per rollout (multi-turn only) |
| `train/agg/effective/is_truncated/mean` | fraction truncated |
| `train/agg/all/has_error/mean` | fraction errored (per-type under `train/agg/all/error/<type>`; also `dispatcher/errored/{train,eval}`) |
| `train/<env>/all/metrics/<name>/mean` | env-specific metrics (e.g. pass rate) |
| `eval/<env>/all/{avg@k,pass@k}` | eval scores when configured |
| `train/<env>/effective/metrics/<name>/mean` | env-specific metrics (e.g. pass rate) |
| `eval/<env>/effective/{avg@k,pass@k}` | eval scores when configured |
**Stability** — trainer log:
+13 -13
View File
@@ -597,11 +597,12 @@ class Orchestrator:
)
return
self.consecutive_empty_batches = 0
n_trainable = sum(1 for r in batch.rollouts if r.is_trainable)
if n_trainable / len(batch.rollouts) <= 0.1:
effective = batch.rollouts.effective
n_trainable = sum(1 for r in effective if r.is_trainable)
if effective and n_trainable / len(effective) <= 0.1:
get_logger().warning(
f"Only {n_trainable}/{len(batch.rollouts)} generated rollouts are trainable "
f"({n_trainable / len(batch.rollouts):.1%}) — consider reviewing task difficulty / filter config"
f"Only {n_trainable}/{len(effective)} effective rollouts are trainable "
f"({n_trainable / len(effective):.1%}) — consider reviewing task difficulty / filter config"
)
# Ship batch ``step`` only once the trainer has published v{step-1-TARGET_LAG}.
@@ -637,7 +638,6 @@ class Orchestrator:
# at ship time; the full arrival window already streamed into ``all`` on arrival.
# to_record drops the per-node training tensors — they're for training, not the rollout
# record, and can't round-trip json (raw numpy bytes).
effective = batch.rollouts.effective
records = [r.to_record() for r in effective]
await asyncio.to_thread(save_rollouts, records, get_trace_path(config.output_dir, step, "train", "effective"))
@@ -805,19 +805,19 @@ class Orchestrator:
def log_train_batch(self, batch: TrainBatch, *, step: int, step_time: float) -> None:
"""Per-step ``Step …`` success line. Multi-env runs append an indented ``╰─`` line per env.
``Error`` is the sink-level rate (errored arrivals / total arrivals, over the full window);
the quality metrics are over the effective (clean, trained-on) subset; ``Trainable`` is
relative to all generated rollouts."""
the quality metrics are over the effective (clean, trained-on) subset, as is ``Trainable``."""
rollouts = batch.rollouts
effective = rollouts.effective
eff = effective.metrics
n_generated = len(rollouts)
n_trainable = sum(1 for r in rollouts if r.is_trainable)
trainable_rate = (n_trainable / n_generated) if n_generated else 0.0
n_effective = len(effective)
n_trainable = sum(1 for r in effective if r.is_trainable)
trainable_rate = (n_trainable / n_effective) if n_effective else 0.0
max_off_policy = max((r.off_policy_steps for r in effective), default=0)
head = (
f"Step {step} | {format_time(step_time):>7} | Reward {eff.reward.mean():.4f} | "
f"Trainable {n_trainable}/{n_generated} ({trainable_rate:.1%}) | "
f"Trainable {n_trainable}/{n_effective} ({trainable_rate:.1%}) | "
f"Turns {eff.num_turns.mean():.1f} | Branches {eff.num_branches.mean():.1f} | "
f"Max Off-Policy {max_off_policy} | "
f"Error {rollouts.metrics.has_error.mean():.1%} | Truncation {eff.is_truncated.mean():.1%}"
@@ -875,15 +875,15 @@ class Orchestrator:
metrics["step"] = float(batch.step)
self.monitor.log(metrics, step=batch.step)
# Success line — reward / turns / truncation over the effective set, error rate + branches
# over the full returned cohort. ``Stat.mean()`` is 0.0 for an empty set.
# Success line — quality metrics over the effective set, error rate over the full returned
# cohort. ``Stat.mean()`` is 0.0 for an empty set.
eff, full = effective.metrics, rollouts.metrics
triggered_at = self.eval_triggered_at.pop((batch.env_name, batch.step), None)
elapsed = (time.perf_counter() - triggered_at) if triggered_at is not None else 0.0
get_logger().success(
f"Evaluated {batch.env_name} (Step {batch.step}) | "
f"Policy v{policy_version} | {format_time(elapsed):>7} | Reward {eff.reward.mean():.4f} | "
f"Turns {eff.num_turns.mean():.1f} | Branches {full.num_branches.mean():.1f} | "
f"Turns {eff.num_turns.mean():.1f} | Branches {eff.num_branches.mean():.1f} | "
f"Error {full.has_error.mean():.1%} | Truncation {eff.is_truncated.mean():.1%}"
)
+1 -1
View File
@@ -146,7 +146,7 @@ class TrainBatch:
finalized in that span (errored + filtered included; rollouts of still-incomplete groups wait
for a later window). Its ``.effective`` / ``.metrics`` views drive logging. ``samples`` is the
trainer-bound payload (the shipped cohort's post-filter survivors) — an empty list means nothing
ships, which would stall the trainer. Trainable counts derive from ``rollouts``
ships, which would stall the trainer. Trainable counts derive from ``rollouts.effective``
(``r.is_trainable``) and token totals from ``samples``, so neither is carried as a field."""
rollouts: TrainRollouts
+25 -12
View File
@@ -298,14 +298,17 @@ class WandbMonitor(Monitor):
OVERVIEW_NAME = "overview"
# Per-rollout metrics (under "<scope>/all/") shown for BOTH train and eval. Only the reward metric
# differs — train uses "reward/mean", eval uses "avg@k" — and each section builder prepends its own.
# Per-rollout metrics (as "<subset>/<metric>" under "<scope>/") shown for BOTH train and eval.
# Quality metrics read the effective subset — the all subset includes errored rollouts, whose
# zero values skew the distributions. has_error only exists on all (effective drops errors by
# construction). Only the reward metrics differ — train uses "reward/mean", eval uses "avg@k",
# each shown for the all and effective subsets — and each section builder prepends its own.
COMMON_METRICS = [
"has_error/mean",
"is_truncated/mean",
"num_total_tokens/mean",
"num_turns/mean",
"num_branches/mean",
"all/has_error/mean",
"effective/is_truncated/mean",
"effective/num_total_tokens/mean",
"effective/num_turns/mean",
"effective/num_branches/mean",
]
STABILITY_METRICS = ["optim/grad_norm", "entropy/all/mean", "mismatch_kl/all/mean", "kl_ent_ratio/mean"]
@@ -347,15 +350,20 @@ def section(name: str, metrics: Sequence[str] = (), regexes: Sequence[str] = ())
def train_section(name: str, scope: str) -> ws.Section:
return section(name, metrics=[f"{scope}/all/reward/mean"] + [f"{scope}/all/{m}" for m in COMMON_METRICS])
return section(
name,
metrics=[f"{scope}/all/reward/mean", f"{scope}/effective/reward/mean"]
+ [f"{scope}/{m}" for m in COMMON_METRICS],
)
def eval_section(name: str, env_pattern: str) -> ws.Section:
# Same metrics as train, but eval's reward is "avg@k" (dynamic k → regex). Everything is a regex so
# one section can also serve any env (env_pattern=".*"). Only the "all" subset, like train.
# one section can also serve any env (env_pattern=".*").
return section(
name,
regexes=[f"eval/{env_pattern}/all/avg@.*"] + [f"eval/{env_pattern}/all/{m}" for m in COMMON_METRICS],
regexes=[f"eval/{env_pattern}/all/avg@.*", f"eval/{env_pattern}/effective/avg@.*"]
+ [f"eval/{env_pattern}/{m}" for m in COMMON_METRICS],
)
@@ -399,8 +407,13 @@ def list_views(entity: str, project: str) -> list[tuple[str, str]]:
def view_signature(sections: Sequence[ws.Section]) -> tuple:
train = sorted(s.name[len("train/") :] for s in sections if s.name.startswith("train/") and s.name != "train/agg")
evals = sorted(s.name[len("eval/") :] for s in sections if s.name.startswith("eval/"))
axes = {getattr(p.x, "name", p.x) for s in sections for p in s.panels if isinstance(p, wr.LinePlot)}
return (tuple(train), tuple(evals), tuple(sorted(axes)))
panels = {
(getattr(p.x, "name", p.x), tuple(getattr(m, "name", m) for m in p.y or ()), p.metric_regex)
for s in sections
for p in s.panels
if isinstance(p, wr.LinePlot)
}
return (tuple(train), tuple(evals), tuple(sorted(panels, key=str)))
def next_overview_name(base: str, existing: Sequence[str]) -> str: