Skip to content

feat: Initial integration with OpenEnv - #719

Closed
bxyu-nvidia wants to merge 298 commits into
mainfrom
ahmadki/openenv
Closed

bxyu-nvidia wants to merge 298 commits into
mainfrom
ahmadki/openenv

Conversation

@bxyu-nvidia

Copy link
Copy Markdown
Contributor

No description provided.

bxyu-nvidia and others added 30 commits September 21, 2025 18:11
…ning (#66)

Remove unnecessary Github Action CI and add uv config to enable
dependency scanning

* This project's current CI doesn't need to build and test through a
docker image. So, deleting the unnecssary CI Dockerfile and Github
Actions template
* Adding `managed = true` under `[uv.tool]` to allow for repo dependency
scanning

---------

Signed-off-by: Charlie Truong <[email protected]>
This implements a simple rounding rule for `AvgMinMax` floats in order
to keep example_metrics consistent.
For background, the addition of median and std dev did not assign a
ceiling for decimal places, so trivial value differences such as `1.2 !=
1.200002` caused ValueErrors.

---------

Signed-off-by: Frankie Siino <[email protected]>
…dd uvicorn logging filtering (#79)

Signed-off-by: Brian Yu <[email protected]>
From now on, any Github repo under the Nvidia-NeMo org will use the
default Issues system / behavior
(unless overwritten i.e. in this case the individual repo would have a
.github/ISSUE_TEMPLATE folder in the repo itself, effectively overriding
the default behavior coming from the NVIDIA-NeMo/.github repo [which
establishes the default system]).

Default behavior for Issues creation now is :
- There is a Bug Report issue
- There is a Feature Request issue
- Blank issues are NOT allowed to be created
# Add `num_repeats` hyperparameter for dataset repetition

## Summary
Adds optional `num_repeats` parameter to `DatasetConfig` that allows
repeating each dataset sample during training data processing and
preparation.

## Changes
- **Config**: Added `num_repeats: Optional[int] = Field(default=None,
ge=1)` to `DatasetConfig`
- **Processing**: Modified `_iter_dataset_lines()` to repeat each line
`num_repeats` times (defaults to 1)
- **Integration**: Updated data validation, metrics aggregation, and
preparation workflows to handle repeated samples
- **Documentation**: Updated README with usage examples

## Usage
```yaml
datasets:
  - name: train
    type: train
    jsonl_fpath: data/train.jsonl
    num_repeats: 3  # Each sample appears 3 times during processing
```

## Testing
Added comprehensive unit tests covering:
- Configuration validation (accepts positive integers, rejects invalid
values)
- Data iteration with different repeat values
- Metrics aggregation with repeated samples
- Data preparation workflow integration

All existing functionality preserved with backward compatibility
(defaults to 1 repetition).

---------

Signed-off-by: Mahan Fathi <[email protected]>
Signed-off-by: Brian Yu <[email protected]>
Co-authored-by: Brian Yu <[email protected]>
Signed-off-by: Brian Yu <[email protected]>
Signed-off-by: Khushi Bhardwaj <[email protected]>
Co-authored-by: Khushi Bhardwaj <[email protected]>
This PR adds a pre-commit hook that scans the resource_server
directories and populates/updates the designated table in the readme
with the pertinent information.

Addresses item 1 from #81

---------

Signed-off-by: Frankie Siino <[email protected]>
Signed-off-by: Brian Yu <[email protected]>
Co-authored-by: Brian Yu <[email protected]>
Signed-off-by: slikhite-1 <[email protected]>
Co-authored-by: slikhite-1 <[email protected]>
This change uses python instead of bash system language to get around
the `python: command not found` error when using vs code source control
gui.

Signed-off-by: Frankie Siino <[email protected]>
Add Attributions for Third Party Softwares.

---------

Signed-off-by: banghuaz <[email protected]>
## Description
Add Tutorial 00 - Key Terminology, providing a comprehensive glossary of
essential terms for NeMo Gym and RL workflows.

## Content
- **Rollout & Data Collection Terms**: rollout, task, trace,
demonstration data, preference pairs
- **Architecture Terms**: policy model, orchestration, verifier, service
discovery, reward
- **Training Approaches**: SFT, DPO, RL, online vs offline
- **Interaction Patterns**: multi-turn, multi-step, tool use
- **Technical Infrastructure**: Responses API, Chat Completions API,
vLLM

Related to #119

Signed-off-by: Chris Wing <[email protected]>
## Description
Add tutorial index/README that provides a roadmap for the NeMo Gym
tutorial series.

This establishes the structure for upcoming tutorial documentation,
organized into:
- Getting Started
- Training
- Resource Servers
- Advanced Operations

## Notes
- This PR includes links to tutorials that will be added in follow-up
PRs. The structure is intentionally created first to provide a clear
roadmap for reviewers and users.
- Did not include previously considered sections for models and agents
since we aren't planning those tutorials for 0.1.0 release.

Related to #119

Signed-off-by: Chris Wing <[email protected]>
## Description
Add Tutorial 01 - Understanding Core Concepts, which explains the three
fundamental abstractions in NeMo Gym: Models, Resources, and Agents.

## Content

### Core Abstractions
- **Models**: LLM inference layer (OpenAI, vLLM)
- **Resources**: Tools and verification systems (weather, search, math
solvers, etc.)
- **Agents**: Orchestration layer that connects models to resources

### Learning Features
- Architecture diagram showing component relationships
- Concrete examples for each abstraction with real resource servers
- YAML configuration pattern example
- Step-by-step walkthrough of a weather request flow
- Key benefits: reusable, testable, scalable, flexible architecture

### User Journey
This tutorial builds on the terminology from Tutorial 00 and prepares
users for hands-on setup in Tutorial 02.

Related to #119

---------

Signed-off-by: Chris Wing <[email protected]>
## Description
Add Tutorial 09 - Configuration Management, providing a comprehensive
guide to NeMo Gym's flexible three-tier configuration system.

## Content

### Configuration System Overview
NeMo Gym uses three configuration sources with clear priority hierarchy:
1. **Server YAML configs** (base configurations, lowest priority)
2. **env.yaml** (secrets and environment-specific values)
3. **Command line arguments** (runtime overrides, highest priority)

### Key Topics Covered
- **Server Configuration Files**: Structure, hierarchy, and multi-server
setups
- **Environment Configuration**: Secrets management with `env.yaml` and
best practices
- **Command Line Overrides**: Runtime customization using Hydra syntax
- **Policy Model Variables**: Standard placeholders for model
configuration
- **Configuration Resolution**: Step-by-step process of how configs are
merged
- **Practical Scenarios**: Dev/prod environments, multi-resource
testing, custom ports
- **Troubleshooting**: Common issues and validation error messages
- **Best Practices**: Keeping secrets secure, organizing configs,
documentation

### Learning Outcomes
After reading this tutorial, users will understand:
- How to separate secrets from version-controlled configs
- When to use each configuration source
- How to override settings for different environments
- How to swap components without code changes
- How to debug configuration issues

Related to #119

---------

Signed-off-by: Chris Wing <[email protected]>
## Summary
Adds a comprehensive Code of Conduct to establish clear community
standards and behavioral expectations for all contributors and
participants.

## Changes
- Add `CODE_OF_CONDUCT.md` following Contributor Covenant 2.1 standards
- Includes community pledge, behavioral standards, and enforcement
guidelines
- Provides clear reporting procedures and enforcement framework
- Creates structured approach to handling community issues

## Benefits
- **Establishes clear expectations** for respectful community
participation
- **Creates welcoming environment** for contributors of all backgrounds
- **Provides enforcement framework** for handling inappropriate behavior
- **Demonstrates commitment** to inclusive open source practices
- **GitHub integration** - automatically detected and highlighted in
repository

## Implementation Details
- Based on widely-adopted Contributor Covenant 2.1
- Includes progressive enforcement guidelines (correction → warning →
temporary ban → permanent ban)
- Uses GitHub's built-in reporting functionality
- Covers all community spaces and official representation

Closes #147

Signed-off-by: Chris Wing <[email protected]>
## Summary
Adds a comprehensive security policy following NVIDIA's established
security practices and procedures.

## Changes
- Add `SECURITY.md` based on NVIDIA NeMo Curator template
- Includes NVIDIA PSIRT contact information and reporting procedures
- Provides guidelines for responsible vulnerability disclosure
- Maintains consistency with other NVIDIA NeMo projects

## Benefits
- Establishes clear security reporting procedures
- Provides trusted NVIDIA security contacts ([email protected])
- Enables responsible vulnerability disclosure
- GitHub will automatically detect and highlight security policy

Closes #146

Signed-off-by: Chris Wing <[email protected]>
This is a proposed change to the train metrics module to prevent false
metrics conflicts by tolerating slight differences in rounding.
This also allows additional fields to be added to the new example
metrics.

---------

Signed-off-by: Frankie Siino <[email protected]>
bxyu-nvidia and others added 14 commits February 20, 2026 15:14
issue described in #736

collate_samples writes metrics without the dataset config metadata eg
name type jsonl_fpath while validate_samples_and_aggregate_emtrics wrote
those with metadata , causing a conflict. this mirrors what the validate
step does to merge the metadata before the conflict check

Signed-off-by: cmunley1 <[email protected]>
# Contributing To NeMo-Gym (NewtonBench Resource Server)

## 1) Basic information

### i. Description of the environment
A resource server wrapping the
[NewtonBench](https://github.com/HKUST-KnowComp/NewtonBench) benchmark
- **Tasks:** 324 scientific law discovery tasks across 12 physics
domains.
- **Observation Space:** Experimental results (numeric or structured
dictionaries) returned after tool use.
- **Tools:**
- `run_experiment`: Query the environment with specific parameters to
receive physical observations.
- `execute_python`: (Optional) Python code-assisted discovery for
complex data analysis.
- **Server:** FastAPI resource server following NeMo Gym conventions.

### ii. Description of the verification logic
The verifier uses the NewtonBench evaluation suite to score the agent's
proposed scientific law:
- **Law Extraction:** Attempts to find a law within `<final_law>` tags
in the assistant's final response.
- **Success Criteria:** Evaluates both **symbolic equivalence** (via an
LLM judge) and **numeric accuracy** (Root Mean Square Logarithmic Error
- RMSLE).
- **Reward Calculation:**
  - `reward = 0.3 * R_symbolic + 0.7 * R_numeric`.
    - $R_{symbolic}$ is 1.0 if equivalent, -1.0 otherwise.
- $R_{numeric} = 1.0 - (2.0 * \text{RMSLE} / (\text{RMSLE} + 3.0))$,
yielding a score in $(-1, 1]$.
- `/verify` endpoint processes the agent's submission and returns these
detailed performance metrics.

### iii. Description of the prompts/tasks (source + domain)
**Domain:** Maths (Scientific Law Discovery).  
**Source:** Tasks and prompts adapted from the
[NewtonBench](https://github.com/HKUST-KnowComp/NewtonBench) benchmark,
which instruct the agent to discover a specific shifted scientific law
(e.g., Newton's Law of Gravitation, Snell's Law) by performing
interactive experiments.

### iv. License information
- **Code:** Apache 2.0.
- **Data:** Apache 2.0
- **NewtonBench Benchmark:** MIT (Copyright (c) 2025 HKUST-KnowComp).

## 2) Environment validity check

### i. Commands used to collect rollouts
```bash
# Start NeMo Gym servers (agent + NewtonBench)
config_paths="resources_servers/newton_bench/configs/newton_bench.yaml,\
responses_api_models/vllm_model/configs/vllm_model.yaml"
ng_run "+config_paths=[$config_paths]"

# Collect sample rollouts
ng_collect_rollouts \
    +agent_name=newton_bench_simple_agent \
    +input_jsonl_fpath=resources_servers/newton_bench/data/example.jsonl \
    +output_jsonl_fpath=resources_servers/newton_bench/data/example_rollouts.jsonl \
    +limit=5

# View rollouts
ng_viewer +jsonl_fpath=resources_servers/newton_bench/data/example_rollouts.jsonl
```

### ii. Resulting rollouts (5 examples)
See `resources_servers/newton_bench/data/example_rollouts.jsonl`  
**Expected behavior:**
- Agent performs several experiments, analyzes data, and submits a
scientific law.
- Successful discovery $\rightarrow$ positive reward ($\approx$ 1.0).
- Failed discovery $\rightarrow$ reward $\approx$ 0.0 or negative.

## 3) Tests

### i. Commands used to run the tests
```bash
source resources_servers/newton_bench/.venv/bin/activate 
pytest resources_servers/newton_bench/tests/test_app.py
```

**Coverage notes:**
Resource server tests provide comprehensive coverage of the following
areas:
- **Session Lifecycle:** Successful seeding, error handling for invalid
modules, session ending, and background cleanup.
- **Experiment Execution:** Dynamic handler registration for each
modules, basic run experiment execution, and error handling for
uninitialized sessions, mismatched module calls, etc.
- **Python Sandbox:** Basic execution, session-based code persistence,
timeout enforcement, and security validation (restricting dangerous
imports/operations).
- **Verification Logic:** Law extraction from diverse response
structures, and reward calculation via symbolic equivalence (LLM judge)
and numeric RMSLE.

## 4) Reward profiling

**Models:** Qwen/Qwen3-VL-8B-Thinking

**Method:**
- 108 prompts based on version v0 of scientific laws.
- 4 rollouts per prompt (432 total).
- Tool calling of `run_experiment` enabled and agent loops until law
submission.

**Results:**
**Overall Metrics**
- **Total Rollouts:** 432
- **Mean Reward:** $\approx$ 0.0675
- **Median Reward:** 0.0
- **Min Reward:** $\approx$ -0.8786
- **Max Reward:** 1.0

**Tool Call Statistics**
- **Average Tool Calls:** 22.95 per rollout
- **Min Tool Calls:** 0
- **Max Tool Calls:** 1770
- **Correlation (tool calls $\leftrightarrow$ reward):** $\approx$
-0.0211 (Weak negative correlation)

**Reward Distribution (Buckets)**
| Reward Range | Count |
|:---|:---|
| [-1.0, -0.8) | 16 |
| [-0.8, -0.6) | 16 |
| [-0.6, -0.4) | 60 |
| [-0.4, -0.2) | 39 |
| [-0.2, 0.0) | 24 |
| [0.0, 0.2) | 150 |
| [0.2, 0.4) | 46 |
| [0.4, 0.6) | 2 |
| [0.6, 0.8) | 1 |
| [0.8, 1.0] | 78 |

**Performance by Tool Call Count Bins**
| Tool Call Range | Rollouts (n) | Mean Reward |
|:---:|:---:|:---:|
| 0 | 23 | $\approx$ -0.1112 |
| 1–10 | 329 | $\approx$ 0.0824 |
| 11–50 | 60 | $\approx$ 0.1308 |
| 51–200 | 15 | $\approx$ -0.1959 |
| 201–2000 | 5 | $\approx$ -0.0600 |

**Key observations**:  
- **Symbolic Accuracy:** Approximately 19.7% symbolic accuracy and a
widespread RMSLE distribution indicate frequent failures to recover
exact symbolic forms or precise numeric behavior.
- **Reward Distribution:** Rewards cluster near zero (median 0.0, mean
~0.0675) with a long tail and many negative outcomes, reflecting
frequent partial or failed discoveries.
- **Tool Usage Sweet Spot:** Positive performance is observed with
moderate tool use (1–50 calls), with a peak in the 11–50 range,
suggesting that tool-driven data collection is critical for inducing
scientific laws.
- **Diminishing Returns:** Performance declines sharply after 50 calls,
showing additional tool calls become detrimental and successful
discovery depends on reasoning and hypothesis selection rather than raw
data volume.

---------

Signed-off-by: Kelvin0110 <[email protected]>
Signed-off-by: cmunley1 <[email protected]>
Co-authored-by: Christian Munley <[email protected]>
@ahmadki
ahmadki marked this pull request as ready for review February 28, 2026 06:44
@ahmadki
ahmadki requested a review from a team as a code owner February 28, 2026 06:44

## How It Works

The adapter bridges OpenEnv's `reset()`/`step()` API to NeMo-Gym's HTTP endpoint model:

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.

aviary already does this too... feels like duplicated work... for future feels like we should make a generic openai-gym style env

Comment thread uv.lock Resolved
@vadam5

vadam5 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Sorry folks, this PR was mistakenly closed when one of our folks mistakenly force-pushed diverging refs to Github. We are looking to remedy this and re-open the PR.

@vadam5

vadam5 commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Replacement PR opened here: #876

bxyu-nvidia pushed a commit that referenced this pull request Mar 16, 2026
Replacement PR for: #719

---------

Signed-off-by: Ahmad Kiswani <[email protected]>
mahanfathi pushed a commit that referenced this pull request Mar 24, 2026
Replacement PR for: #719

---------

Signed-off-by: Ahmad Kiswani <[email protected]>
jsw-zorro pushed a commit to niletron/Gym that referenced this pull request Apr 7, 2026
Replacement PR for: NVIDIA-NeMo#719

---------

Signed-off-by: Ahmad Kiswani <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.