Add NeMo-Gym integration: mini_swe_agent_2 via the agent function - #1921
Merged
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Shi-Dong
approved these changes
Jul 29, 2026
| from pathlib import Path | ||
|
|
||
| sys.path.insert(0, str(Path(__file__).resolve().parent)) | ||
| from nemogym_agent_function import _build_responses_create_params, _post_json # noqa: E402 |
Contributor
There was a problem hiding this comment.
Nit: perhaps remove the leading underscore in _build_responses_create_params and _post_json since they are not private functions?
Contributor
There was a problem hiding this comment.
I think probably we'll want to move this example out of experimental in the future, so let's switch to .py launch scripts instead of .sh.
…ion TITO chain New examples/experimental/nemo-gym recipe integrating NVIDIA-NeMo/Gym as an external environment ecosystem at the agent-function layer, the same shape as the Harbor and OpenEnv connectors: the session server records every chat-completions turn losslessly, and a thin agent function POSTs each sample to the sandbox-backed mini_swe_agent_2 agent with policy_base_url set to the session URL (the per-request override proposed in NVIDIA-NeMo/Gym#2166; the README points at that PR's branch until it merges). - nemogym_agent_function.py: one POST /run per sample; sampling kwargs mapped onto responses_create_params (temperature / top_p / max_output_tokens), the only channel mini_swe_agent_2 reads; no miles imports so it loads on CPU-only machines - nemogym_generate.py: reward hook reading the environment's grade - eval_nemogym_via_api.py + tests/: no-GPU validation — offline unit tests of the /run contract, a golden scan (gold patch through the sandbox + SWE-bench harness, no model), and an API-policy scan that drives real episodes through the same policy_base_url override - run.py: the validated GPU launcher (requires MILES_EXPERIMENTAL_ROLLOUT_REFACTOR=1, which gates the dynamic registration of the agentic flags) - user-guide docs: nemo-gym page, environments tables (agent-function connector row; NeMo-Gym's own sandbox provider API supports Daytona) Validated end-to-end: offline contract tests; a golden scan scoring 1.0 in the official SWE-bench container; a DeepSeek API-policy episode; and a 4x H200 GRPO training smoke (Qwen3-4B-Instruct-2507, SWE-bench Verified) whose episodes ran in real task containers with the official harness grading them and rewards flowing back into training. Known limitations are documented in the README: the official swebench package lacks eval specs for several SWE-Gym repos (train on SWE-bench-family instances until that gap closes), and Qwen3 templates trip the tito_session_mismatch soft diagnostic (empty <think> skeleton on re-rendered assistant history; engine-recorded tokens stay lossless). This supersedes the fork-based NeMo-Gym integration removed in #1918: same ecosystem, now driven through upstream NVIDIA-NeMo/Gym with no submodules and lossless token recording. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
nblintao
force-pushed
the
tao/nemogym-agent-function
branch
from
July 29, 2026 21:34
248f20a to
d8a0e5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
examples/experimental/nemo-gym: an agentic training recipe that integrates NVIDIA's NeMo-Gym as an external environment ecosystem at the agent function layer — the same connector shape as Harbor and OpenEnv. Miles' session server records every chat-completions turn losslessly (token ids + logprobs + loss masks), and a thin agent function POSTs each sample to NeMo-Gym's sandbox-backedmini_swe_agent_2agent withpolicy_base_urlset to the per-episode session URL. The environment runs mini-swe-agent v2 in a per-task container, grades the episode with the official SWE-bench harness, and the grade flows back through a reward hook.The per-request
policy_base_urloverride is proposed upstream in NVIDIA-NeMo/Gym#2166; until it merges, the README points at that PR's branch (upstream main + two small commits).Why
docs/user-guide/environments.mdpositions Miles as agnostic about where environments come from, with prebuilt connectors for external ecosystems. This adds NVIDIA's ecosystem to that table — driven through upstream NeMo-Gym: no submodules, no forks, and lossless token recording. It supersedes the fork-based generate-function integration removed in #1918 (which re-tokenized message text and depended on two personal-fork submodules).What is in the example
nemogym_agent_function.pyPOST /runper sample; sampling mapped ontoresponses_create_params; no miles imports so it loads on CPU-only machines.nemogym_generate.pysample.metadata.run-qwen3-4b-instruct.shMILES_EXPERIMENTAL_ROLLOUT_REFACTOR=1, which gates the dynamic registration of the agentic flags).eval_nemogym_via_api.pydownload_and_process_data.py--subset gym|verified).tests//runcontract (no network, no docker).README.mdDocs: a
user-guide/nemo-gympage plus rows in the environments tables (NeMo-Gym at the agent-function layer; its own sandbox provider API covers Docker/Daytona/Apptainer/Fargate/OpenSandbox).Validation
All four layers were run for real on 2026-07-28; the commands in the README are the exact ones used.
pytest examples/experimental/nemo-gym/tests/).swebench/sweb.eval.x86_64.*container scored reward 1.0.policy_base_urloverride — patch applied, FAIL_TO_PASS 4/5, a legitimate reward 0.0.rollout/raw_reward.Known limitations (documented in the README)
swebenchpackage lacks eval specs for several SWE-Gym repos (KeyError: 'getmoto/moto'atmake_test_spec), so SWE-Gym episodes run but error at grading — train on SWE-bench-family instances until that upstream gap closes.rollout/tito_session_mismatch_ratereads 1.0 with Qwen3-family templates (they insert an empty<think></think>skeleton when re-rendering assistant history, which the engine's output never contains). Soft diagnostic only: training tokens and loss masks come from the engine's recorded token ids. The CPU chat-template verifier passes 14/14 for this model.Test plan
bash -non the example🤖 Generated with Claude Code