Repository navigation
feat(harbor): add the environment server for Harbor-format tasks - #3674
Conversation
914b8a6 to
0d18371
Compare
0d18371 to
1948e57
Compare
3dd9dd9 to
ac3e67a
Compare
ac3e67a to
563d6b5
Compare
563d6b5 to
bffd9ec
Compare
bffd9ec to
e33e106
Compare
e33e106 to
18428fa
Compare
d2ae8c0 to
1042727
Compare
|
/ok to test 1042727 |
|
/ok to test e339084 |
|
/ok to test f55e0f3 |
|
/ok to test cf44a4b |
|
@adil-a thanks for the schema fix, I checked it on One thing came in with the re-fold: against
If they weren't meant to go, this restores them from the base: git checkout 8073346931cc646e1fe1f72dd5f101d9a5936219 -- \
$(git diff --name-only --diff-filter=D 8073346931cc646e1fe1f72dd5f101d9a5936219 HEAD | grep -v harbor)
|
|
/ok to test 901c9a1 |
|
Thanks for restoring the files, @adil-a. On |
|
/ok to test f1e36c7 |
ffrujeri
left a comment
There was a problem hiding this comment.
Approving f1e36c76. All review threads are resolved, the unrelated files are restored, and the rebase onto main only adds environment_servers/harbor/.gitignore and a test fixture rename. The Harbor and data-prep tests pass, and CI is green apart from the non-blocking harness conformance probes.
Follow-ups, none blocking:
- A fresh smoke rollout through the environment server and agent-session handoff. The checked-in example rollouts predate the rewrite.
- A reply to Yu's Oct 15 question about reusing upstream Harbor parsing and reward handling.
|
Thanks, I checked this against the installed harbor 0.22.0. The overlap is small and the coupling is large. What we copy from Harbor is a few hundred lines of pure code: the task.toml models, the whole-value ${VAR} template rule, the verifier mode resolution, the packager digest and the reward file precedence. The one place where byte identity matters, the content hash that names images, is already vendored unmodified. Everything Harbor builds on those pieces is bound to its trial runtime. BaseEnvironment takes trial paths and a session id, Verifier takes a Task plus an environment and uploads, execs and downloads through it, and the Docker code writes Compose override files for docker compose. Gym's sandbox providers, Compose adapter, deadlines, cleanup and failure classification have nothing to plug into there, so importing those modules means adapting them, and installing harbor would add litellm, supabase and typer to the core package. So we keep the Gym implementations and pin behaviour with tests, without taking harbor as a dependency. Today the parity coverage is Gym-side fixtures (the verbatim 0.22.0 build Compose file, the vendored hash, reward, canary and deprecated field cases) plus two importorskip tests that run Harbor's own models when the package happens to be installed. I propose adding, as a follow-up commit on this PR, golden fixtures taken from Harbor 0.22.0 (task.toml cases, template resolution, verifier mode, digest and reward files) with the expected results recorded in the test, and one README table of the intentional differences (the 28800 s default timeout, finite rewards only, the empty reward object, leading blank lines without a canary, the Gym-only [gym] table). |
|
Status note: this PR is unchanged since f1e36c7, the commit Felipe approved, which already carries the one line from M5 (#3677, now closed) in environment_servers/harbor/.gitignore. The rest of the stack is rebased on it, on top of main dc709bc, with #3675 as the next PR. The reuse assessment from 15 Oct is in the comment above. |
yuhezhang-ai
left a comment
There was a problem hiding this comment.
Reviewed f1e36c76. The three earlier findings are fixed: cancellation reaches bounded cleanup, host snapshot I/O failures remain retryable, and schema lookup preserves the agent's validator when its environment wrapper has none. All 12 focused tests passed; the full preparation path accepts a valid tau2 row and rejects one missing seed. I have no remaining blocking code finding from this follow-up.
The reuse assessment makes sense. Keeping Gym's execution lifecycle and selectively reusing small Harbor components is reasonable; the proposed fixed-version compatibility fixtures and intentional-differences table remain a nonblocking follow-up.
Please record a fresh model rollout through the current environment-server flow before merging; the existing rollout evidence covers the previous implementation.
|
/ok to test d0f4c21 |
ffrujeri
left a comment
There was a problem hiding this comment.
Re-approving d0f4c216 after the rebase onto main (968e069c5). The only change from the approved f1e36c76 is the .secrets.baseline merge: it adds just the two Harbor entries and leaves every main entry untouched. CI is green apart from the non-blocking harness conformance probes.
One environment server, `environment_servers/harbor`, runs Harbor task folders: its `/run` owns the whole episode. It checks the row's digest against the taskset mapping, snapshots the task once per digest, starts the task image through the configured sandbox provider, hands the harness a `SandboxAccess` through the agent session seed every sandboxed harness already accepts, posts the task's `responses_create_params`, closes the agent session, runs `tests/test.sh` in the same sandbox and reads the reward it wrote, then stops the sandbox. No resources server takes part; harnesses never see a sandbox handle. Failures are staged episode failures: `seed` (terminal when the task or row is at fault, retryable when the provider failed), `agent`, `cleanup` and `verification`, with the harness's observations and any usable response attached. A missing or invalid reward file is a measured zero with a namespaced `failure_kind`; only a Gym-side failure masks the sample. Verifier logs land in a fresh folder under the results root per verification. Carried from the resources-server review: snapshots under a temporary directory with the digest checked on the copy, sandbox ownership kept until a stop succeeds (retried by the episode's final cleanup and at shutdown), environment templates resolved at use and never written to rows or snapshots, episode-based sandbox TTL, root-first transfers with a default-user fallback, reward download before optional logs with unsafe members skipped, and verifier roots unlinked before preparation. The generated run config now holds an agent block (which declares the materialized rows as its validation dataset, where rollout collection looks for datasets) and a per-taskset `harbor` environment server block that names that agent. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Adil Asif <[email protected]>
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/39638648657 |
What does this PR do?
Adds
environment_servers/harbor, the environment server that runs Harbor-format task folders. Builds on #3673 (merged), which loads task folders and hub datasets into materialized rows; this is the next layer of the existing Harbor proposal, so no separate issue is needed.One
/runcall owns one episode; no resources server takes part:_ng_digestagainst the taskset mapping, snapshots and re-hashes the task once per digest (concurrent episodes share it), starts the task image through the configured sandbox provider, and prepares the workdir.SandboxAccess(the seed every sandboxed harness already accepts), posts the task'sresponses_create_params, then closes the session and keeps its observations./testsand/logs/verifier, uploads the snapshot'stests/, runsbash /tests/test.shin the same sandbox, downloads the reward first and diagnostic logs best-effort into a fresh server-generated directory.Failures are staged (
seed,agent,cleanup,verification) and carry the harness's observations and any usable response. Task or row defects are terminal; provider, transport and host-storage failures are retryable. Whentest.shran, the sample is measured: a missing, malformed or non-finite reward or a verifier timeout scores 0 with aharbor:*failure kind. Only Gym-side failures (sandbox lost, reward transfer failed, local log directory unusable) setmask_sample. A multi-keyreward.jsonwithout arewardkey is a terminal authoring error.Supporting changes:
nemo_gym/sandbox/transfer.py: shared tar-basedupload_dir/download_dirthat run as root with a default-user fallback and extract withtarfile.data_filter.nemo_gym/tasks/harbor: the generated run config now has an agent block (declaring the materialized rows as its dataset) and a per-tasksetharborenvironment server block that names that agent. The resources-server block is removed.nemo_gym/train_data_utils.py: data preparation finds thetask_data.pyschema of the environment server that drives a self-contained agent, sogym data preparevalidates Harbor rows against the schema the server enforces.data/tasks/, with their materialized rows; secrets baseline entries for the example rollout files (no credentials).Validation
pytest environment_servers/harbor/tests tests/unit_tests/test_harbor_tasks.py tests/unit_tests/test_sandbox_transfer.py tests/unit_tests/test_task_data.pyatf55e0f3: 637 passed, 1 failed locally. The failure istest_transfer_preserves_target_permissions_and_task_file_modes, which only fails under a restrictive umask such as027; it passes in CI.f55e0f3: Lint, Test, and server shards 0–4, 6 and 7 pass. Shard 5, which includesenvironment_servers/harbor, fails only inresponses_api_agents/miniswe_sandboxed_agent(APIConnectionErrorto its mock model), which this PR does not touch. The codex/opencode/pi harness conformance failures also occur onmain.ENOSPCas a retryable seed failure; malformedtask.tomlas terminal; episode-ID containment for verifier log directories; symlinked verification roots; reward precedence and parsing; failed-stop ownership through retry and shutdown.Rollouts
The checked-in
data/example_rollouts.jsonlanddata/example_metrics.json(Qwen2.5-0.5B-Instruct Q4_K_M, 5 tasks, mean reward 0.2, none masked) were produced on Oct 12 by the previous resources-server version of this layer, with a single-command smoke harness and an in-process sandbox handoff, because Enroot cannot serialize sandbox access. They exercise the carried-over verifier, transfer and cleanup logic in real Enrootubuntu:24.04sandboxes. They do not exercise this PR's/runepisode flow, the agent-sessionSandboxAccesshandoff, Hermes, or provider TTL expiration.verifiedremains false.Compatibility and benchmark impact
New server, so no existing benchmark results change. Generated Harbor run configs change shape: they no longer contain a
harbor_*_resources_serverblock, and the environment server isharbor, notsingle_agent_turn. Hand-written configs from the earlier resources-server layer must be regenerated.Unsupported task modes are rejected at seed rather than silently ignored: separate verification, explicit
[agent].user/DockerfileUSER, Dockerfile builds, sandbox-less tasks and restricted networking. Clearing/testsbefore verification intentionally differs from Harbor's shared mode, which merges tests; helpers baked into an image's/testsmust ship in the task'stests/. Consumers should readverifier_logs_dirfrom the result rather than deriving it from the episode ID. Seeenvironment_servers/harbor/README.md.Checklist
pre-commit run --all-files).git commit -s).