Skip to content

feat(harbor): training metadata in the gym table, entry, rows and reward (M37) - #4860

Merged
adil-a merged 1 commit into
adasif/harbor-m38-pull-destinationfrom
adasif/harbor-m37-training-metadata
Oct 26, 2026
Merged

adil-a merged 1 commit into
adasif/harbor-m38-pull-destinationfrom
adasif/harbor-m37-training-metadata

Conversation

@adil-a

@adil-a adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

M37 of the Harbor task-format stack: training metadata. The [gym] table of a dataset's dataset.toml gains allowed_agents, domain, verified and [gym.defaults].num_repeats; together with license and type (M33) they flow into the generated run config's datasets: entry and the run's defaults. Materialized rows carry task_source (the dataset folder's name) beside _ng_digest, and the verifier's result names reward_components: only keys that sum to the reward. allowed_agents is enforced by gym eval run before any work and by the collector's pairing guard at dispatch. None of the [gym] identity, run or catalog keys enters a task's digest.

What changes

  • nemo_gym/tasks/harbor/dataset_config.py: allowed_agents (list of harness implementation names, validated: non-empty, distinct, no bare string), domain (one of Gym's Domain values; any other value is refused with the values named), verified (strict bool, default false), [gym.defaults].num_repeats (strict int >= 1), admits(). None of them shapes a task.
  • nemo_gym/tasks/harbor/task.py: task_digest folds the [gym] table in only when it shapes tasks ([gym.defaults] scaling or a [gym.tasks] override). A table that declares only license, type, allowed_agents, domain, verified or num_repeats leaves every task at its bare folder hash, exactly as no table does (previously license/type alone hashed an all-default slice in).
  • nemo_gym/tasks/harbor/materialize.py: dataset_entry() builds the datasets: entry from the table: type = effective split (validation with a license, else benchmark), license, domain, verified, allowed_agents. The validation/TBD placeholders are gone. write_rows stamps task_source on every row: the dataset folder's name, which is the taskset for a dataset target and the parent's name for a single task folder target inside a dataset (a parent that holds a dataset.toml or a manifest.toml: the folder whose table, image records and digests the preparation uses); a standalone task folder, whose parent holds neither, is labelled by its own name, so two unrelated task folders prepared from one scratch directory do not share its name. The taskset (routing, output paths, instance names) is unchanged. The label is what a results row and a trainer read, not a routing key.
  • nemo_gym/tasks/harbor/cli.py: prepare_target(agent=...) refuses a harness outside allowed_agents as soon as dataset.toml is at hand (after a hub fetch, before any manifest check, image record, build or server), naming the harness and the admitted list; gym eval run passes the resolved --agent, the oracle path is always admitted. An example dataset is refused at the same point whatever the harness (refuse_example_dataset), so neither gym eval run nor gym dataset validate writes a manifest, records or builds an image, or writes rows for smoke-test samples; build_run keeps the check as a backstop for a hand-built taskset. PreparedTaskset.task_source carries the label (_dataset_label). build_run writes [gym.defaults].num_repeats as the run config's top-level num_repeats, below config files and command-line overrides (so +num_repeats= replaces it), appends +split=<effective type> and writes the oracle's entry without allowed_agents (the list speaks of model harnesses; the dispatch guard would otherwise refuse gym dataset validate). gym dataset validate adds +num_repeats=1 unless the command line sets a count: validation is not an evaluation. The entry carries no num_repeats: collate would duplicate rows by it and the collector would multiply on top, and the metrics sidecar records the entry.
  • nemo_gym/rollout_collection.py: the dispatch-time pairing guard (_validate_agent_pairings) also reads the allowed_agents of every dataset the agent block declares (_dataset_admitted_agents) and refuses an agent type outside it, through the existing error and --allow-unsupported-pairing override. The Harbor environment server binds no resources server, so this is what refuses a run config edited to another harness after gym eval run admitted one.
  • nemo_gym/train_data_utils.py: collate keeps the task_source a materialized task row already carries; flat rows, and materialized rows without one, are stamped with the declaring instance as before. The metrics sidecar written beside a dataset's rows (and the per-type one collate writes) leaves domain, verified and allowed_agents out, as it already left prepare_script/prepare_dependencies out: catalog declarations are not properties of the rows, so flipping verified after baselining, widening allowed_agents or changing domain between two runs of one taskset and harness no longer fails data preparation with a sidecar conflict. type and license are recorded as before, for every Gym dataset; editing either still conflicts and the error names the sidecar to delete (documented).
  • nemo_gym/config_types.py: DatasetConfig and BenchmarkDatasetConfig accept domain, verified, allowed_agents (omitted from dumps when unset); BenchmarkDatasetConfig.prepare_script is optional. Domain moves above the dataset types.
  • environment_servers/harbor/verifier.py, app.py: the reward rule from the RFC. A reward key is the score and the other keys are metrics; without one every key is a component, the reward is their sum, and the result carries reward_components. Several keys without reward is no longer a terminal verification failure. Components whose sum is not finite are measured 0 with harbor:invalid_reward. summing_components is the check at the point a verifier result becomes a result (single turn, final and mean roll-ups); a roll-up that drops components logs a warning naming the task, the keys, their sum and the reward.
  • Docs: environment_servers/harbor/README.md (reward rule, settings table, "Training metadata" section with the digest rule, validate's repeat default, the domain refusal, the dispatch guard and the sidecar rule; the task_source paragraph says what the label is and is not, standalone task folders included), fern/versions/latest/pages/data/harbor-tasks.mdx ([gym] section, --agent row), gym dataset init scaffold comments.

Test plan

  • environment_servers/harbor/tests + responses_api_agents/harbor_oracle_agent/tests (-k "not partial_eval and not buildah and not validate_ and not real_image"): 438 passed, 2 deselected (409 + 22 on the base; 7 new).
  • Core unit files touched, run together on the final tree (test_harbor_tasks, test_harbor_manifest, test_harbor_scaffold, test_harbor_validation, test_benchmarks, test_cli_eval, test_cli_main, test_environment_manifest, test_environment_validation, test_environment_publication, test_eval_plan, test_global_config, test_registry, test_task_materialization, test_train_data_utils, test_rollout_collection): 1837 passed, 0 failed, 284 warnings in 186.70s (0:03:06), exit 0.
  • Unit tests per key: presence, absence and bad values (bare string, empty list, duplicates, unknown domain with the values named, string booleans, zero or fractional repeats); entry round trip through DatasetConfig/BenchmarkDatasetConfig; the licenseless benchmark path through the real parser (entry type: benchmark, verified: false, no prepare_script, split benchmark, one repeat, domain/allowed_agents kept when declared); each non-shaping key alone leaves the task digest at the folder hash while a shaping table moves it; +num_repeats= and +split= through the real parser; gym dataset validate at one repeat unless the command line sets a count; gym eval run refusal before any work; the single task folder target's label (task_source = parent inside a dataset, taskset = target; a standalone task folder under a bare scratch directory = its own name, and the parent's again once a dataset.toml or a manifest appears there); a [gym] edit of verified, allowed_agents or domain between two runs validating against the first run's metrics sidecar with no conflict file written, while a license edit still conflicts naming the sidecar; the dispatch guard (refusal naming agent, type and dataset; unset, list and bare-string admission; the override; the generated run config passing and its hand-edited copy refused; the oracle's run config passing); an example dataset refused by prepare_target for a harness and for the oracle path with no output folder, manifest or image record written, by gym eval run and gym dataset validate through the real parser (exit 2, nothing dispatched, dataset folder and results root untouched) and by build_run on a hand-built taskset of that type; a benchmark entry without prepare_script through collate; summed components, metrics-only keys, overflow, multi-turn mean/final roll-ups with the drop warning asserted.
  • Materialize of three Terminal-Bench 2.1 task folders fetched from the package store (harbor:terminal-bench/terminal-bench-2-1): generated entry with every key, three rows with task_source and _ng_digest equal to the folder digests, refusal of a non-admitted harness, benchmark defaults on the untouched copy, a single task folder target inside the dataset whose row carries the dataset's label and whose entry carries the parent's keys, and two standalone task folders under one bare scratch directory each labelled by its own name.
  • Real rollouts: gym dataset validate on OpenSandbox of a one-task dataset whose verifier writes a two-key reward.json and whose dataset.toml sets every new key with num_repeats = 2, on the final tree and through the dispatch guard: validating 1 oracle rollout(s) despite num_repeats = 2, hello [repeat 0] oracle solved 1.0, the result row with task_source, summing reward_components {"exists": 0.25, "content": 0.75} and an _ng_digest equal to the task's folder digest; the oracle's generated entry without allowed_agents. A second validate of the same taskset after editing verified = true into its dataset.toml: the sidecar of the first run records no catalog key, data preparation reports it already up to date, and the run completes with the same result row and the new dataset digest. gym dataset validate of a copy of that dataset with type = "example": exit 2 with the refusal naming its dataset.toml, the copy's manifest.toml unchanged, no image record, no results folder and no output written; the unchanged dataset validated again afterwards runs as before.
  • ruff check ., ruff format --check ., pre-commit run --files <changed>: clean.

🤖 Generated with Claude Code

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test efdd560

@adil-a
adil-a added this pull request to stack #4793 October 21, 2026 16:26
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 21, 2026 16:30
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 21, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 46413e5

@adil-a

adil-a commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 3570b60

@adil-a

adil-a commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 32a6231

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 32a6231e against immediate stack parent #4827 (342968c5). Please address the three P2 items before approval: associate admission rules with the selected dataset, honor the explicit pairing override during preparation, and preserve compatibility with existing metrics for ordinary prepared datasets. The two P3 comments are non-blocking suggestions.

Focused CPU tests passed, and the three P2 behaviors were reproduced separately. This review did not include a real model/provider rollout or trainer integration run.

Comment thread nemo_gym/rollout_collection.py Resolved
Comment thread nemo_gym/tasks/harbor/cli.py Resolved
Comment thread nemo_gym/train_data_utils.py Resolved
Comment thread tests/unit_tests/test_harbor_tasks.py Resolved
Comment thread environment_servers/harbor/app.py Resolved
@adil-a

adil-a commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b5ffbe3

@adil-a

adil-a commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4d758c8

@adil-a

adil-a commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test b3876ea

@adil-a

adil-a commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a33f451

@adil-a

adil-a commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 26c6749

ffrujeri
ffrujeri previously approved these changes Oct 24, 2026

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thorough follow-ups. I re-checked the three P2 items at 26c6749, and each now has a regression test that reproduces the original case: the dispatch guard resolves the dataset entry by the rows' taskset across agent blocks, the early admission check honors the pairing override, and the per-split sidecar keeps the preparation fields. The reward_components contract is clearly documented as Harbor-specific and optional, and the sum check before results are emitted keeps rows consistent. Required CI is green; the only failure is the non-blocking kilocode conformance probe, which this PR doesn't touch. LGTM.

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a3272f9

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d0ade33

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 4f4efc3

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 01cd7e8

