Repository navigation
fix(ns_tools): apply the generic/math prompt in prepare_dataset.py - #5335
Conversation
|
/ok to test dd93030 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP — no correctness concerns found; one non-blocking provenance NOTE.
Reviewed all four changed files and traced prompt loading, prepared-row contracts, downstream verification, and component-test integration. The preparation script applies the shipped template without importing Skills’ prompt utilities, while missing or structurally malformed configs fail before output is opened.
Tests were inspected, not executed, in this read-only review.
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
|
/ok to test f9a17da |
yaoyu-33
left a comment
There was a problem hiding this comment.
Thanks for the thorough write-up and the before/after evidence. The fix does what it says. With the README command and the server venv (no transformers), all 256 comp-math rows come out equal to the shipped data/compmath_test.jsonl. The only difference is the tool timeout description, which the PR body already calls out. The vendored YAML body is byte-identical to Skills da85a881. All 23 ns_tools tests pass locally, and the 3 new ones fail on main as described.
There are two non-blocking notes inline. Both are on the custom-YAML route that the README now documents; the default generic/math path is unaffected:
- A template error, such as an unknown placeholder or a stray brace, fails only after the output file has been truncated.
- The
systemtemplate is written without formatting, so Skills prompts that have a system message get doubled braces.
A possible follow-up, not for this PR: the shipped rows tell the model the Python tool times out after 120 s, but configs/ns_tools.yaml enforces 10 s.
The README command for regenerating the comp-math data failed in two ways: - It exited at import with `ModuleNotFoundError: No module named 'transformers'`. prepare_dataset.py used `nemo_skills.prompt.utils.load_config`, and that module imports transformers at module scope; neither requirements.txt nor nemo-skills-tools declares it. - With transformers installed, it still could not load `generic/math`: the pinned nemo-skills-tools package (tools/pyproject.toml, no MANIFEST.in, same on Skills main) ships no prompt YAMLs. A broad `except` logged a warning per row and wrote the raw problem, so the data silently lost its prompt. Load the prompt with Gym's own `nemo_gym.prompt.load_prompt_config` from a copy of the Skills generic/math.yaml (da85a881, Apache-2.0) in prompts/, as physics_judge does for its Skills judge prompt. That drops the transformers import entirely. Load it once, before any output is written, and let a missing or malformed config fail the run. A path ending in .yaml still selects another prompt. The README now names the shipped file (data/compmath_test.jsonl, not compmath_prepared.jsonl) and the server venv the script needs. Fixes NVBug 6847514 (GitHub #4520). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: qiaochuz <[email protected]>
List resources_servers/ns_tools/prompts/generic/math.yaml in the vendored-components inventory with its upstream revision and license, as CONTRIBUTING.md requires for vendored third-party files. Addresses review feedback on this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: qiaochuz <[email protected]>
yaoyu-33
left a comment
There was a problem hiding this comment.
LGTM. The two inline notes are optional hardening for custom prompt YAMLs and can go in this PR or a follow-up.
…iting
Review feedback on the custom-YAML route the README documents:
- The system template was written unformatted, so a Skills prompt with a system
message (for example qwen3/math-cot-think) wrote `\boxed{{}}` into every row.
It is now filled with the same values as the user template, as Skills'
Prompt.fill and Gym's fill_prompt do.
- A template that loads but cannot be filled (an unknown placeholder such as
`{question}`, or a stray brace) failed on the first row, after the output file
had been truncated. Both templates are now filled once before the output is
opened, so the existing file is left as it was.
The README names the placeholders the templates can use.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
f9a17da to
5f8ad6b
Compare
|
/ok to test 5f8ad6b |
yaoyu-33
left a comment
There was a problem hiding this comment.
Re-reviewed at 5f8ad6b. Both notes are addressed:
build_input_messagesfillssystemwith the same values asuser. A Skills prompt with a system message no longer writes\boxed{{}}into the rows.mainfills both templates once before it opens the output. A bad placeholder now fails without truncating the existing file, andtest_template_error_fails_before_the_existing_output_is_truncatedchecks exactly that.
generic/math has no system message, so the 256 shipped rows are unchanged. CI is green except kilocode conformance probes, a non-blocking check that fails the same way on other PRs.
LGTM.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41495287481 |
What does this PR do?
The ns_tools README command that regenerates the comp-math data now runs and writes the
generic/mathprompt intoevery row. Before this change it either failed at import (
No module named 'transformers') or, with transformersinstalled, logged a warning per row and silently wrote the raw problem with no prompt.
Fixes NVBug 6847514. Fixes #4520. Linear GYM-1045.
Cause
prepare_dataset.pyread its prompt withnemo_skills.prompt.utils.load_config. Since #1078 (c7ab4eac8) the serverinstalls the
nemo-skills-toolssubpackage instead of the fullnemo-skillspackage, and that subpackage has neitherof the two things this script relied on:
nemo_skills/prompt/utils.py:25importstransformers.AutoTokenizerat module scope, buttools/requirements.txtdoes not declare transformers (the full package's
core/requirements.txtdoes).tools/pyproject.tomlbuilds the wheel from..withinclude-package-data = truebut has noMANIFEST.in, so noprompt YAMLs are shipped (the full package ships them through the root
MANIFEST.in). This is the same at the pinnedda85a881and on Skills main, so bumping the pin does not help.prepare_dataset.py:201-203caught every exception from loading the prompt, logged a warning and returned the problemunchanged.
Fix
nemo_skills/prompt/config/generic/math.yaml(unchanged below a provenance header) toresources_servers/ns_tools/prompts/generic/math.yaml, asphysics_judgeandugphysics_judgedo for their Skillsjudge prompts.
da85a881d972e6fec847b90cf553a0bf9bf10638(the revisionrequirements.txtpins)nemo_gym.prompt.load_prompt_config. That removes thenemo_skills.prompt.utilsimport, sotransformers is not needed at all; the server venv stays as it is.
ending in
.yamlstill selects another prompt.data/compmath_test.jsonl;compmath_prepared.jsonldoes not exist) and the servervenv the script needs.
Not chosen: adding
transformerstorequirements.txtfixes only the import, still leaves the YAMLs missing, and addsa large dependency only to read one YAML file. Fixing the Skills packaging upstream is still worth doing, but this
server cannot wait on a Skills release to work.
Before the fix
Gym
99594f29e(main), venv built fromresources_servers/ns_tools/requirements.txt, sourcecomp-math-24-25/test.txtfrom Skillsda85a881(256 rows):resources_servers/ns_tools/.venv/bin/python resources_servers/ns_tools/prepare_dataset.py \ --input /path/to/nemo_skills/dataset/comp-math-24-25/test.txt \ --output resources_servers/ns_tools/data/compmath_test.jsonl \ --prompt_config generic/math \ --tools nemo_skills.mcp.servers.python_tool::DirectPythonTool \ --verifier_type math_with_judgeSame command after
uv pip install transformers(exit 0, but 256 warnings and no prompt in any row):First row's user message:
'Find the sum of all integer bases $b>9$ for which $17_b$ ...'After the fix
Gym
dd93030a7(this branch), same venv (no transformers), same command:First row's user message:
'Solve the following math problem. Make sure to put the answer (and only answer) inside \\boxed{}.\n\nFind the sum of all integer bases ...'All 256 rows equal the shipped
data/compmath_test.jsonlexcept the tool description: the shipped rows say thePython tool times out after 120 s, while the pinned
DirectPythonToolandconfigs/ns_tools.yaml(
exec_timeout_s: 10) give 10 s. Both values date from #571; this PR does not change either.Validation
ns_tools, case "README preparation preserves all 256 original comp-math tasks using pinned Skills tools"(run with the server venv that
gym env test --resources-server ns_toolsbuilds): before (5911d628c) FAIL at"original preparation CLI runs" (
ModuleNotFoundError: transformers), after PASS (256/256 rows,generic/mathprompt applied). Neither the script nor
nemo_gym/prompt.pychanged between5911d628cand99594f29e; theREADME command above was rerun on both.
resources_servers/ns_tools/testsin a venv built fromrequirements.txt(no transformers): 23 passed (20 existing,3 new). The new tests run the README command and compare with the shipped rows, check that a missing prompt config
fails before any output is written, and check that a
.yamlpath is used as given. On main the first two fail inthe same venv with transformers added (raw problem; exit 0 on a missing config).
pre-commit run --all-files: passed.Compatibility
--prompt_confignames now resolve underresources_servers/ns_tools/prompts/(onlygeneric/mathis shipped).Other Skills names, such as
llama3-instruct/math, never loaded with the pinned package either; pass a.yamlpathfor them.
🤖 Generated with Claude Code