Skip to content

fix(orchestrator): align train metrics with trainer cohort#3033

Open
vineetjain96 wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
vineetjain96:fix/train-reward-cohort
Open

fix(orchestrator): align train metrics with trainer cohort#3033
vineetjain96 wants to merge 1 commit into
PrimeIntellect-ai:mainfrom
vineetjain96:fix/train-reward-cohort

Conversation

@vineetjain96

@vineetjain96 vineetjain96 commented Jul 15, 2026

Copy link
Copy Markdown

Summary

  • retain the exact post-filter rollout cohort represented by each trainer batch
  • compute effective reward, input/output usage, traces, and trainer-batch summaries from that cohort
  • keep finalized-group diagnostics separate from trainer-bound metrics
  • refresh older W&B overview views so their reward panel uses the trainer cohort

Problem

TrainBatch.rollouts is the finalized-group observation window, not necessarily the payload sent to the trainer. TrainSink can finalize more clean rollouts than fit in the current batch, retain overflow for the next step, or exclude rollouts that have no samples.

For example, with a batch size of six, two finalized groups of four put eight clean rollouts in the observation window. Only six ship in the current trainer batch; two remain buffered for the next one. Metrics currently treat all eight as effective now, then can omit the buffered two when they actually train. The same mismatch affects input/output usage, traces, sample tables, and environment-mix summaries.

Regression

Before #2907, TrainSink.process_batch() returned the sliced trainer cohort as TrainBatch.rollouts, so each step's reward was calculated from the rollouts selected for that trainer batch. This behavior is visible in v0.6.1.dev30 (16efd8a).

#2907 introduced the broader observation window while consolidating train and eval metrics, and used its non-errored, non-filtered effective view as an approximation of what trained. The two sets diverge at batch overflow, so the reward mismatch appears to be an unintended consequence of that consolidation rather than an intended change to training semantics.

#3013 later corrected which finalized groups belong to each observation window, but deliberately retained a window that can be broader than the sliced trainer cohort.

Fix

Carry an explicit trainer_rollouts cohort alongside the observation window. It is derived from the same sliced, post-filter, non-empty-sample rollouts that produce the trainer payload.

Use that cohort for effective metrics and trainer-bound observability while retaining the full finalized-group window for all-rollout, error, and pre-filter diagnostics. Point the curated reward panel at the effective trainer-cohort metric and document the distinction. When an existing W&B overview still uses the older all-rollout reward panel, create a versioned overview with the corrected schema instead of reusing or overwriting the saved view.

This changes accounting and observability only. It does not change rollout filtering, batching, reward assignment, samples, losses, or optimizer behavior.

Verification

All commands ran against this checkout using the existing shared environment with uv run --active --no-sync and an explicit PYTHONPATH.

  • pytest tests/unit/orchestrator/test_metrics.py tests/unit/utils/test_wandb.py -v — 13 passed
  • pytest tests/unit/orchestrator -m "not gpu" -v — 95 passed, 1 skipped
  • pytest tests/unit -m "not gpu" --ignore=tests/unit/test_configs.py --ignore=tests/unit/utils/test_metrics_server.py -q — 352 passed, 1 skipped, 81 deselected
  • pytest tests/unit/utils/test_metrics_server.py -q with proxy variables unset for localhost — 16 passed
  • pre-commit run --files <touched files> — Ruff check and Ruff format passed

tests/unit/test_configs.py was excluded from the broad shared-environment run because that environment intentionally does not contain every optional taskset package referenced by the repository's config catalog.


Note

Low Risk
Observability and logging only—no changes to filtering, batching, rewards, or trainer payloads beyond aligning what gets measured.

Overview
Train observability was treating the finalized-group observation window as the cohort that actually trained, which diverges when batching overflows or rollouts have no samples.

This PR adds an explicit trainer_rollouts on TrainBatch—the same sliced, post-filter rollouts that produce the shipped samples—and uses it for effective reward, traces, W&B samples/distributions, env mix (batch/*), and console Step lines. The broader rollouts window stays on all metrics for errors and diagnostics.

Docs and the monitor skill now point at train/.../effective/reward/mean as the main progress signal. W&B overview train panels use that metric; legacy overviews that still chart all/reward trigger a versioned view instead of reuse.

Reviewed by Cursor Bugbot for commit c9bd6f8. Bugbot is set up for automated code reviews on this repo. Configure here.

@vineetjain96
vineetjain96 marked this pull request as ready for review July 15, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant