Repository navigation
feat(visgym): add visual environments with optional context compaction - #5984
Conversation
Let training frameworks own capture roots and continuation decisions using request replay evidence and committed coordinates. Preserve completion identity, buffered Responses capture, explicit retry controls, and exact measurement through the ordinary vLLM server. Keep the existing compaction agent and model intact in this infrastructure layer. The native agent migration is a separate stacked change. Validation: 618 core/model cases and 56 retained legacy agent/model cases passed on Mac CPU across the documented runs. Combined-head GPU smoke evidence is recorded separately. Co-authored-by: alexandery <[email protected]> Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Preserve concurrent framework capture alongside upstream rollout timing, outbound telemetry, tool-call attribution, and canonical finish reasons. Keep retry suppression effective with metrics and tracing enabled. Validation: 2,475 affected Gym CPU tests and 184 paired RL compatibility tests passed; two optional custom OpenCode exporter cases skipped. Full pre-commit passed. Fern check passed with the unauthenticated redirect check skipped. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Normalize string input as a user message before capture matching and measurement. Verify unchanged history continues while omitted or changed initial questions start new roots. Validation: 840 affected Gym CPU tests, three HTTP prefix checks using the actual RL input decision, and pre-commit checks passed. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Move semantic history, policies and the context client into the reusable context_management package. Return ordinary accepted rollout history from simple_agent_with_compaction and use the ordinary vLLM capture server. Preserve shared termination semantics and remove the replaced legacy compaction session/model with its paired ASR configuration entry. Context management stays optional for external harnesses. The combined source tree exactly matches the qualified Gym PR head cf90856; no dependency or lockfile changes. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Merge main while preserving rollout dispatch tracing. Validate Responses conversion before intent registration, shield cancellation failure writes, reuse connection-safe replay controls, and root ambiguous source candidates without selecting a parent. Validated with 2,279 Gym CPU cases, four paired Gym/RL selection and reconstruction cases, and pre-commit --all-files. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Replace removed _retry arguments in context measurement, generation, and resources calls. Exercise the real ServerClient retry stack against aiohttp's accepted arguments, preserving safe connection retries and refusing ambiguous resends. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
…ements Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Merge Gym main at 4945282. Retain upstream output-budget classification in both backend routes and source-history worker-acknowledged refusal handling. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
…20261026 Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Integrate the validated source tree while retaining the published PR history. Signed-off-by: Ali Roshan Ghias <[email protected]>
Integrate the validated source tree while retaining the published PR history. Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Ali Roshan Ghias <[email protected]>
…ntracts Signed-off-by: Ali Roshan Ghias <[email protected]>
yfw
left a comment
There was a problem hiding this comment.
HOLD. This is not ready to merge yet, but each of the two blockers has a small, tested fix.
The first blocker is the six plain 409s that turn a required core test red (resources_servers/visgym/app.py:322). The second is the capture key that drops NeMo RL's rollout ID (responses_api_agents/visgym_agent/app.py:610-619). Please also fix the three risks before merge. Each one is small and has a tested fix:
- model server failures scored as 0 on the full-history path (
responses_api_agents/visgym_agent/app.py:658-681) - a malformed model action that masks the row instead of scoring it (
resources_servers/visgym/app.py:479) - the missing
source_historyrequirement (responses_api_agents/visual_context.py:29)
In the same pass, if you can:
- a row's
init_statenever reaches the environment (resources_servers/visgym/app.py:785-794) - a run that mixes
matchstick_rotationand cube rows corrupts cube frames (resources_servers/visgym/app.py:837) - a
max_stepsabovemax_model_callsdrops long episodes (responses_api_agents/visgym_agent/app.py:245)
The notes can follow: resources_servers/visgym/schemas.py:49, resources_servers/visgym/schemas.py:34-46, responses_api_agents/visual_context.py:1, responses_api_agents/visgym_agent/app.py:790 (a recommendation for other harnesses), responses_api_agents/visgym_agent/README.md:28-32, responses_api_agents/visgym_agent/app.py:563-571 and resources_servers/visgym/app.py:721.
Thank you for this adapter. It keeps cleanup running through cancellation, and it holds each observation back until a model call covers it. The overlay reuses the #3368 client instead of a private copy, and the fork pin is one packaging commit on upstream VisGym.
Process: the latest commit, cbd4e921a6, merges main and changes none of this PR's own lines. All commits have a DCO sign-off. In CI only the early jobs ran (lint, locks, DCO, copyright, secrets), and they pass. The unit and server tests wait for a maintainer to authorize the current head cbd4e921a6, and the PR body names an older SHA, 7e625a8ff2. The core job will be red until the 409 change lands. The validation list in the PR body names public-API and component test runs, but not the core session test file that fails. Locally, pre-commit passes at the reviewed head 270a984e72.
Shared files: the PR adds one core export, NeMoGymMessageForTraining, which is additive and not used by NeMo RL. It also adds two files in shared places, responses_api_agents/visual_context.py and tests/helpers/visual_context_contract.py, and only this agent uses them. With the file move (responses_api_agents/visual_context.py:1) and the union removal (resources_servers/visgym/schemas.py:34-46), the PR changes nothing under nemo_gym/ or tests/. The lock-policy entry applies only to resources_servers/visgym, and the README row is generated. #5983 has byte-identical copies of the two shared files and the same export, so the same changes apply there.
A faster path, if you want one: move the compaction overlay to a follow-up PR. That takes four comments out of this PR: responses_api_agents/visual_context.py:29, responses_api_agents/visual_context.py:1, responses_api_agents/visgym_agent/app.py:245 and responses_api_agents/visgym_agent/README.md:28-32. This is a choice, not a requirement. The capture-key fix still applies to the full-history path.
Rollout evidence: the November 10 run covered only the compaction overlay, and it predates main's capture changes. After the fixes, one run of environments/visgym/config.yaml on the five example rows at the new head will show the default path.
Context, fine to skip:
- Open draft #2730 adds the same three folders (
resources_servers/visgym,responses_api_agents/visgym_agentandenvironments/visgym), so the two PRs cannot both merge as they are. The provenance commit that the PR body links (22742c1) does not resolve on GitHub. - No CI lane collects the benchmark tests (
test_prepare.py,test_component_setup.py). Also,test_server_ci_validates_manifest_verifierbuilds the full 1.2 GB resources server venv, with a git fetch, as a side effect.
Generated by Claude Code
Signed-off-by: Ali Roshan Ghias <[email protected]>
|
@yfw, pushed the review fixes in 8d412d8 and a591942; the current head is Alongside the conflict exception, capture identity, infrastructure-failure and source-history fixes, explicit initial states now reach the wrapped provider, grammar-invalid model actions that raise type/value/overflow errors remain scored, and both pyplot families share one lock through construction and cleanup. The duplicate tombstones and task-field declarations are removed; helpers are component-local and the existing core response union is reused. Validation on the pushed source: 80 resource tests, 123 agent/HTTP/core-session checks and five workload/manifest checks passed, plus full pre-commit. Four new correctness regressions failed before the repair. Real-provider checks cover wrapped initial state, sliding-block malformed actions, and matching serial/concurrent image payloads across eight mixed-family episodes. This does not establish all-family rendering correctness. Live E2E validation is still incomplete. At the latest job check, the full-history smoke reached model readiness but failed in the test launcher's directory creation before any rollout; the compaction learner was still queued. No new live rollout, optimizer-update or checkpoint/resume pass is claimed. The earlier November 10 rollout evidence does not validate these new changes. The optional migration to another harness remains outside this PR. I have left the review threads open for your verification. |
Signed-off-by: Ali Roshan Ghias <[email protected]>
|
The fixes look good, and I resolved the 12 fixed threads. Before approval, can you post one default-path smoke run at the current head Please run Your last comment says the full-history smoke failed in the launcher before any rollout. The November 10 run covered only the overlay. Generated by Claude Code |
|
Tested the current head With the original 1,024-token budget, every row completed verification but scored 0 / task_success=false: this reasoning model exhausted its output budget before producing an action. These were legitimate scored failures, not masked infrastructure failures. I then ran a separate diagnostic changing only the row output limit to 8,192 tokens, preserving all other row fields. All five seeds, 1234–1238, succeeded, each with reward 1, task_success=true, and five model calls. All 25 calls returned HTTP 200, with no truncations or masks. For seed 1234, the actions were This demonstrates working multi-turn gameplay, while also exposing that the original example budget is too restrictive for this model. It is not an RL-training or benchmark-quality claim. Model serving used temperature 1/top_p 1 to match the NeMo-RL endpoint’s sampling profile; the example rows request temperature 0.7. Agent/resource defaults were preserved. |
|
/ok to test cf0f168 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/45728741564 |
What does this PR do?
Add VisGym resources and Responses API agent components for visual reset/action/step/verification episodes, with optional capture-backed context compaction. The default retains full history; the compaction overlay retains first-plus-latest-two reasoning/images while preserving actions and observation boundaries. It uses measured admission and the shared client/policy from #3368.
Context-management dependency #3368 is merged. This PR targets NVIDIA-NeMo/Gym main and incorporates upstream
da75c436c3a17ba942a5b59ba31c0757727f59f5. Review the adapter-only diff. Both game adapters remain independent siblings; their common admission helper, core export and test helper are identical. No separate issue is needed for this scoped adapter integration.The scope cleanup removes optional debug/transition plumbing and experiment-specific helpers while retaining the shared compaction client, capture identity, history boundaries, native reward and lifecycle protections. The November 20 refresh updates the four affected component locks to reflect upstream's optional Ray/E2B bounds. Resolved package versions, sources and simulator revisions are unchanged.
The adapter owns resource sessions, bounded cleanup and verification retries; infrastructure failures are masked, while legitimate model failures remain scored. Native accumulated reward remains the default; the qualification workload explicitly selects binary task success. Includes isolated component dependencies, deterministic smoke preparation, verifier fixtures, usage aggregation and rollout/capture identity propagation. Component-local pytest importlib mode and namespace-package discovery prevent provider/module shadowing during tests. No shared resources package marker or edits to existing Aviary components are needed.
Validation — November 20 refresh
Scope cleanup: the component-local discovery replacement passed 70 Gym-V resource tests plus 73 agent/workload tests, and 73 VisGym resource tests plus 89 agent/workload tests, with no skips. Both full pre-commit and resource lock checks passed. Aviary and the shared resources package layout match upstream main. Normal per-component CI discovers the local pytest configuration automatically; combined tests from the repository root should select
--import-mode=importlib -o consider_namespace_packages=true. The public API checks below preceded this test-discovery-only cleanup.uv lock --checkpass. Full repository pre-commit passes, including guardwords and layering. Both new commits are signed off. Root dependency files match upstream main.Rollouts
Representative real-model compaction smoke completed on November 10 (job 8838475, exit 0), using Super step_120, 8,192 output tokens, measured 51,200-token context and up to 20 calls. Measurement and generation both explicitly set
truncate_history_thinking=falseso the model template preserves selected reasoning.Compatibility and benchmark impact
Experimental status and
verified: falseremain. Maze3D, Fetch and custom reward shaping are explicitly rejected pending separate qualification; this PR ships the supported native-rendering path and Maze2D smoke inputs. Existing environments are not reconfigured. The legacy-agent relay remains the dispatch boundary; the agent does not claim typed-turn telemetry. The optional overlay uses 20 calls and 8,192/51,200 output/context limits without changing model sampling. Additional task families need their own audited success predicates and assets.VisGym is an external Git dependency pinned to the packaging fork at
33f996cda320db5f127b1e2a858c5653bebc90fc, based on upstream927271d107ad0196ad6aa597095ca57d01c6ddbb. It removes only three duplicate normalized extras; simulator code/data are unchanged. No provider wheel is bundled in this PR's tree or new commit history. Upstream LICENSE/NOTICE and metadata remain unchanged, including the MIT-metadata/Apache-root discrepancy; ATTRIBUTIONS records it without assigning new terms. Stock PyPI Gymnasium is not an interchangeable dependency. Optional robotics/counting dependencies are outside this smoke qualification.The adapter is extracted from existing NVIDIA-NeMo/Gym work at 22742c13589b610d6af81a87949916b7f682b62f, Apache-2.0, under
resources_servers/visgymandresponses_api_agents/visgym_agent. It is not copied from the external simulator implementation; that implementation remains an isolated dependency. No NeMo-RL code is included.Checklist
For contributor CI, a qualified maintainer must authorize the current head with
/ok to test 7e625a8ff247631d3a43bf513ab7c0c5121a3dbf. No trust-gate comment is part of this refresh.