Skip to content

feat(scicode): run scientific grading in OpenSandbox - #5474

Merged
adil-a merged 5 commits into
mainfrom
codex/scicode-opensandbox
Nov 5, 2026
Merged

adil-a merged 5 commits into
mainfrom
codex/scicode-opensandbox

Conversation

@Kipok

@Kipok Kipok commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

SciCode's scientific subprocesses can exhaust the model-serving host's memory at normal grading concurrency. Add optional OpenSandbox execution so each scientific grading attempt runs remotely while retaining the existing subprocess grader, generated test programs, and two-environment OR grading contract. Local grading remains the default. No separate issue is needed for this focused memory-isolation change.

The existing semaphore covers sandbox creation through deletion. Each attempt validates the interpreter and test-data checksum, uploads the existing grader and program, and cleans up in finally, with a finite TTL as a backstop. Infrastructure errors and SIGKILL propagate instead of being scored as incorrect model answers; sibling attempts are canceled and awaited on failure. An opt-in SciCode-Verified overlay and image-build recipe document the required interpreters, data, image digest, credentials and concurrency controls.

Validation:

  • 89 SciCode tests passed on the current head. Three new regression cases fail on the original PR and pass with the fixes.
  • Shared sandbox tests on the initial PR revision: 720 passed, 6 skipped; two direct CLI tests were rerun successfully with the venv on PATH.
  • pre-commit run --all-files passed; commit includes DCO sign-off.
  • Full repository/core coverage remains for CI. This is a server-only change under Gym's change classifier.

Representative rollout evidence: the development implementation completed a 512-row saved-program replay and a fresh 512-row model evaluation with 20 concurrent grading attempts and unlimited model admission, without host OOM or infrastructure failures. Replay matched all compared verdicts for 510/512 rows; the differences were traced to unseeded randomness and ARM/x86 floating-point rounding. All 4,582 replay sandboxes were deleted. The fresh evaluation resumed two remaining rows after an allocation timeout; the 510 preserved rows were verified unchanged.

Those live evaluations exercised the development lineage before this patch was adapted to current main's server_runtime APIs and local interpreter behavior. The unit tests above cover this submitted adaptation; the live results do not establish statistical equivalence or replace reference-solution validation. Keep the verifier image digest and architecture fixed when comparing benchmark results.

Review follow-up at f6ce911f5ec5407d20095de79224c1bb2aa9c39c:

  • Scope sibling cancellation to remote grading. A failed local step leaves executor-backed siblings holding their permits until they finish, including across a retry.
  • Run deletion in a shielded task and await it through repeated cancellation before releasing the grading permit. Regression coverage exercises both direct runner cancellation and verification with a semaphore-waiting sibling.
  • Add the SciCode entry point, image contract and concurrency/failure semantics to the Fern OpenSandbox guide. Fern check: 0 errors, 1 warning; all pre-commit hooks pass.

Live validation of the submitted adaptation (after the fixes):

  • Image digest sha256:15f95ba70bc8a8239b1d2b6bc5a72323ce74229e0260c23e91b9844efa862633, Linux amd64, corrected HDF5 MD5 2b41a7df40ddc23ce651ec05b8ecb6f8, both 2024/2025 interpreters.
  • Six fixed saved substeps across problems 9, 20 and 42 completed and were scored. All 12 per-environment verdicts match the previously captured local/native grading baseline. Subtask accuracy: 3/6 before and after; rewards for the three partially scored problems: [0, 0, 0] before and after. No discrepancies. This is a selected parity smoke, not a full benchmark score.
  • Fresh real-model generation of substep 20.1 was sent directly through the submitted verifier: 1/1 completed/scored, both environments passed, reward 1 and subtask accuracy 1. Other substeps were excluded. This tests fresh generation plus the real provider/image path; it is not another full agent/benchmark run.
  • All 14 sandboxes created by these smokes were deleted. A complete service API listing confirmed zero remaining smoke sandboxes.

The OpenSandbox overlay now defaults to 64 concurrent grading attempts; local grading remains at 20. The completed live evaluations above used 20. The higher default reduces the concurrency cap on remote execution without changing per-sandbox resources, timeouts or scoring rules; no throughput result at 64 is claimed.

@Kipok Kipok added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Nov 3, 2026
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE

I found two cancellation-related reliability risks, detailed inline, plus the validation gap and documentation suggestion below. I inspected all eight changed files and their directly affected scoring, provider, and consumer contracts. This was a static review; I didn't execute tests or contact OpenSandbox.

RISK — Validate the submitted adaptation on the real remote path

The PR description explicitly distinguishes its successful development-lineage evaluations from the submitted adaptation to current runtime APIs and interpreter behavior. Those runs are useful evidence, but they don't validate the integration exposed by the new overlay. The pinned rubric requires representative real-model rollouts for behavior-changing environment work and before/after reward evidence for fixed-benchmark verifier changes. This is a validation gap, not a demonstrated scoring defect.

Could you run a representative real-model smoke using this adaptation and provide local-versus-remote regrading of fixed saved programs? Record the reviewed commit, image digest, architecture, completed/scored counts, whole-problem reward and subtask accuracy before/after, explained discrepancies, and sandbox cleanup outcome. Preserve the local default, two-interpreter OR rule, pinned HDF5 checksum, and prefilled/sentinel accounting; this doesn't require changing verified: false or completing the separate full-baselining checklist. Acceptance is recorded evidence that representative grading completes through the submitted provider/image path, produces the expected scoring/accounting, and reclaims every sandbox created by the smoke.

NOTE — Suggestion: expose the workflow in the user docs

The benchmark instructions explain the feature, but the user-facing OpenSandbox guide has no SciCode entry point. The rubric places notable user-feature documentation in Fern. Could you add a short section or pointer with the benchmark selector, required credentials/image contract, concurrency controls, and infrastructure-failure semantics? Keep the detailed image recipe in its existing location and make clear that local grading remains the default. Static acceptance: the Fern section links to the overlay and image instructions, and its configuration agrees with the two interpreter paths and corrected HDF5 path.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread resources_servers/scicode/app.py Resolved
@Kipok

Kipok commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged upstream main 483674910 in c8d4f848d4ea69065addec0ad1ba4440803fa0ad and reconciled the package-layout changes.

89 SciCode component tests pass, including local sibling permit retention and teardown through repeated cancellation. Both inline cancellation findings are already fixed and remain covered. The provider/image parity and real-model smoke evidence is recorded in the PR description.

pre-commit run --all-files, diff whitespace checks and 724 public-API/import-boundary tests pass. This update merges main and adapts imports; no new model rollout or full local coverage run is claimed. Trusted CI needs vetter authorization for the new head.

@cmunley1

cmunley1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/ok to test c8d4f84

@cmunley1

cmunley1 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP

No remaining eligible findings in this follow-up.

  • The local cancellation guard fixes the reported sibling-failure case: local executor-backed siblings keep their permits until execution finishes, while remote siblings are still canceled and awaited.
  • The shielded teardown fixes the repeated-cancellation finding. The new regressions cover local retries and remote deletion, including verification with a semaphore-waiting sibling.
  • The Fern section resolves the documentation suggestion and agrees with the overlay and image contract.
  • The supplied validation record addresses the earlier evidence gap: six saved substeps matched all 12 local environment verdicts, before/after accuracy and rewards were unchanged, a fresh model-generated substep passed both interpreters, and all 14 smoke sandboxes were reported deleted. This is selected smoke/parity evidence, not full-benchmark equivalence or throughput validation at 64 attempts.

I compared the fixes and subsequent configuration/import changes with the previous-review tree and traced their directly affected tests, callers, and provider contracts. I found no unresolved prior findings or introduced regressions above the historical moderate-impact threshold. This was a static follow-up review; I didn't execute tests or contact OpenSandbox, and the live results remain author-reported.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

yaoyu-33
yaoyu-33 previously approved these changes Nov 4, 2026

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Moving SciCode's scientific subprocesses off the serving host fixes the OOMs, and the sandbox handling follows the repo's rules: files go through SandboxSpec.files, every attempt stops in finally (shielded through repeated cancellation), ttl_s is set, and both error_type and return_code are checked. By default, grading still runs locally and is unchanged.

