Repository navigation
Conversation
…assing run_substep passed any program that exited with status 0. Model code runs before the sub-step's assertions, so raise SystemExit(0), sys.exit(), exit(), os._exit(0) or an atexit os._exit passed every sub-step, and the solution carried into later steps passed those too. Append a statement that writes a random per-run sentinel line to fd 1 after the assertions, and require it along with exit status 0. A program that exits 0 early now fails with 'the program exited before its tests finished'. The sentinel is removed from the recorded stdout tail. Signed-off-by: Salma <[email protected]>
a5583f9 to
c305e35
Compare
Remove the completion marker when a program reaches its assertions but hangs during interpreter shutdown. Cover timeout cleanup, zero or short output tails, and nonzero shutdown exits. Update the grading description to match the completion requirement. Signed-off-by: Salma <[email protected]> (cherry picked from commit 654210d)
|
@marcromeyn @Kipok — following up on the request in #4901. I rechecked readiness and pushed The follow-up fixes a reproduced timeout-path issue: assertions could finish, an exit hook could hang, and the internal completion marker would leak into the recorded stdout tail. The regression failed before the fix and passes now. It also adds zero/short-tail and nonzero-shutdown coverage and corrects the grading documentation. Completed local evidence on the published head:
A separate integration with current Remaining request: could a qualified vetter authorize CI for the full head SHA above, and could you arrange a representative five-example SciCode smoke on authorized infrastructure with the official For the smoke, please retain gym eval run --no-serve \
--agent scicode_benchmark_agent \
--input resources_servers/scicode/data/example.jsonl \
--output results/scicode-4946-smoke.jsonl \
--num-repeats 1 --temperature 0.0Complete saved generations plus real HDF5 targets can establish grading parity without new inference, but that remains replay evidence; the committed example rollouts do not retain all per-step code. I have kept this draft because the contribution policy calls for a representative model rollout for behavior changes. If your intended sequence is ready-for-review first, then CI authorization and this smoke, please explicitly confirm that review can start with the smoke still outstanding. I will preserve that gap in the PR rather than treating local regressions as full benchmark validation. |
|
The PR is still marked as draft. Could you please run SciCode on the PR branch with the real test data and share the results before marking it ready for review? |
|
@dhruvnathawani I ran SciCode on the PR branch with the official Setup
1. Model smoke (documented command) gym env start --benchmark scicode --model-type openai_model \
++scicode_benchmark_resources_server.resources_servers.scicode.test_data_fpath=<path>/test_data.h5 \
++scicode_benchmark_resources_server.resources_servers.scicode.record_step_outputs=true \
++scicode_benchmark_resources_server.resources_servers.scicode.output_tail_chars=2000 \
++scicode_benchmark_resources_server.resources_servers.scicode.record_step_code=true
gym eval run --no-serve --agent scicode_benchmark_agent \
--input resources_servers/scicode/data/example.jsonl \
--output results/scicode-4946-smoke.jsonl \
--num-repeats 1 --temperature 0.0The policy was
2. The same generations, regraded with main's runner I rebuilt each verify request from the retained 3. Passing control: reference solutions The test split does not publish reference code, so I used the dev split (15 problems, 50 sub-steps; it includes the 5 smoke problems). I accumulated
There are zero per-step differences. The two reference failures are identical under both runners, so they come from the grading stack, not the sentinel:
Both look like the dependency drift #4892 addresses. 4. Early exits with the real HDF5, through On the dev split, each solution is the problem's imports plus the exit, with no implementation:
All 250 PR-side failures report "the program exited before its tests finished", and no marker leaked into recorded stdout. 5. Tests on the merged head 145 passed across Not covered: a production-model run over the 65-problem test split, and #4892's pinned environment. CI still needs a vetter to authorize |
|
Follow-up: I reran the real-data regrades under #4892's pinned grading stack. They also correct one claim in my previous comment. Setup
Every row has zero per-step differences between the two runners. All 250 PR-side exploit failures are "exited before its tests finished" rejections, and no completion marker appears in any recorded stdout. Correction: 78.3 and 70.8 I said these looked like the dependency drift #4892 addresses. That was wrong. They fail the same way under the pinned stack, and the cause is in the dataset, not the grader:
Neither involves the completion marker: both raise ( Still not covered:
|
|
/ok to test 39d5444 |
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no concerns found.
Reviewed the completion gate and output cleanup, regression tests, execution documentation, and affected verifier/agent scoring paths. No qualifying regressions identified.
The supplied real-model smoke and before/after grading results address the validation requirements. Tests and rollouts were not executed or independently reproduced during this read-only review.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
Fixes #4901.
What and why
SciCode previously accepted any sub-step program that exited with status 0, even when model code exited before the assertions ran. This covers
raise SystemExit(0),sys.exit(),exit(),os._exit(0), and anatexithook callingos._exit(0)after a failing assertion. Accumulated solutions can carry the shortcut into subsequent sub-steps.run_substepnow appends a random per-run completion sentinel after the program and requires both that sentinel on stdout and exit code 0. The marker is written directly to fd 1, so a partial printed line or replacement ofsys.stdoutdoes not hide completion. An exit-0 run without the marker fails withthe program exited before its tests finished. Result dictionary keys are unchanged.The sentinel is removed before retaining the stdout tail, including when assertions finish but an exit hook hangs and the process times out. Regression tests cover that shutdown case, zero/short output retention, and nonzero shutdown after completion. The runner docstrings and resources-server README now describe the actual pass condition.
The sentinel is in the program text: deliberately self-inspecting code could forge it. This addresses generic early-exit grading shortcuts, not hostile-code isolation or all possible grading attacks.
Completed local validation
Final PR head:
215f0c0af71ffe91526166fd3ecb378f4d891aac. Python 3.13.16, macOS ARM64.132 tests passed: 86 SciCode resource tests and 46 SciCode agent tests, using:
PYTHONPATH=.:resources_servers/scicode:responses_api_agents/scicode_agent \ python -m pytest resources_servers/scicode/tests/test_app.py \ responses_api_agents/scicode_agent/tests -q -o addopts=''The original five early-exit regressions remain covered. The new timeout-marker regression failed before the follow-up fix and passes afterward.
Real subprocess/HDF5 integration with a small synthetic fixture: exercised
ScicodeResourcesServer.verify, interpreter preflight, program construction, HDF5 loading and reward aggregation. Two-step correct solutions retained reward 1.0; wrong solutions retained 0.0. Each of the five exit mechanisms changed from false reward 1.0 on the baseline runner to 0.0 here. This used NumPy 2.5.4, SciPy 1.18.1 and h5py 3.16.0; it is not the official SciCode dataset or fix(scicode): use a pinned scientific grading environment #4892's pinned scientific stack.Example exploit replay, comparing the runner on
main@9d6e0c2824894814359aa0739c29d141fa59b98bwith this head:raise SystemExit(0)import os; os._exit(0)These programs exit before loading HDF5 targets. This demonstrates the exploit and its rejection; it does not validate ordinary solutions against
test_data.h5.pre-commit run --all-filespassed in a full checkout. The private guardwords catalog was unavailable, so that hook reported a skipped scan; no private-catalog validation is claimed.The repository's
_validate_data_single(TestConfig(entrypoint="resources_servers/scicode", should_validate_data=True))passed. This checks the committed example/metrics/rollout fixture structure, not a new rollout.git diff --checkpassed; both contributed commits have DCO sign-offs.Related changes
A separate local integration with
main@9d6e0c2824894814359aa0739c29d141fa59b98bpassed 144 resource/agent tests. This is separate from the 132 tests on the published head.Combining the SciCode source/tests with #4892 at
e80b5c324cb147aebab44ec8c5afe2ccb5d59a6cpassed 91 component/setup tests. Source/test changes combine cleanly; both PRs edit the same README grading paragraph, which needs a small reconciliation when the second PR lands. #4892 is not incorporated into this PR. Its pinned grading environment was built from the lock and used for the real-data regrade below.Real-data SciCode run
Run on the merged head
59b507587ce2550b0dbf317a8d86675d2d6d8778with the officialtest_data.h5(sha25648b0272a…b890), using the resources server's own venv (Python 3.13.16, numpy 2.5.4, scipy 1.18.1, h5py 3.16.0; not #4892's pinned stack). Details are in the PR conversation.gym eval run --no-serveonexample.jsonl, 1 repeat, temperature 0.0, withrecord_step_outputsandrecord_step_codeon. The policy was a small local model (qwen2.5-coder:1.5bvia Ollama), so the reward is not representative: 0.2 reward, 1/15 sub-steps. No step was rejected as an early exit, and no completion marker appeared in recorded stdout.verifywith main'srun_substep(5911d628c), gives identical per-step results.Not covered: a production-model run over the 65-problem test split. CI requires a qualified maintainer to authorize the current full head SHA.
Proposed labels:
bug,area:environment.