-
Notifications
You must be signed in to change notification settings - Fork 196
feat(eval): --backend=gym pilot for ns eval (gsm8k) #1454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gwarmstrong
wants to merge
20
commits into
main
Choose a base branch
from
georgea/convert-eval-to-gym
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ab1a709
feat(eval): add --backend={skills,gym} flag and Skills→Gym override t…
gwarmstrong 81ea7bb
feat(eval): wire --backend=gym to a GymEvalClientScript pilot (gsm8k …
gwarmstrong 4bd1542
feat(eval): gym→skills metrics adapter (math case)
gwarmstrong b2437b5
fix(eval): pick gym container when backend=gym
gwarmstrong 85d1b1c
fix(eval): point Gym backend at the Gym-shape input JSONL, not Skills'
gwarmstrong 53a2530
fix(gym translator): drop prompt_config / prompt_template
gwarmstrong 57c9f71
fix(gym eval): pass Gym-side prompt_config to ng_collect_rollouts
gwarmstrong 535f871
fix(gym eval): mkdir output dir before ng_collect_rollouts
gwarmstrong 1a53572
fix(adapters): move gym→skills adapter out of nemo_skills.pipeline
gwarmstrong f32803d
fix(gym): shell-quote extra_body dict literals
gwarmstrong 0e9278a
fix(gym): drop responses_create_params.extra_body — schema is extra='…
gwarmstrong f1ffd1d
refactor(gym eval): break the Skills output schema; use Gym native
gwarmstrong 3e01d00
feat(gym registry): add aime24, aime25, hmmt_feb25, hendrycks_math
gwarmstrong 40d3ed4
fix(gym registry): align prompt_config paths with upstream Gym main
gwarmstrong f44bea5
feat(gym registry): add gpqa (mcqa) and ifbench
gwarmstrong a7bf49e
fix(gym registry): add livecodebench (v6_2408_2505) + realign gpqa pr…
gwarmstrong e9ca290
feat(gym registry): auto-discover all 57 Skills↔Gym shared benchmarks
gwarmstrong 711fcdc
gym backend: infra fixes for judge / sandbox / translation parity
gwarmstrong 647d931
gym backend: dedicated dispatcher for --backend=gym
gwarmstrong 5d1b77a
eval_gym: trigger run_exp on the wrapping experiment
gwarmstrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Pipeline-level adapters bridging external backends to NeMo-Skills' on-disk schemas.""" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,184 @@ | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Convert Gym `ng_collect_rollouts` output into a Skills-shape `output.jsonl`. | ||
|
|
||
| The existing `nemo_skills.pipeline.summarize_results` and the | ||
| `nemo_skills.evaluation.metrics.MathMetrics` calculator read fields like | ||
| `symbolic_correct`, `predicted_answer`, `expected_answer`, and `generation` | ||
| from Skills' `output.jsonl`. Rather than teach `summarize_results` about | ||
| Gym's `rollouts.jsonl` schema, we write a parallel Skills-shape file | ||
| alongside each Gym rollouts file so the downstream metric path is unchanged. | ||
|
|
||
| For the v1 pilot only `math` is supported (the `math_with_judge` resource | ||
| server). Other `metric_type`s raise — when we expand benchmarks in Tier 2/3 | ||
| we add per-type converters here. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import json | ||
| import logging | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Any, Dict, Iterable, List | ||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # math: math_with_judge → Skills MathMetrics | ||
| # ---------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def _extract_output_text(response: Dict[str, Any]) -> str: | ||
| """Pull the assistant-message text out of an OpenAI Responses-API response.""" | ||
| chunks: List[str] = [] | ||
| for item in response.get("output", []) or []: | ||
| for c in item.get("content", []) or []: | ||
| if c.get("type") == "output_text": | ||
| text = c.get("text") | ||
| if text: | ||
| chunks.append(text) | ||
| return "".join(chunks) | ||
|
|
||
|
|
||
| def convert_math_rollout(rollout: Dict[str, Any]) -> Dict[str, Any]: | ||
| """Convert one Gym `math_with_judge` rollout dict into a Skills math prediction. | ||
|
|
||
| Maps the fields that `MathMetrics` reads: | ||
| symbolic_correct ← (library_reward == 1.0) | ||
| predicted_answer ← extracted_answer | ||
| expected_answer ← expected_answer | ||
| generation ← response.output[].content[].text (concatenated) | ||
|
|
||
| If a judge produced evaluations, surface them as `judgement` so Skills' | ||
| `is_correct_judgement` can parse them. v1 pilot benchmarks (gsm8k) don't | ||
| use the judge, so this is a best-effort placeholder. | ||
| """ | ||
| library_reward = rollout.get("library_reward") | ||
| if library_reward is None: | ||
| # Fall back to the overall reward when the server doesn't expose the | ||
| # symbolic-only signal (we lose the judge/symbolic separation but at | ||
| # least we get a pass/fail). | ||
| library_reward = rollout.get("reward", 0.0) | ||
|
|
||
| out: Dict[str, Any] = { | ||
| "generation": _extract_output_text(rollout.get("response", {}) or {}), | ||
| "predicted_answer": rollout.get("extracted_answer"), | ||
| "expected_answer": rollout.get("expected_answer"), | ||
| "symbolic_correct": bool(library_reward == 1.0), | ||
| } | ||
|
|
||
| judge = rollout.get("judge_evaluations") | ||
| if judge: | ||
| # MathMetrics calls is_correct_judgement(prediction["judgement"]) which | ||
| # expects a string. The judge_evaluations entries each have their own | ||
| # `response.output[].content[].text`; concatenate the first verdict | ||
| # text for now and revisit when Tier 2 brings judge benchmarks in. | ||
| verdicts = [] | ||
| for ev in judge if isinstance(judge, list) else [judge]: | ||
| response = ev.get("response", {}) if isinstance(ev, dict) else {} | ||
| text = _extract_output_text(response) | ||
| if text: | ||
| verdicts.append(text) | ||
| if verdicts: | ||
| out["judgement"] = "\n\n".join(verdicts) | ||
|
|
||
| return out | ||
|
|
||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # Dispatch + file IO | ||
| # ---------------------------------------------------------------------- | ||
|
|
||
|
|
||
| _CONVERTERS = { | ||
| "math": convert_math_rollout, | ||
| } | ||
|
|
||
|
|
||
| def supported_metric_types() -> List[str]: | ||
| return sorted(_CONVERTERS.keys()) | ||
|
|
||
|
|
||
| def convert_rollouts( | ||
| rollouts: Iterable[Dict[str, Any]], | ||
| *, | ||
| metric_type: str, | ||
| ) -> Iterable[Dict[str, Any]]: | ||
| try: | ||
| converter = _CONVERTERS[metric_type] | ||
| except KeyError as e: | ||
| raise NotImplementedError( | ||
| f"gym_to_skills: no converter for metric_type={metric_type!r}. " | ||
| f"Supported: {supported_metric_types()}. " | ||
| f"Add a converter to nemo_skills/pipeline/adapters/gym_to_skills.py." | ||
| ) from e | ||
| for rollout in rollouts: | ||
| yield converter(rollout) | ||
|
|
||
|
|
||
| def convert_file( | ||
| rollouts_path: str | Path, | ||
| output_path: str | Path, | ||
| *, | ||
| metric_type: str, | ||
| ) -> int: | ||
| """Read `rollouts_path`, write Skills-shape JSONL to `output_path`. Returns row count.""" | ||
| rollouts_path = Path(rollouts_path) | ||
| output_path = Path(output_path) | ||
| output_path.parent.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| n = 0 | ||
| with rollouts_path.open("r", encoding="utf-8") as fin, output_path.open("w", encoding="utf-8") as fout: | ||
| rollouts = (json.loads(line) for line in fin if line.strip()) | ||
| for prediction in convert_rollouts(rollouts, metric_type=metric_type): | ||
| fout.write(json.dumps(prediction)) | ||
| fout.write("\n") | ||
| n += 1 | ||
| LOG.info("Wrote %d converted rows from %s to %s", n, rollouts_path, output_path) | ||
| return n | ||
|
|
||
|
|
||
| # ---------------------------------------------------------------------- | ||
| # CLI | ||
| # ---------------------------------------------------------------------- | ||
|
|
||
|
|
||
| def _build_argparser() -> argparse.ArgumentParser: | ||
| p = argparse.ArgumentParser( | ||
| prog="python -m nemo_skills.pipeline.adapters.gym_to_skills", | ||
| description="Convert Gym rollouts.jsonl into Skills-shape output.jsonl.", | ||
| ) | ||
| p.add_argument("rollouts", help="Path to the Gym rollouts JSONL file.") | ||
| p.add_argument("output", help="Path to write the Skills-shape JSONL file.") | ||
| p.add_argument( | ||
| "--metric_type", | ||
| required=True, | ||
| choices=supported_metric_types(), | ||
| help="Which Skills metric calculator the output will feed.", | ||
| ) | ||
| return p | ||
|
|
||
|
|
||
| def main(argv: List[str] | None = None) -> int: | ||
| logging.basicConfig(level=logging.INFO, format="%(levelname)s %(name)s: %(message)s") | ||
| args = _build_argparser().parse_args(argv) | ||
| convert_file(args.rollouts, args.output, metric_type=args.metric_type) | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Pipeline utilities for the Gym eval/generate backend.""" | ||
|
|
||
| from nemo_skills.pipeline.utils.gym.registry import ( | ||
| GymBenchmarkConfig, | ||
| get_gym_config, | ||
| is_registered, | ||
| registered_benchmarks, | ||
| ) | ||
| from nemo_skills.pipeline.utils.gym.translator import ( | ||
| UnsupportedSkillsOverrideError, | ||
| translate_skills_overrides_to_gym, | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| "GymBenchmarkConfig", | ||
| "UnsupportedSkillsOverrideError", | ||
| "get_gym_config", | ||
| "is_registered", | ||
| "registered_benchmarks", | ||
| "translate_skills_overrides_to_gym", | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject unsupported Gym modes here.
Lines 619-650 only enforce “one benchmark per job”.
--backend=gymstill accepts multi-model inputs and chunked eval units, even though this path is scoped to a single model without chunking. Please fail fast before constructingGymEvalClientScript; otherwise those user flags are accepted and the failure moves downstream.Suggested guard
As per coding guidelines, "Avoid cases where user-passed parameters are unused; code should fail if user specifies an unsupported argument or if a required argument is missing."