Approving. I left one non-blocking suggestion inline about SIGKILL.

  • Merge order with #4892: both PRs rewrite model_post_init, _resolve_grading_interpreters and requirements.txt. Whichever lands second, keep the sandbox branch ahead of #4892's ensure_grading_env default, so sandbox mode never builds a local 3.11 environment it won't use.
  • CI: the red Core tests (shard 3) come from test_orchestration_otel.py, which can't resolve driver.gym_install.ref 'main' from GitHub. That failure is unrelated to this PR.

result = json.loads(execution.stdout or "")
if not isinstance(result, dict) or not isinstance(result.get("passed"), bool) or "error" not in result:
raise RuntimeError("SciCode sandbox returned an invalid grading result")
if result.get("returncode") == -9:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: the local runner scores a killed process as a fail (passed = proc.returncode == 0 in runner.run_substep), but here SIGKILL raises. Suppose a candidate always needs more than memory_mib. Graded locally, the answer scores 0. Graded here, /verify fails on every resume and the row never gets a score.

If the goal is to keep sandbox-limit kills apart from model answers, retry once on a fresh sandbox and then record a fail, or an explicit unscored outcome. Either way, such rows stop blocking the run. Fine as a follow-up.

@yaoyu-33 yaoyu-33 added ready-to-merge PR is approved, current, and waiting for final CI or merge and removed needs-review PR is ready for code review and waiting on a reviewer labels Nov 4, 2026

Copy link
Copy Markdown
Contributor

I'll watch this ready-to-merge PR and report substantive progress. Running on nim-gpt-6-1-sol.

Copy link
Copy Markdown
Contributor

🤖 On it — handling this as babysit-ready-to-merge.

1 similar comment

Copy link
Copy Markdown
Contributor

🤖 On it — handling this as babysit-ready-to-merge.

Copy link
Copy Markdown
Contributor

💬 CI diagnosis is blocked: the GitHub read and its bounded retry both failed because the native Git authority returned HTTP 503. I haven’t read the failing job logs, so I can’t classify the failure or safely request a CI retry. Platform access needs to recover before diagnosis can continue; the PR watch remains armed.

@Kipok

Kipok commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Checked the current-head CI log: core shard 3 failed because git ls-remote for driver.gym_install.ref main timed out, outside this diff (job 126185368131). The non-blocking KiloCode model_error failure is shared across unrelated PRs. Keeping the approved scoring behavior in this PR; the SIGKILL suggestion remains an explicit follow-up because terminal unscored outcomes versus candidate failures changes the evaluation contract. Also noted the merge-order requirement with #4892: sandbox mode must bypass the local grading-env build.

@Kipok
Kipok requested a review from a team as a code owner November 4, 2026 19:20
@Kipok

Kipok commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged current main fb340d84425fcc4f4fd10779072f03de494d9453 in 35412b265. Preserved main's process-exit reporting alongside sandbox concurrency/cancellation cleanup. Migrated the sandbox dependency extra to the new per-server pyproject.toml and regenerated uv.lock; the obsolete requirements.txt stays deleted. Validation: all 100 SciCode tests and 890 public API/import tests pass; uv lock --check, full pre-commit and whitespace checks pass. No fresh model/sandbox rollout for this compatibility merge; prior smoke evidence remains documented. The non-blocking SIGKILL scoring follow-up is unchanged. New head needs trusted-CI authorization.

@adil-a

adil-a commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

/ok to test 35412b2

@adil-a
adil-a enabled auto-merge November 5, 2026 18:42
@adil-a
adil-a added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42088901105

Copy link
Copy Markdown
Contributor

💬 GitHub access has recovered. The run named in the alert passed; the current red checks come from KiloCode’s non-blocking conformance probe, where a controlled HTTP 400 becomes an agent RuntimeError. Current-main CI didn’t execute that probe, so I haven’t established whether main shares the failure. Merge-queue validation is already in progress; I won’t request a speculative retry.

Merged via the queue into main with commit 480da64 Nov 5, 2026
72 of 75 checks passed
@adil-a
adil-a deleted the codex/scicode-opensandbox branch November 5, 2026 19:12

Copy link
Copy Markdown
Contributor

The PR is no longer an open ready-to-merge PR targeting main.

This branch was previously deployed

1 inactive deployment
public — 35412b26 Deployed Nov 5, 2026 by copy-pr-bot[bot] via release / finalize / notify #10414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers feature New capabilities, enhancements, or enablement work ready-to-merge PR is approved, current, and waiting for final CI or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants