Repository navigation
feat(scale_swe): run episode sessions on the shared session base, with checkpoints - #6765
Conversation
…h checkpoints scale_swe was the one SWE server with its own episode-session code on SimpleResourcesServer. It now runs on RepoTaskSessionResourcesServer and takes part in partial-rollout checkpoints like the other repository-task servers. Grading, the patch-capture failure semantics and the failure kinds are unchanged. - The base supplies the session record, lock, close fences, expiry and checkpoint export/restore. Overrides keep scale_swe's own behaviour where the base differs: a close claims the session before waiting for its lock, bounded stop waits that never cut a stop short, verifier sandboxes kept until their stop succeeds, a 503 for a retry after an attempt without a verdict, bounded shutdown, and the lenient untracked-file listing. - New for scale_swe: an episode session never closed expires after the sandbox's ttl_s; shutdown retries task sandboxes whose stop failed; an agent-run seed naming an episode session gets a 409. - The patch capture, failure kind included, is saved as a JSON value so a verify after a restore grades the same patch. - partner_if (a ScaleSWEResourcesServer subclass with its own sessions) declares restart_only and checkpoint_verify wait, keeping its behaviour. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…d base Scale-SWE kept its own verify and close on the session base. Use the base's, as the other repository-task servers do: - an identical retry gets the first verification back, masked or not; a verification that ended before it replied runs again on the patch it captured instead of answering 503; - a task sandbox that does not stop after the capture fails that verify, and the retry grades the captured patch; - a close waits for a seed or verify in progress instead of claiming the session first; - a verify after a close is masked as session_lost instead of refused with 409; - a /run verify that finds no task sandbox, such as a retry, is masked as session_lost instead of grading an empty patch. Grading, patch capture and the bounded sandbox stops are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
Use the repository-task base's listing, as the other repository-task servers do: it retries a listing the provider refused and fails the seed when it still cannot run, instead of going on with an empty list that would count the image's own untracked files as the agent's patch. The grader's apply drops those files' sections, so rewards do not change. The episode, the /run seed and partner_if's seed are retried instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…lost Once the close retry window has passed, the expired session is forgotten and a verify is masked as session_lost, not session_expired. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
The other repository-task servers document checkpoint behavior in code only. The README keeps the session behavior it documented before. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
A restart_only server never holds up a checkpoint. It declares wait because its judge-graded verify is not safe to run again, so it must not inherit Scale-SWE's replay. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…ed refusal A commit that arrives while the task sandbox's stop after capture is running waits for it and snapshots nothing, and an agent's own /run seed cannot replace an episode session. Each test fails when its protection is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
|
/ok to test baec436 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE.
I found four reliability risks in slow-stop and shutdown paths. I did not find a demonstrated score-calculation regression. The inline findings include reproductions and acceptance checks.
RISK: Required real rollout evidence is missing
Could you attach a representative model rollout and the planned OpenSandbox checkpoint → crash → restore smoke? The PR’s current description still says these have not run. This changes task-sandbox ownership, verification replay and restore behavior, so the real-run requirement in AGENTS.md applies. Include the task IDs, configuration, inspected agent/verifier outcomes and evidence that the resumed session grades the same patch. Mock tests and golden-patch grading alone do not cover that production agent path.
Coverage and validation
- I reviewed all seven PR-changed files with three delegated topic reviewers. I also accounted for the other differences against the admitted base: those paths match the merge-base and are upstream drift, not PR-authored removals. The new Scale-SWE checkpoint path passed fake-provider conformance probes against both admitted shared-runtime versions.
- CI on
baec436f9beecdd0f100c6dd23703db83ba592ccis green forNemo_CICD_Test,Unit tests / Test, core shards, sandbox tests, combined coverage, changed-server tests andLint check. The changed-server log records 132 Scale-SWE tests passed and 701 partner_if tests passed. Full server-suite shards, session-routing end-to-end and provider E2E were skipped, not passed. - Local probes used
766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:cd1b05dcdf72d6101a3a2b8292608422f0f93eb7, the default-branch CI image because the head’s container build was skipped. Successful probes covered saved-patch replay/restore, cancelled verification, failure-kind persistence, partner_if’s inherited verify and restart-only behavior. Slow-provider probes reproduced the inline issues. Existing green CI suites were not rerun. - All local execution was CPU-only with fake providers. Initial probe setup failures were corrected before interpreting results; no real model or OpenSandbox rollout ran. The admitted source checkout has no tracked-file changes.
Inline comments (escaped v1):
-
resources_servers/swebench/sandbox_sessions.pyline 245: RISK: An identical seed can return a sandbox that close already deleted.Scale-SWE newly adopts this seed path at
app.py:562. Its bounded close wait leaves the actual stop running, but shared close records its fence only after that wait succeeds. After a timeout, this membership check accepts the cached response both during deletion and after the detached stop completes, because the sandbox stays in the map.probe_seed_after_stop_comparison.py, using a realAsyncSandboxover a scripted provider, returnedstatus=200 sandbox_access_returned=True sandbox_started=Falseon head; base rejected the same sequence with 409. This hands a retrying episode a dead or dying sandbox.Could you keep close intent recorded across the bounded timeout and reject seed replay until cleanup is reconciled? Preserve identical-seed replay for genuinely open sessions and retryable close ownership. Acceptance: replay seed before and after an overlong provider deletion completes; both must be rejected, and retried close must join the original stop without starting another deletion.
-
resources_servers/swebench/sandbox_session_checkpoints.pyline 171: RISK: Inherited shutdown starts a second stop and closes the provider beneath the first.The new
Scale-SWE shutdown delegationfirst runs_stop_abandoned_session. When its bounded wait expires, the shielded stop continues. This checkpointer pass still owns the same sandbox and callssandbox.stop()directly instead of joining Scale-SWE’s_stop_tasks; provideraclose()then runs while the original stop is pending.A real-wrapper/fake-provider probe observed two concurrent provider closes, cancellation of the second, and provider-client closure with the first still running. The probe shortened the checkpointer deadline to exercise the ordering. This also occurs with checkpoint control disabled because episode sandboxes are still tracked.
Could you give both shutdown passes one joining stop owner and keep the provider available until pending stops settle or reach an explicit bounded backstop? Preserve cleanup of checkpointer-only restore forks. Acceptance: stall a sandbox created through
new_task_sandboxpast the wait; assert one concurrent deletion, no duplicate-stop cancellation, and no premature provider closure. -
resources_servers/scale_swe/app.pyline 376: RISK: The export lock defeats the busy-session shutdown bound._stop_abandoned_sessionbounds acquisition of the session lock, then tries to stop the sandbox anyway. This second lock acquisition has no bound. Patch capture holds the export lock for its entire callback, so a stalled capture prevents shutdown from even reaching_wait_for_stop.probe_shutdown_comparison.pyheld capture on an event with a 0.02-second shutdown wait. After 150 ms, head was still waiting with zero stop calls; base had finished shutdown and called stop once. Head finished only after capture was cancelled. Production capture commands have their own longer timeout, but the configured shutdown bound is lost.Could you include export-lock acquisition and its owning operation in the bounded shutdown policy? Coordinate draining/cancellation or explicitly hand unresolved cleanup to the TTL backstop; do not destroy a sandbox concurrently with snapshotting. Acceptance: hold the lock through both capture and checkpoint export beyond the shutdown budget and verify bounded, diagnosed cleanup.
-
resources_servers/scale_swe/app.pyline 379: RISK: A timed-out stop releases snapshot exclusion while deletion continues._wait_for_stoptimes out only the waiter, leaving the actual stop running. On that exception this context releases_export_locks, while the sandbox stays registered and started. A subsequent checkpoint therefore snapshots a sandbox whose deletion is still in flight, despite already having its saved capture.probe_snapshot_during_stop.pydrove the HTTP seed, verify and checkpoint routes with an event-held provider close. It printedunderlying sandbox stop still running=Truefollowed bycheckpoint completed; snapshots=1 snapshot while stop was running=True. The added stop/checkpoint test releases deletion before the wait expires, so it misses this ordering. The PR notes that overlong stops can block commits; this additionally demonstrates that export can race deletion rather than wait or fail cleanly.Could you make export account for the actual stop task, not only its bounded waiter? Either refuse/wait within the checkpoint deadline, or export the saved capture without snapshotting while keeping independent cleanup ownership. Preserve bounded caller waits and the original capture. Acceptance: hold close past
sandbox_stop_timeout_seconds, attempt a commit, and assert no snapshot starts until deletion settles; cover both completion and failure without orphaning the sandbox.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
macandro96
left a comment
There was a problem hiding this comment.
Review comments on session cleanup, configuration propagation, and shared checkpoint test coverage.
Resolve the overlap with NVIDIA-NeMo#6670, keeping both changes: - The /run (cookie) path grades and masks like an episode session, as NVIDIA-NeMo#6670 made it: a capture lost to infrastructure is masked, a repository the agent broke is a measured 0. Its capture takes the sandbox and its state out of the session first, so a re-seed during the capture keeps its own sandbox; episode sessions keep the base-backed capture that is saved for checkpoints. - A /run seed whose setup failed forgets what the capture would read and stops its sandbox, so a later verify cannot grade it, even when the stop fails. - The untracked-file listing stays the repository-task base's. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
…on base does Scale-SWE waited a bounded time for each sandbox stop and left the stop running after the wait, and bounded its shutdown wait for a busy session. On the session base that stop collided with the base's own: a close that gave up let an identical seed replay a sandbox being deleted, shutdown started a second stop and closed the provider under the first, a checkpoint could snapshot a sandbox mid-deletion, and a slow verifier stop was waited for twice. Use the base's stop and shutdown, as the other repository-task servers do: each stop waits for the provider's own stop, and shutdown stops every sandbox the server holds, the cookie path's included. sandbox_stop_timeout_seconds still loads, with a warning, and is ignored. Each grading attempt's verifier sandbox still stays with the session until its stop succeeds. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
SWEIFConfig inherits anti_cheat_required from Scale-SWE's config, but the seed called the scrub without it, so the setting did nothing. Pass it, so a required scrub that did not complete fails the seed and stops its sandbox. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
|
/ok to test 00ccb47 |
Brings in NVIDIA-NeMo#6763, whose shared checkpoint test helper the next commit uses. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
Scale-SWE's checkpoint tests repeated the scenarios NVIDIA-NeMo#6763's helper runs for every repository-task server (conformance, the seed's saved diff base, a restored verify, a capture the sandbox could not run, a fork capturing against the saved base, the agent's own /run, golden-patch restart_only and the restoring job's egress rule). Run the helper instead, and keep the Scale-SWE tests: grading in a fresh sandbox, the stored failure kind, a commit during grading or during the stop after capture, and the /run seed refusal. The helper's seed HEAD is now a full object name and its passing run prints the server's start marker, as Scale-SWE requires; the other servers accept both. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
|
/ok to test a9ec8bf |
macandro96
left a comment
There was a problem hiding this comment.
Follow-up review: failed-seed cleanup ownership and clarification of shared shutdown and verifier cleanup budgets.
The /run seed took no session lock, so another seed for the same ID, such as a retry or an episode seed, could replace its sandbox during setup; a setup that then failed cleaned up the replacement's sandbox and saved state. Seed under the lock, as the other repository-task servers and every episode seed do: an overlapping seed waits until this one is done. A /run re-seed now also waits for a verification in progress on the same session. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
Scale-SWE stopped every grading attempt's sandbox, the last one included, and the shared verify wrapper stopped a sandbox whose stop had failed again before replying: a provider that hung on both delayed the reply by two stop timeouts. Stop an attempt's sandbox only when another attempt follows and leave the last one to the wrapper's single stop, as the other repository-task servers do. A sandbox whose stop fails stays with the session for close and shutdown. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
|
/ok to test 3818e3e |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/46958801829 |
What changed and why
scale_swewas the one SWE server with its own episode-session code onSimpleResourcesServer, so #5331 left itrestart_only. This PR moves it onto the shared session base and partial-rollout checkpoints, asRepoTaskSessionResourcesServer. Grading, the patch-capture failure semantics (_PatchCaptureError/_UnreadablePatchError) and the failure kinds are unchanged.new_task_sandbox./runpath grades and masks like an episode session. Its capture takes the sandbox and its state out of the session first, so a re-seed during the capture keeps its own sandbox.partner_if(aScaleSWEResourcesServersubclass with its own sessions) declarescheckpoint_mode = "restart_only"andcheckpoint_verify = "wait", keeping its behaviour. It also passesanti_cheat_required, which it inherits from Scale-SWE's config, to its scrub.Behaviour changes without checkpoints
ttl_s(18000 s in the shipped config); a later verify is masked assession_expired, orsession_lostonce the close retry window has passed. The provider's TTL ended the sandbox at the same time before./runpath's included, after any request in progress on that session finishes. Before, each stop had a bounded wait (sandbox_stop_timeout_seconds), and the/runpath's sandboxes were left to the TTL at shutdown.sandbox_stop_timeout_secondsstill loads, with a warning, and is ignored./run) seed naming an episode session gets a 409 instead of replacing that session's sandbox.session_lost; before, it got a 409./runverify that finds no task sandbox is masked assession_lost. Before, it graded an empty patch./runseed whose setup failed stops its sandbox, and a later verify grades nothing./runseed holds the session lock, as the other repository-task servers' do: another seed for the same ID, or a re-seed during a verification, waits until it is done.Notes for reviewers
_task_sessions,_task_session_fences,_task_sandbox_response,_stop_failed_seed_sandbox,_TaskSession), so this server is tied to the base's internals.checkpoint.state_dirand refuses to start without it; before, it ranrestart_only.Issue
No GitHub issue. Requested for the Nemotron-4 post-training environments marked for rollout checkpointing.
Validation
In an existing Gym venv with
NEMO_GYM_CONFIG_DICT='{}'(otherwise Hydra parses pytest's arguments and the session tests error onmaintoo):scale_swe/testsagentic_if/testspartner_if/testsThe 22
partner_iffailures (test_recorded_context_*) fail identically onmain: the venv has no ripgrep.scale_swe/tests/test_checkpoints.py(15 tests): the eight scenarios feat(swe): checkpoint the episode sessions of five more repository-task servers #6763's helper runs for every repository-task server (tests/helpers/swe_repo_task_checkpoints.py, whose fake HEAD is now a full object name and whose passing run prints the start marker), plus Scale-SWE's own: grading in a fresh sandbox, the stored failure kind, a commit during grading or during the stop after capture, and the/runseed refusal. Existing tests changed where they assert internals that moved (session fields renamed to the base's, the fake_create_sandboxtakingsession_id), and where they asserted the verify, close and listing rules and the stop and shutdown this PR now takes from the base.pre-commit run --fileson the changed files: passed.Rollout evidence
Real model on OpenSandbox, AGA (Slurm job 2480319). Nemotron-3-Nano-30B-A3B on vLLM, OpenCode through
single_agent_turn, this PR atbaec436f9be(before the #6670 merge and the move to the base's stops and shutdown). The checkpoint landed during verify, after 8 model calls. After Gym was killed and restored, the saved capture was graded; verify completed, not masked.Local, on Docker, no model, each row's golden patch standing in for the agent: golden-patch grading and the episode path give the same rewards and the same captured patch on main and this PR for all 5 example rows. A
docker commitsnapshot stand-in also ran checkpoint → crash → restore: verify completed, same patch.🤖 Generated with Claude Code