Repository navigation
fix(terminal_bench_2_1): give prepared rows a stable task_id and order - #4135
Merged
Merged
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
iguehring-nvidia
force-pushed
the
iguehring/tb21-task-id
branch
from
October 6, 2026 22:54
c993851 to
c2d7047
Compare
iguehring-nvidia
marked this pull request as ready for review
October 6, 2026 23:03
iguehring-nvidia
force-pushed
the
iguehring/tb21-task-id
branch
from
October 6, 2026 23:06
62bb311 to
6767aea
Compare
prepare.py wrote rows in filesystem glob order and without an id field, so Gym fell back to the row position as the task id: "task 0" could be a different task on another machine or after a re-clone. Rows now carry task_id = the task's folder name (e.g. "path-tracing"), the id the Harbor task format uses for the same task, and are written in sorted order. The task count check now also requires the 89 task ids to be unique. Signed-off-by: Ingo Guehring <[email protected]>
iguehring-nvidia
force-pushed
the
iguehring/tb21-task-id
branch
from
October 7, 2026 05:43
6767aea to
9ba4e16
Compare
lafrancef
approved these changes
Oct 7, 2026
Contributor
|
/ok to test 9ba4e16 |
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37586994913 |
7 tasks done
yaoyu-33
pushed a commit
to yaoyu-33/Gym
that referenced
this pull request
Oct 8, 2026
…A-NeMo#4131) ## What does this PR do? Adds `gym eval plan`, which prepares one benchmark and writes a **plan file**: every task once, sorted by task id, with a SHA-256 digest of the exact input a run receives. **Why:** Gym has no single command that answers "which tasks does this benchmark have, and with exactly what inputs?" in a stable form. The prepared JSONL depends on preparation details, its row order is not guaranteed, and many rows have no id, so collation falls back to the row position. `gym eval plan` produces that answer as one file: stable task ids, a digest of each task's exact run input, and a versioned, documented format. The plan stores ids and digests, not the inputs themselves, so it stays small; a run re-prepares the data, and the digests show whether it still matches the plan. What the command does: - Selects the benchmark with the existing `--benchmark NAME[/FLAVOR]` lookup and runs its `prepare.py` (shared code with `gym eval prepare`). - Takes each task's id from `task_id`, `problem_id` or `instance_id`, the same precedence as `materialize_task` (NVIDIA-NeMo#3818); the field list is now defined once, as `TASK_ID_FIELDS` in `nemo_gym/task_materialization.py`, and used by `materialize_task`, rollout collection and the plan. Unlike collation, **there is no fallback to the row position**: a position-based id names a different task once rows are reordered, so benchmarks without an id field are refused with an actionable error. - Each task is `{task_id: {taskset, task_id}, digest}`. The digest is `sha256(canonical JSON of task_input)`, where `task_input` is the `MaterializedTask` input with routing and bookkeeping fields (`agent_ref`, `task_source`, `_ng_*`) excluded. The taskset is the dataset's declared `taskset`, or the benchmark name when it declares none. - Records the Gym version and commit and the selected config paths (relative to the checkout). - Output is deterministic (sorted tasks, canonical JSON): same Gym commit and same prepared data give a byte-identical file. - `--task-ids` plans a subset; `--schema` prints the JSON Schema; the format is labelled `nemo-gym.eval-plan.v1` and is meant to change only additively within that version. - Benchmarks with a prompt template (`prompt_config`) are refused for now; applying the template is a follow-up. `prepare_benchmark` is split into `_datasets_to_prepare` and `_prepare_datasets` so both commands share them; its behaviour is unchanged, except that the "no preparable dataset" error no longer names `gym eval prepare` (it suggests `--config <config path>` or `--benchmark <name>`). The plan considers only the benchmark datasets among the datasets to prepare. No issue filed: this is a new, additive command. Related: the Harbor task work (NVIDIA-NeMo#3673 and follow-ups) produces the same `MaterializedTask` rows and pins, so plans for Harbor datasets should line up with it. Feedback on the file format is very welcome while this is a draft. ## Validation - `pytest tests/unit_tests/test_eval_plan.py`: 20 passed (id precedence, ids and digests only (no inputs) in the file, declared taskset used, refusal of missing and duplicate ids, refusal of already-materialized rows as a config error, routing fields excluded from input and digest, subset selection, deterministic output, schema round trip, CLI: file written, subset, prompt-template refusal, several-benchmarks refusal, `--out` required, `--schema`). - `pytest tests/unit_tests/test_cli_main.py tests/unit_tests/test_cli_compat.py tests/unit_tests/test_rollout_collection.py tests/unit_tests/test_task_materialization.py tests/unit_tests/test_benchmarks.py`: all pass after rebasing onto `main`, except `test_benchmarks.py::test_every_repo_benchmark_appears_in_listing`, the DNS `gaierror` on my machine noted below. - `pytest tests/unit_tests/test_benchmarks.py tests/unit_tests/test_cli_main.py tests/unit_tests/test_cli_compat.py`: 335 passed, 1 failed. The failure (`test_every_repo_benchmark_appears_in_listing`) is a DNS `gaierror` while resolving four configs on my machine and fails identically on unmodified `main`. - `pre-commit run --all-files`: all hooks pass. - Real runs: - `gym eval plan --benchmark swebench/verified/opencode --out plan.json`: 500 tasks keyed by `instance_id`; running it twice gives byte-identical files. - `--task-ids astropy__astropy-12907,django__django-11099`: plan with those 2 tasks. - `--benchmark terminal_bench_2_1/terminus_2` (fresh preparation, on `main` with NVIDIA-NeMo#4135): 89 tasks, keyed by task folder name. - `--benchmark aime24`: refused because of its prompt template. ## Rollouts N/A: the command only prepares data and writes a file; no server, agent or model code changes. ## Compatibility and benchmark impact None. New command; `gym eval prepare` behaviour unchanged. ## Checklist - [x] I have read the [contributing guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Documentation added or updated, or N/A with justification. - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format checks pass). - [x] New source files include the required Apache-2.0 SPDX header. - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Ingo Guehring <[email protected]>
7 tasks done
elisam0
pushed a commit
to elisam0/Gym
that referenced
this pull request
Oct 15, 2026
## What does this PR do? Gives every prepared IFEval row a stable `task_id`: the source row's `key` from the upstream `input_data.jsonl` (unique for all 541 rows). Until now the rows carried only `id`, the row's position. Gym selects and plans tasks by `task_id`, `problem_id` or `instance_id`, never by position, so IFEval could not be planned (`gym eval plan --benchmark ifeval` refused it) and its tasks could not be selected by id. A positional id would also name a different task if the upstream file were reordered; the source `key` does not. `id` is kept unchanged, so nothing that reads it changes. Same approach as NVIDIA-NeMo#4135 for TB2.1. ## Validation - New test `benchmarks/ifeval/tests/test_prepare.py`: prepared rows carry the source `key` as `task_id` (download mocked). - `pytest benchmarks/ifeval/tests`: 1 passed. - `pre-commit run` on the changed files: pass. - Real run: `gym eval plan --benchmark ifeval --out plan.json` downloads and prepares the data and writes a plan with 541 tasks (`1000`, `1001`, `1005`, …), where it was refused before. ## Rollouts N/A: only the prepared rows gain a field; prompts, verifier metadata and grading are unchanged. ## Compatibility and benchmark impact None for scores. Prepared files gain a `task_id` field; re-run `gym eval prepare --benchmark ifeval` to pick it up. ## Checklist - [x] I have read the [contributing guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Documentation added or updated, or N/A with justification. N/A: the prepare script's docstring lists the new field; no documented behaviour changes. - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format checks pass). Ran on the changed files. - [x] New source files include the required Apache-2.0 SPDX header. - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Ingo Guehring <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
benchmarks/terminal_bench_2_1/prepare.pywrote rows inglob()order (filesystem order) and without an id field. Gym's task identity (_trajectory_identity,materialize_task) therefore fell back to the row position, so "task 0" could name a different task on another machine or after a re-clone.This PR:
task_idto every row, set to the task's folder name (e.g.path-tracing). That is the id the Harbor task format uses for the same task (feat(tasks): load Harbor task folders and hub datasets into materialized rows #3673 takes the folder name astask_id; feat(terminal_bench_2_1): Terminal Bench 2.1 on the Harbor task shape (M8) #3730 keeps TB2.1's folder names), so the ids stay the same when TB2.1 moves to that format. Folder names are unique by construction;task_name(terminal-bench/path-tracing) is unchanged;NUM_TASKS = 89replaces the literal in the existing count check).Servers are unaffected:
TaskDataisextra="allow", the Terminus and OpenCode run requests accept extra fields, and nothing readstask_idfrom TB2.1 rows today.Motivation: stable ids are required by
gym eval plan(#4131), which refuses position-based ids. With this change TB2.1 can be planned. No separate issue.Validation
prepare.pyviagym eval plan --benchmark terminal_bench_2_1/terminus_2(with feat(eval): add gym eval plan to write a benchmark's task list #4131 applied locally): 89 tasks, idsadaptive-rejection-sampler,bn-fit-modify, …; two runs produce byte-identical plans. Without this change the same command is refused with "89 of 89 tasks have no task id".pre-commit run --files benchmarks/terminal_bench_2_1/prepare.py: pass.Rollouts
N/A: data-only change. The added field is ignored by the TB2.1 resources server and both agents; the instruction, image and task folder of every row are unchanged. Happy to run a smoke rollout if reviewers want one.
Compatibility and benchmark impact
_ng_task_indexvalues change. Don't resume (--resume) a TB2.1 run started before this change after re-preparing the data.Checklist
pre-commit run --all-files) (so CI lint/format checks pass). Ran on the changed file.git commit -s) (so the DCO check passes).