Repository navigation
feat(rollout): task_source resolution and run-level fan-out - #2713
Conversation
eba4a36 to
e20d6be
Compare
e20d6be to
67a0664
Compare
| We provide this function as a lower level interface for running rollout collection. | ||
| """ | ||
| server_client = self.setup_server_client(head_server_config) | ||
| self.resolve_task_sources(examples, server_client.global_config_dict) |
There was a problem hiding this comment.
Direct run_examples callers receive task_source resolution here, but they do not receive agent_map, fan_out, or num_repeats, which are applied only by _preprocess_rows_from_config.
NeMo RL calls this lower-level API: https://github.com/NVIDIA-NeMo/RL/blob/a8d4c4e66964c2b4fb01eecb82c1d84c02fc94d6/nemo_rl/environments/nemo_gym.py#L688-L690
so we need a public preprocessing entry point for such callers
There was a problem hiding this comment.
Added in 3aa2fec: public RolloutCollectionHelper.preprocess_examples(examples, *, agent_map=None, fan_out=None, num_repeats=1, num_repeats_add_seed=False, global_config_dict=None). It applies the run-level knobs to caller-held rows with the same validation as the CLI path, does not mutate the inputs, and optionally resolves task_sources (or leaves that to run_examples, which keeps doing it on dispatch). run_examples' docstring now points callers at it. Happy to follow up with a NeMo RL-side change to adopt it.
9ac2e47 to
3aa2fec
Compare
|
/ok to test 3aa2fec |
|
/ok to test d3e5d4e |
3aa2fec to
d3e5d4e
Compare
…cess API Review feedback on #2713: 1. fan_out misconfiguration failed silently: an empty target list dropped every matching row (zero rollouts collected), and duplicate targets ran the row twice under one agent. Both now fail at config validation with actionable messages. 2. agent_map={source: agent} + num_repeats={source: k} did not compose: after the re-route, repeats were looked up only by the dispatched agent name, so the source-keyed entry was missed (error, or silent _default). num_repeats keys now match either side of a re-route - the dispatched agent (fan_out/agent_map target) or the row's original routing key (agent_ref.name / task_source as written in the data) - with the dispatched agent winning when both have entries. The missing-key error names both candidates; source-keyed entries no longer trip the typo warning. 3. Direct run_examples callers (e.g. NeMo RL drives dispatch through it) got task_source resolution but no agent_map/fan_out/num_repeats, which lived only inside the file-reading preprocessing. New public RolloutCollectionHelper.preprocess_examples(examples, ...) applies the run-level knobs to caller-held rows (same validation as the CLI path, inputs not mutated, optional task_source resolution), and run_examples's docstring points at it. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
d3e5d4e to
5cda9ac
Compare
…cess API Review feedback on #2713: 1. fan_out misconfiguration failed silently: an empty target list dropped every matching row (zero rollouts collected), and duplicate targets ran the row twice under one agent. Both now fail at config validation with actionable messages. 2. agent_map={source: agent} + num_repeats={source: k} did not compose: after the re-route, repeats were looked up only by the dispatched agent name, so the source-keyed entry was missed (error, or silent _default). num_repeats keys now match either side of a re-route - the dispatched agent (fan_out/agent_map target) or the row's original routing key (agent_ref.name / task_source as written in the data) - with the dispatched agent winning when both have entries. The missing-key error names both candidates; source-keyed entries no longer trip the typo warning. 3. Direct run_examples callers (e.g. NeMo RL drives dispatch through it) got task_source resolution but no agent_map/fan_out/num_repeats, which lived only inside the file-reading preprocessing. New public RolloutCollectionHelper.preprocess_examples(examples, ...) applies the run-level knobs to caller-held rows (same validation as the CLI path, inputs not mutated, optional task_source resolution), and run_examples's docstring points at it. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
e2b495b to
3edb28a
Compare
|
/ok to test 3edb28a |
…cess API Review feedback on #2713: 1. fan_out misconfiguration failed silently: an empty target list dropped every matching row (zero rollouts collected), and duplicate targets ran the row twice under one agent. Both now fail at config validation with actionable messages. 2. agent_map={source: agent} + num_repeats={source: k} did not compose: after the re-route, repeats were looked up only by the dispatched agent name, so the source-keyed entry was missed (error, or silent _default). num_repeats keys now match either side of a re-route - the dispatched agent (fan_out/agent_map target) or the row's original routing key (agent_ref.name / task_source as written in the data) - with the dispatched agent winning when both have entries. The missing-key error names both candidates; source-keyed entries no longer trip the typo warning. 3. Direct run_examples callers (e.g. NeMo RL drives dispatch through it) got task_source resolution but no agent_map/fan_out/num_repeats, which lived only inside the file-reading preprocessing. New public RolloutCollectionHelper.preprocess_examples(examples, ...) applies the run-level knobs to caller-held rows (same validation as the CLI path, inputs not mutated, optional task_source resolution), and run_examples's docstring points at it. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
3edb28a to
511de16
Compare
|
/ok to test 511de16 |
|
/ok to test 5f42941 |
|
/ok to test adeebb2 |
Rows may now carry task_source — the name of the config instance that declared their dataset — instead of a physical agent_ref. Resolution to an agent happens at dispatch preparation, against the merged running config: - instance is an agent (self-contained environment) -> route to it directly - instance is a resources server -> route to the unique agent whose resources_server.name edge references it (inversion of the edge every agent config already declares); 0 or 2+ candidates is a hard pre-dispatch error, with +agent_map named as the disambiguator - unknown or non-routable instance -> hard error with did-you-mean Resolved agent_refs are stamped into materialized inputs (run-scoped artifacts; custom drivers read them there) before anything is dispatched. Rows that already carry agent_ref are untouched, so legacy datasets and materialized artifacts behave identically. Also adds fan_out: run each matching row once per listed agent (cross-product), keyed by agent_ref.name or task_source, composing with per-agent num_repeats. This replaces the committed-data pattern of duplicating rows per agent alias (genrm_compare, jailbreak_detection). agent_map and num_repeats dict keys now also match task_source values. No observable change for existing data: routing-equivalence replay over all 220 runnable config closures shows byte-identical materialized inputs and routes. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…re agents Two edge gaps in the task_source resolver: 1. Derived artifacts carry BOTH task_source and a resolved agent_ref; agent_map lookup only checked the agent name, so a task_source-keyed entry silently failed to match such rows. Lookup now checks both names (agent name wins). 2. _validate_agent_names accepted any top-level config key, so routing to a non-agent instance (e.g. agent_map to a resources server name) passed validation and died at runtime with a 404 on /run. Validation now requires the target to be an agent instance and says so in the error. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
Pins that fanned copies POST to their distinct agent servers end-to-end (through run_examples), and that fan_out keys match the data-side name with targets final over a competing agent_map rewrite. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
The guard that resolves task_source rows before the materialized-inputs write was untested (it is dormant until collate produces task_source-only rows). Pins that materialized rows carry the resolved agent_ref alongside task_source. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…_ref Rows carrying agent_ref with no task_source are the legacy routing path (old collated/prepped artifacts). They keep working unchanged; each run now emits one DeprecationWarning with the row count, pointing at re-collation or +agent_map. The path itself is removed only after the deprecation cycle, gated on trainer integrations embedding current Gym. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
Outputs stamped agent_ref but dropped task_source, losing which environment produced each rollout (surfaced by live smoke: outputs had task_source=None). Provenance now carries both. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
Fan-out dispatches the same task to several agents, and those dispatch copies share a task index. The reward profiler grouped rollouts by task index alone, so a fanned run's per-row profile pooled every agent's rollouts into one row per task - the per-harness reward/length split was only recoverable by hand from the stamps. Now, when any task's materialized inputs span more than one agent, the profiler groups per (task, agent): each harness keeps its own profile row (stamped with agent_ref, like the agent-level metrics), its own rollout counts, and its own sample. The completion summary counts per (task, agent) the same way, so one agent's missing rollouts cannot hide behind another's completed ones. Runs where every task has a single agent - everything that exists today, including the aggregate-metrics path behind the committed metrics sidecars - keep the plain per-task grouping and byte-identical output (verified by re-running gym eval profile on a pre-change artifact and comparing bytes). Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
…cess API Review feedback on #2713: 1. fan_out misconfiguration failed silently: an empty target list dropped every matching row (zero rollouts collected), and duplicate targets ran the row twice under one agent. Both now fail at config validation with actionable messages. 2. agent_map={source: agent} + num_repeats={source: k} did not compose: after the re-route, repeats were looked up only by the dispatched agent name, so the source-keyed entry was missed (error, or silent _default). num_repeats keys now match either side of a re-route - the dispatched agent (fan_out/agent_map target) or the row's original routing key (agent_ref.name / task_source as written in the data) - with the dispatched agent winning when both have entries. The missing-key error names both candidates; source-keyed entries no longer trip the typo warning. 3. Direct run_examples callers (e.g. NeMo RL drives dispatch through it) got task_source resolution but no agent_map/fan_out/num_repeats, which lived only inside the file-reading preprocessing. New public RolloutCollectionHelper.preprocess_examples(examples, ...) applies the run-level knobs to caller-held rows (same validation as the CLI path, inputs not mutated, optional task_source resolution), and run_examples's docstring points at it. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
|
/ok to test 1aa089c |
Problem
Every dataset row must name the exact agent instance that runs it (
agent_ref.name), baked in at data prep. Consequences:genrm_comparecommits the sameexample.jsonltwice,jailbreak_detectionfive times — once per agent alias, differing only in the stamp.swe_agents_val/swe_agents_trainare alias configs that exist only so old stamped rows still resolve.Change
1. Rows can carry
task_sourceinstead ofagent_ref.task_source= the name of the config instance that declared the row's dataset. It is a fact about the data. The agent is computed from it at dispatch time.2. How a row finds its agent — first hit wins:
agent_mapentry for either name the row carries — itsagent_ref.nameor itstask_source(agent name wins)+agent_map={math_with_judge: math_with_judge_swe_agent}re-routes rows stampedtask_source: math_with_judge. Values must be agent instance names; mapping to anything else fails validation.agent_ref→ use it unchangedtask_sourcenames an agent instance → route to ittask_source: tau2_agent→ tau2_agent (self-contained envs verify in-process and declare their own datasets)task_sourcenames a resources server → route to the one agent whose config points at ittask_source: math_with_judge→math_with_judge_simple_agent, found via theresources_server: {name: math_with_judge}line already in its config+agent_map={math_with_judge: <agent>}"The resolved
agent_refis written into materialized inputs before dispatch, so drivers that readrow["agent_ref"]from materialized rows (e.g. gdpval's orchestrator) see exactly what they see today.3. New
fan_outconfig: run the same rows under N agents in one run.Fan-out happens at run preprocessing, not at collate. Data on disk stays one row per task; the per-agent copies exist only inside the run:
So no artifact ever holds per-agent copies distinguished only by
task_source— the copy and its agent stamp are created in the same step. Outputs group per agent for metrics exactly as today. Fan-out keys match the name the data carries (itsagent_ref.nameortask_source); targets are final and are not re-mapped byagent_map.4.
agent_mapand dict-formnum_repeatskey on the routing name a row carries — whichever it is.Rows used to always carry an agent name, so these dicts keyed on agent names. Rows may now carry
task_sourceinstead, and the dicts match that too:What does NOT change
agent_ref: byte-identical behavior (resolution step 2 short-circuits). Verified by replaying preprocessing + dispatch over all 220 runnable config closures in the repo: identical materialized inputs and routes.task_sourceyet. This PR is the consumer; the collate-side producer is the next PR in the stack.Tests
119 passed. New contract tests pin: RS→agent inversion, self-contained direct routing, unknown/zero/ambiguous/non-agent errors, legacy-row precedence, dual-stamped-row
agent_mapmatching, fan-out expansion + per-agent repeats + end-to-end dispatch to distinct agents + interaction withagent_map,task_source-keyedagent_map/num_repeats. Live-model smoke rollouts on the fan-out pattern (genrm_compare) are planned before the stack merges, per the repo's real-rollout policy.Reward profiling under fan-out
gym eval profilegroups its per-row report by task index. Fan-out copies of a task share a task index, so a fanned run's profile pooled every agent's rollouts into one row per task. Fixed in this PR: when a task's materialized inputs span more than one agent, the profiler groups per (task, agent) — each harness gets its own profile row (stamped withagent_ref), its own rollout counts, and its own sample. The completion summary counts the same way, so one agent's missing rollouts can't hide behind another's completed ones.Runs where every task has one agent — everything that exists today, including the aggregate-metrics path behind the committed metrics sidecars — keep the exact per-task grouping: verified by re-running
gym eval profileon a pre-change artifact and comparing output bytes (identical), plus a contract test pinning that single-agent profile rows gain no new fields.Stack
PR 2 of the dataset↔agent decoupling stack (RFC: gym-dataset-preparation, Open Question 1). Base: #2710.
🤖 Generated with Claude Code