@adil-a

adil-a commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1693638

@yuhezhang-ai yuhezhang-ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, Adil. I rechecked 16936389 against its current stack parent 2b803462. The early pairing override, per-split metadata compatibility, hostname fixtures, and component-reward documentation points are addressed.

The dataset-association point is partially fixed: the supported custom-name fallback still reproduces the unused-dataset rejection and the restriction bypass after rebinding. I added the reproduction details in the original thread; I would hold approval on that remaining P2.

ffrujeri
ffrujeri previously approved these changes Oct 26, 2026

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

…ard (M37)

The [gym] table of dataset.toml gains allowed_agents, domain, verified and
[gym.defaults].num_repeats. With license and type (M33) they flow into the
generated datasets: entry (type is the effective split, benchmark without a
license; the validation/TBD placeholders are gone) and the run's defaults:
num_repeats becomes the run config's top-level count, which +num_repeats=
replaces, and +split= follows the entry's type. gym dataset validate plays
each reference solution once unless the command line sets a count: validation
is not an evaluation. gym eval run refuses a harness outside allowed_agents as
soon as dataset.toml is at hand, before any image is recorded or built or any
server started, naming the harness and the list; the oracle is always
admitted. The collector's pairing guard reads the entry's allowed_agents at
dispatch too, so a run config edited to another harness afterwards is refused
there as well (the Harbor environment server binds no resources server for
the existing guard to read); the oracle's run config carries the entry
without the list. A domain outside Gym's values is refused with the values
named. Materialized rows carry task_source, the dataset folder's name (the
parent's for a single task folder target inside a dataset, one whose parent
holds a dataset.toml or a manifest.toml; a standalone task folder is labelled
by its own name, so two unrelated task folders prepared from one scratch
directory do not share its name; the taskset stays the target's), beside
_ng_digest, and collate keeps it on materialized rows. The label is what a
results row and a trainer read, not a routing key.

The verifier applies the RFC reward rule: a reward key is the score and the
other keys are metrics; without one every key is a component, the reward is
their sum and the result names them as reward_components, only ever keys that
sum to the reward (single turn, final and mean roll-ups; a roll-up that drops
components says so in a warning naming the task). Several keys without reward
is no longer a terminal failure; a non-finite sum is an invalid reward.

Core: DatasetConfig and BenchmarkDatasetConfig accept domain, verified and
allowed_agents (omitted from dumps when unset); BenchmarkDatasetConfig's
prepare_script is optional for materialized datasets. The metrics sidecar
data preparation writes beside a dataset's rows leaves domain, verified and
allowed_agents out, like prepare_script: catalog declarations are not
properties of the rows, so flipping verified after baselining, widening
allowed_agents or changing domain between two runs of one taskset and harness
does not conflict with the first run's sidecar (type and license still do,
as for every Gym dataset, and the error names the file). A task's digest folds
the [gym] table in only when it shapes tasks: identity, run and catalog keys
(license, type, allowed_agents, domain, verified, num_repeats) leave every
task at its bare folder hash. Docs in the harbor README and the Harbor tasks
page.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Adil Asif <[email protected]>
@adil-a

adil-a commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 6e09402

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40411825855

This branch was previously deployed

1 inactive deployment
public — 6e09402c Deployed Oct 26, 2026 by copy-pr-bot[bot] via release / finalize / notify #7378
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:data Datasets, preparation, task formats, and materialization feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer QA_verified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants