Repository navigation
fix(finance): isolate python_exec, stage the EDGAR index, mask unresolved rubrics - #6671
Conversation
Upstream starts the interpreter in the server's working directory, i.e. the Gym checkout, so files the policy's code wrote landed in the Gym tree (on shared storage in training). Same interpreter, flags, timeout and output. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…local_edgar_stage_dir) A runtime SQLite database should not be read in place on shared storage. With local_edgar_stage_dir set, the server copies the local index, its metadata sidecar and WAL into that node-local directory at startup and reads the copy. Copies go through a .partial name and a rename under a lock on the stage directory, so concurrent server processes on a node copy each file once. A staged copy is kept only while its size and modification time match the source; an optional file the source lacks (WAL, default sidecar) is removed from the stage so a stale copy never pairs with a new index; a missing index or configured sidecar fails at startup naming the source path. Off by default. Tests: TestLocalEdgarStaging in tests/test_app.py (10 cases). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…olve Before, a criterion the judge never resolved (transport errors, replies with no parseable 0/1 verdict, or replies cut at the judge's own max_output_tokens, after all judge_max_attempts) weighed as a miss: the row was scored (often 0.0 under dealbreaker gating) and trained, flagged only by judge_error. Now verify raises JudgeError (judge_unparseable when every failed call got a reply, judge_failed otherwise), so judge_failsafe returns the row masked and routes it to the failures sidecar. A row with no usable rubric, or a server with no judge configured, scored 0.0 and was trained; it is now masked with failure_kind verifier_error. Unchanged: no submit_final_result is the model's failure and still scores 0 unmasked; criteria the judge resolved as not met are still scored and trained. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…form main accepts On main, JudgeError takes no failure_kind and judge_failsafe takes no placeholder_reward. The previous commit used both, so seven verify tests failed with TypeError. verify now raises a plain JudgeError, and judge_failsafe masks the row as judge_failed. The message still names the first cause: a failed call, a reply with no 0/1 score, or a reply cut at max_output_tokens. The tests assert that cause. The same rows are masked. Only the judge_unparseable kind is not set. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…ge failures The benchmark README told readers to filter judge_error rows by hand, and the server configuration said that an unresolved criterion only flags the question. These rows are now masked, so both texts say that. The server README also describes local_edgar_stage_dir. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
The benchmark README now says that a row is masked when the judge did not resolve one of its criteria. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 8f347b8 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
HOLD — EDGAR staging can silently serve another corpus, and the verifier change lacks required rollout and reward-profile evidence.
Reviewed all seven changed files, surrounding callers, SQLite readers, failure routing, score aggregation, tests and documentation. Existing formal reviews and inline comments were empty.
RISK — Provide real rollout and benchmark reward evidence. The unresolved-criterion change removes previously scored rows from training and the fixed finance benchmark's means. The description explains that intended change, but explicitly reports no real rollout logs or before/after reward profile. The protected contribution requirements require representative model smoke rollouts for behavior changes and reward profiling for fixed benchmarks.
Could you provide a representative model/tool/verifier smoke trace and compare the same saved benchmark answers under a pinned judge configuration? Report before/after reward and rubric means, scored/masked counts and failure reasons. Explain the intended denominator change and confirm fully resolved rows keep their scores. A full training run is not required.
Validation: exact-head CI passed lint, core shards 0–3, Sandbox tests and Changed server tests. The server log confirms 115 BigFinance tests and 302 finance-agent tests passed, with both data validations successful. Repository suites were not rerun locally.
Focused probes ran with Python 3.13.14 in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:main-offline. Real SQLite readers reproduced the staging defect below. Scripted judge probes confirmed masking and metric exclusion; scratch-execution probes checked cleanup, output and timeout behavior. Probes extracted admitted source definitions where external dependencies were unavailable, so they do not establish full-server or real-model behavior.
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.
… copied code's source A cancelled python_exec call removed its temporary folder but left the child running, and a folder cleanup error replaced the tool result. The call now kills a child that is still running in a finally block, and it ignores folder cleanup errors. ScratchDirPythonExecTool.run is adapted from PythonExecTool.run of https://github.com/wowowoxuan1994/big-finance-benchmark at commit dffb39459dbfc96a7b38d179fec420900d616a69 (Apache-2.0). The file header now records this. A new test fails when the pinned PythonExecTool.run changes, so the copy does not drift without a signal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
…nd fix judge-failure docs and metrics Two source indexes with the same file name in one local_edgar_stage_dir overwrote each other's copy, so a running server read the other index. Each source index now gets its own subfolder, named by a hash of its absolute path. A new test stages two such indexes apart. Other changes: - Both server configurations pass local_edgar_stage_dir from env.yaml. - The stage copies only the index and its sidecar. The reader opens the index with immutable=1, so it never reads a WAL. - A failed copy removes its .partial file. - The default sidecar name comes from default_sidecar_path. - The answer that goes to the judge is capped at 50,000 characters, so a long answer does not mask the row through a judge context error. - Before the JudgeError, the server logs the failed judge replies. - get_key_metrics no longer promotes the two judge-failure counters, because masked rows never reach them. - The README and docstring describe judge_error and rows with no submission correctly. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 220e85a |
…ration folder With one folder per source path, a server that started after the source index changed copied the new version over the copy that a running server read. The running server's next connection then opened the new version, and its index and sidecar did not always come from the same version. Each version of the index and sidecar now goes into its own generation folder, named by a hash of their inode, size, modification time and change time. A generation folder never changes after it is staged. A server holds a shared lock on its generation for its whole life, and a later start removes only the generations that no process holds, so old copies do not pile up on the node disk. New tests cover a source changed while a copy is in use, a replacement with equal size and modification time, a changed sidecar, two servers on one node, the removal of unused generations, and a failed copy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test cfb5b52 |
secrets-detector reported the SHA-256 of the pinned PythonExecTool.run source as a "Hex High Entropy String". The hash now sits in its own variable with an inline "pragma: allowlist secret" comment. The .secrets.baseline file does not change. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 7013e96 |
…refuse a source that changes mid-copy The shared lock sat on an empty <gen>/.in-use file. If a cleaner outside the server deleted that file, a later start made a new one, got the exclusive lock, and removed a generation that a running server still read. The lock is now on the generation folder, opened with O_DIRECTORY, so no file inside it can replace the locked one. The generation name is now taken under the stage lock. After the copy, the stager takes the fingerprint again, and if the source changed, the start fails instead of staging a mix of two versions. A new test covers this. The README and the field description now say that the stage folder must be on a node-local disk, and that copies for other index paths and files from earlier layouts are not removed automatically. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 7e777a4 |
|
Smoke runs at Model, tool and verifier trace, with a forced judge failure (16 output tokens, 2 attempts): the policy ran the tools ( Same saved answers, re-judged on
The description has the full numbers. |
…en calls Each python_exec call runs in a fresh temporary folder. The README now says so, and that this matches the tool description, which says there is no persistent state between calls. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 88c1898 |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 830ce4d |
ffrujeri
left a comment
There was a problem hiding this comment.
Thanks. Only an unresolved criterion masks the row, so a resolved miss still scores; the python_exec folder is cleaned on every path; and staging is locked per version. One optional note inline. LGTM.
| rubric_total=len(criteria), | ||
| ) | ||
|
|
||
| if len(generated_answer) > 50_000: |
There was a problem hiding this comment.
Optional: could the 50,000-character cap become a named constant, with a test showing that a longer answer is judged on its prefix and scored, not masked? This line keeps an overlong answer from becoming a masked judge failure.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/46532622317 |
What changed and why
This PR brings three finance server changes by Jiaqi Zeng. Each one is its own commit. The later commits make the third change work on
main, update the docs, and apply review fixes.big_finance:python_execruns the policy's code in a new temporary directory for each call, and removes the directory after the call (ScratchDirPythonExecTool). Before, the code ran in the server's working directory, which is the Gym checkout. Files that the policy's code wrote landed in the Gym tree. The interpreter, its flags, the timeout and the output do not change. A cancelled call now kills the child process, and a folder cleanup error no longer replaces the tool result.finance_agent_v2: a new setting,local_edgar_stage_dir, is off by default. When you set it, the server copies the local EDGAR index and its metadata sidecar into a node-local directory at startup, and reads the copy. A SQLite database then does not run on shared storage. Each source index gets its own subfolder, named by a hash of its absolute path, so two indexes with the same file name do not overwrite each other. Each version of the index and sidecar gets its own generation folder in that subfolder, named by a hash of their inode, size, modification time and change time. A generation folder never changes after it is staged, so a running server keeps reading its own version when a later server stages a new one. A lock on the subfolder and a copy into a.partialfolder, then a rename, make sure that each version is copied once per node. An unchanged source reuses its copy. Each server holds a shared lock on its generation folder, and a later start removes only the generations that no server holds. If the source changes during the copy, the start fails instead of staging a mix of two versions. The stage folder must be on a node-local disk, because on NFS or Lustre file locks can cover only one node. A missing index or a missing configured sidecar fails at startup and names the source path. The WAL is not staged, because the reader opens the index withimmutable=1and never reads a WAL. Both server configurations passlocal_edgar_stage_dirfromenv.yaml.finance_agent_v2: a row with a criterion that the judge did not resolve is masked, not scored. The next section gives the details.Commit 4 adapts commit 3 to
main. On the source branch,JudgeErrortakes afailure_kindandjudge_failsafetakes aplaceholder_reward.mainhas neither, so with commit 3 alone, 7 tests failed withTypeError.verifynow raises a plainJudgeError, andjudge_failsafemasks the row asjudge_failed. The error message still names the first cause. Commits 5 and 6 update the benchmark README and a configuration comment, and documentlocal_edgar_stage_dirin the server README. Commits 7 to 11 apply the review fixes that this description names. Commit 12 adds a README sentence: eachpython_execcall runs in a fresh temporary folder, so files do not carry over to the next call.ScratchDirPythonExecTool.runis adapted fromPythonExecTool.runinbig_finance_harness/tools/python_exec.pyof https://github.com/wowowoxuan1994/big-finance-benchmark at commitdffb39459dbfc96a7b38d179fec420900d616a69(Apache-2.0). The header ofresources_servers/big_finance/app.pyrecords the same source. A test fails when the pinnedPythonExecTool.runchanges, so the copy does not drift without a signal.Reward changes in finance_agent_v2
These rows were scored before. They are masked now.
judge_max_attempts. The judge call failed or timed out, the reply had no 0/1 score, or the reply stopped at the judge'smax_output_tokens.must_passcriterion set the reward to 0.0.judge_errorwas set. The row was trained.verifylogs the failed judge replies and raisesJudgeError.judge_failsafereturns reward 0.0 withmask_sample: trueandfailure_kind: judge_failed. The row goes to the failures sidecar. The cause is infailure_reason.judge_error. Trained.failure_kind: verifier_error.judge_errorstays.judge_model_server.judge_error. Trained.failure_kind: verifier_error.judge_errorstays.These rows do not change. A rollout without
submit_final_resultstill scores 0 and is not masked, also when the agent stopped on a failed policy call or an aborted tool. A criterion that the judge resolved as not met still counts against the row. The FrontierFinance grader path (frontier_finance_grader) returns before this code, so it does not change.The answer that goes to the judge is now capped at 50,000 characters, so an answer longer than the judge context does not mask its row. No example answer is longer than 8,224 characters.
The failure kind is
judge_failedfor every unresolved row. The source branch usedjudge_unparseablewhen every failed call got a reply. That needsJudgeError(failure_kind=...), which #6675 adds. After #6675 lands, a one-line follow-up can set that kind.A follow-up can also mask the no-judge row as
judge_skippedinstead ofverifier_error, so thatgym evalrecovery treats a dry run as complete. That change exportsJUDGE_SKIPPEDfromnemo_gym.core, which moves a PR out of the server-only CI class, so it is not in this PR.Benchmark effect
benchmarks/finance_agent_v2(the 27 public questions, onresources_servers/finance_agent_v2/configs/finance_agent_v2.yaml): if the judge resolves every criterion, the numbers do not change. If the judge fails on a row, that row now leavesmean/reward,mean/rubric_partial_credit,mean/rubric_all_passandmean/rubric_fraction, so these means use fewer rows. Before, the row stayed in the means and its unresolved criterion counted as a miss. The server's reverify mode is stateless, sogym evalrecovery can judge the row again from its saved answer.benchmarks/frontier_finance: no change. It uses the FrontierFinance grader.benchmarks/big_finance: no reward change.python_execreturns the same output. A policy that writes a file in onepython_execcall and reads it in the next call now gets a file-not-found error, as the tool description already says ("There is no persistent state between calls"). Onmain, it found the file in the Gym checkout.grpo.masked_reward_policy: include, its placeholder reward 0.0 still counts in its group's baseline and standard deviation.excludeleaves it out. Before, these rows trained as low scores.Compatibility
local_edgar_stage_diris a new optional setting and is off by default. Existing configurations do not change. A start removes old versions of the same index path only. Copies for other index paths, and flat files that earlier versions of this code left in a stage folder, stay until you delete them.big_finance: the policy's code no longer runs in the Gym checkout. Code that read a file from the checkout by a relative path no longer finds it.finance_agent_v2: tools that removedjudge_errorrows by hand do not need to. Judge failures now come back as masked failure rows.get_key_metricsno longer promotesrubric/criteria_unresolvedandrubric/rollouts_with_judge_error, because masked rows never reach them. Gym reports judge failures as masked failures.compute_metricskeeps both counters for rollouts collected before this PR.Related PRs and issue
async_request_temp_dir. After feat(core): add temporary dir helpers, save_dir and temp_dir for runtime files #6235 lands,ScratchDirPythonExecToolcan use it in one line, so that the Gymtemp_dirsetting picks the folder. The two PRs do not touch the same files.failure_kindtoJudgeError. The reward section above explains the link.Validation
All runs were on CPU, on the tree of
7e777a4968, in the dev environment (uv sync --extra dev). The head,88c189830b, adds only the README sentence, andpre-commit run --all-filespassed on it.With the three source commits only (before commit 4), the
finance_agent_v2run had 7 failed and 295 passed. All 7 failures wereTypeErrorfrom theJudgeErrorandjudge_failsafecalls.What the new tests cover:
big_finance: two calls run in two different temporary directories. Both directories are removed, and no file lands in the working directory. The output, the empty-code error and the timeout matchPythonExecTool. A cancelled call kills its child process. A hash of the pinnedPythonExecTool.runsource guards the copy.finance_agent_v2staging:TestLocalEdgarStaging(16 cases) builds a real SQLite index. It covers the staged read, the default and the configured sidecar, one copy for an unchanged source, a new generation for a changed source or sidecar while the old copy stays unchanged, a replacement with equal size and modification time, a running server that keeps its version after another server stages a new one, two sources with the same file name that stay apart, the removal of unused generations, a failed copy, a source that changes during the copy, and the errors for missing files.finance_agent_v2masking: call failures, timeouts, cut-off replies and replies without a score raiseJudgeError, and the message names the cause.judge_failsafe(verify)returns a maskedjudge_failedrow. A criterion that the judge resolved as not met is scored and not masked. Rows with no rubric or no judge are masked asverifier_error.The CI classifier puts this PR in the server-only class. CI runs the core tests and the tests of
big_financeandfinance_agent_v2.Rollout evidence
finance_agent_v2rows on a 28 GB local EDGAR index (staged withlocal_edgar_stage_dir) and 6big_financerows.judge_failedand went to the failures sidecar ("6 failed (6 masked, not scored as zero)"). The 2 rollouts without a submission scored 0, unmasked.gym eval reverify --judge-failed-only --settle-into-sourcewith the normal judge then scored all 6 (1.0, 1.0, 1.0, 0.958, 0.667, 0.0), with no unresolved criterion.mainand on this branch with one pinned judge (temperature 0): every rollout that both runs fully resolved scored the same, except one that differed by one judge verdict (0.667 and 0.700). Onmain, one rollout with an unresolvedmust_passcriterion scored 0.0 and stayed inmean/reward. This branch masks such a rollout instead.mainreportedmean/reward0.0 over 8 rollouts (6 of them judge outages). This branch reported it over the 2 scored rollouts and 6 masked failures.big_finance: 10python_execcalls in 6 rollouts created no file in the server folder and left no temporary folder. A file written in one call was not visible in the next call.Credit
These changes were written by Jiaqi Zeng (@HeyyyyyyG). Commits 4 to 12 adapt them to
main, update the docs, and apply review fixes.🤖 Generated with Claude Code