Skip to content

feat(rollout): add multi-harness fan-out training - #4082

Draft
ehosseiniasl wants to merge 62 commits into
NVIDIA-NeMo:mainfrom
ehosseiniasl:ehosseiniasl/multi-harness-training-routing
Draft

ehosseiniasl wants to merge 62 commits into
NVIDIA-NeMo:mainfrom
ehosseiniasl:ehosseiniasl/multi-harness-training-routing

Conversation

@ehosseiniasl

@ehosseiniasl ehosseiniasl commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds FineEnvs-style multi-harness rollout support to NeMo Gym.

  • adds fan_out to run every matching task through every configured harness
  • retains agent_pool as a distinct choose-one-harness mode
  • adds a neutral AnyTerminal source route, anyterminal_multi_harness
  • supports the P0 harnesses OpenCode, OpenClaw, Pi, and Hermes
  • preserves deterministic routing across repeats, retries, resume, reordering, trainer batches, and distributed shards
  • validates empty/duplicate destinations, missing agents, and conflicting routing modes
  • adds local and Enroot profiles, portable runtime setup, documentation, and regression coverage

Routing semantics

Setting Behavior
agent_pool deterministically selects one destination harness for each source task
fan_out creates one copy of every matching source task for every listed harness

The generic profile intentionally does not hard-code either mode. The caller chooses fan_out for task × harness training or agent_pool for one-of-N routing.

P0 configuration

The source data uses:

task_source: anyterminal_multi_harness

Direct Gym rollout fan-out:

python -m nemo_gym.cli run   --config responses_api_agents/anyterminal_agent/configs/anyterminal_multi_harness.yaml   '+fan_out={anyterminal_multi_harness:[anyterminal_opencode,anyterminal_openclaw,anyterminal_pi,anyterminal_hermes]}'   --input data/anyterminal_multi_harness/train.jsonl   --output results/anyterminal_multi_harness.jsonl

For NeMo RL training, the companion PR supplies the same mapping at env.nemo_gym.fan_out. Four source tasks × four destinations produce 16 independent prompt groups.

Implementation

  1. nemo_gym/rollout_collection.py
    • models and validates fan_out
    • performs the task × harness expansion for direct Gym usage
    • keeps agent_pool selection and fan_out expansion separate
  2. nemo_gym/global_config.py
    • validates all routing destinations against configured agent servers
  3. nemo_gym/train_data_utils.py and nemo_gym/task_data.py
    • preserve stable routing identity through collation/materialization
  4. responses_api_agents/anyterminal_agent/
    • generic source plus OpenCode, OpenClaw, Pi, and Hermes targets
    • local and Enroot-ready profiles
  5. tests and docs
    • cross-product, ordering, repeats, resume, conflicts, missing targets, Enroot resolution, and P0 profile coverage

Validation

Automated coverage

Coverage includes:

  • fan_out emits one row per destination in configured order
  • per-agent and source-keyed repeats compose with fan-out
  • seeded and unseeded target settings do not leak
  • disjoint agent_pool and fan_out routes compose
  • one route cannot configure both modes
  • destination coverage fails early
  • generic local and Enroot profiles resolve all four P0 targets

Focused fan-out and profile coverage passes on the current head: 12 passed, 441 deselected. The changed-file pre-commit hooks also pass on 63bd86b11; GitHub CI is rerunning on that head.

Real P0 harness execution

Real Terminal-Bench 2.1 task containers completed through all four harnesses—OpenCode, OpenClaw, Pi, and Hermes—with non-empty output and:

  • mask_sample=false
  • failure_kind=null and failure_reason=null
  • agent_timed_out=false
  • container_timed_out=false
  • sandbox_failed=false

Async-GRPO regression run

The earlier one-harness-per-task run validates the surrounding Gym ↔ RL runtime path, token capture, policy update, TMPE logging, and W&B integration:

It is a regression result, not proof of the new cross-product. Current-head Slurm preflight 2158959 completed successfully: 4 Terminal-Bench source tasks expanded to 16 prompt groups in OpenCode/OpenClaw/Pi/Hermes order. The companion RL PR adds the full Nemotron Super 3.5 Omni task × four-harness recipe; training job 2158991 is submitted and pending scheduler capacity.

Review guide

  1. routing behavior: nemo_gym/rollout_collection.py
  2. config validation: nemo_gym/global_config.py
  3. stable data identity: nemo_gym/train_data_utils.py
  4. P0 harness profiles/runtime: responses_api_agents/anyterminal_agent/
  5. tests: tests/unit_tests/test_rollout_collection.py and test_anyterminal_multi_harness.py

Companion NeMo RL PR: NVIDIA-NeMo/RL#4521

@ehosseiniasl ehosseiniasl self-assigned this Oct 6, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: Ehsan Hosseini Asl <[email protected]>
Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
Signed-off-by: Ehsan Hosseini Asl <[email protected]>
Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
Signed-off-by: ehosseiniasl <[email protected]>
Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
Signed-off-by: ehosseiniasl <[email protected]>
Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
Signed-off-by: ehosseiniasl <[email protected]>
Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
@ehosseiniasl

ehosseiniasl commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Current P0 fan-out validation

This comment supersedes the earlier choose-one agent_pool smoke.

Current PR head: 63bd86b11.

The generic source is anyterminal_multi_harness. With fan_out, every Terminal-Bench task runs through all four P0 harnesses:

  • OpenCode
  • OpenClaw
  • Pi
  • Hermes

agent_pool remains supported as the separate choose-one mode. The generic profile hard-codes neither mode; the caller selects the intended routing behavior.

Validation completed:

  • focused fan-out and profile suite: 12 passed
  • local and Enroot profiles resolve the generic source plus all four destinations
  • direct Gym fan-out preserves configured target order and per-group harness affinity
  • Slurm preflight 2158959: COMPLETED (0:0)
  • verified 4 real Terminal-Bench source tasks → 16 prompt groups

Full Nemotron Super 3.5 Omni async-GRPO job 2158991 is submitted and pending 16-node scheduler capacity. W&B will use adlr/multi-harness-RL; the run URL and TMPE results will be added here after the allocation starts.

@yaoyu-33 yaoyu-33 added area:training Training framework integrations and training-data interfaces complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Oct 6, 2026
@ehosseiniasl
ehosseiniasl force-pushed the ehosseiniasl/multi-harness-training-routing branch from fe22f31 to cda0d86 Compare October 6, 2026 16:26
…rness-training-routing

Signed-off-by: Ehsan Hosseini-Asl <[email protected]>

# Conflicts:
#	nemo_gym/train_data_utils.py
@ehosseiniasl ehosseiniasl changed the title feat(rollout): add multi-harness training routing feat(rollout): add multi-harness fan-out training Oct 6, 2026
@ehosseiniasl
ehosseiniasl force-pushed the ehosseiniasl/multi-harness-training-routing branch from ecf59f4 to a1b3466 Compare October 6, 2026 23:02
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Oct 7, 2026
@ehosseiniasl
ehosseiniasl requested a review from a team as a code owner October 9, 2026 18:49
@ehosseiniasl
ehosseiniasl force-pushed the ehosseiniasl/multi-harness-training-routing branch from 97441d3 to c27e6c1 Compare October 12, 2026 16:56
# Conflicts:
#	nemo_gym/token_id_capture/fingerprint.py
#	responses_api_agents/openclaw_agent/setup_openclaw.py
#	responses_api_agents/opencode_agent/app.py
#	responses_api_agents/opencode_agent/tests/test_app.py
#	responses_api_agents/pi_agent/README.md
#	responses_api_agents/pi_agent/app.py
#	responses_api_agents/pi_agent/configs/pi_agent.yaml
#	responses_api_agents/pi_agent/tests/test_app.py

Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
# Conflicts:
#	responses_api_agents/openclaw_agent/app.py
#	responses_api_agents/openclaw_agent/configs/openclaw_agent.yaml
#	responses_api_agents/openclaw_agent/tests/test_app.py
#	responses_api_agents/opencode_agent/README.md
#	responses_api_agents/opencode_agent/app.py
#	tests/unit_tests/test_token_capture_ledger.py

Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
Signed-off-by: Ehsan Hosseini-Asl <[email protected]>
(cherry picked from commit 5511663cddfff144726bb85983882e6f65bd4d32)
khazic pushed a commit to khazic/Gym-lao that referenced this pull request Oct 13, 2026
## What does this PR do?

README only. Tells OpenClaw users to set `context_window` to the model
server's maximum context length, and explains how OpenClaw uses it and
`max_output_tokens`. Follow-up to NVIDIA-NeMo#4476, which lets sandbox sessions use
`max_output_tokens`; there is no issue.

Why: when `context_window` is unset, OpenClaw assumes 200,000 tokens. On
a server with a smaller limit, it keeps requesting its full output limit
and does not compact in time, so long episodes can send requests the
server rejects. Gym's `vllm_model` returns an empty reply, not an error,
by default, and the run ends early.

Example, worked out from the code and not measured in a run: released
vLLM (up to 0.31) rejects a call when prompt + requested output >
`max_model_len`. At 131,072 with no `context_window`, calls fail once
the prompt passes 122,880 tokens (131,072 − 8,192 default), or 98,304
with `max_output_tokens: 32768` (131,072 − 32,768). With
`context_window: 131072`, OpenClaw lowers each call's output to fit the
room left by its estimate of the input; the estimate can undercount code
or JSON. Unreleased vLLM main (vllm-project/vllm#57035) lowers the
output instead of rejecting, but still rejects a prompt longer than
`max_model_len`.

The sandbox section now also says that the request field is rejected but
the agent config field applies, and that a `max_output_tokens` above
`context_window` is rejected (the check from NVIDIA-NeMo#4476).

## Validation

- Read the OpenClaw npm package at 2026.6.11 (pinned in
`configs/openclaw_agent.yaml`) and at 2026.6.35 (the pin in NVIDIA-NeMo#4082). Both
match the README:
- `contextWindow` defaults to 200,000 and `maxTokens` to min(8,192,
`contextWindow`) (`dist/io-*.js`);
- each call requests at most min(`maxTokens`, `contextWindow` −
estimated input − 1), where the estimate is characters / 4 × 1.25. This
applies to any base URL other than OpenAI's or Azure OpenAI's, which
covers Gym's model server (`dist/openai-transport-stream-*.js`);
- two in-run limits are computed from `contextWindow`. One is the
context guard: once a run passes its limit, OpenClaw compacts and
retries (`installToolResultContextGuard` in `dist/selection-*.js`). The
other is the cap on each tool result's size
(`resolveLiveToolResultMaxChars` in `dist/tool-result-truncation-*.js`).
- Gym code on main: `_build_openclaw_config` writes `contextWindow` and
`maxTokens` only when they are set, and `vllm_model` returns an empty
`length` completion on a context-length error unless
`propagate_context_overflow_errors` is true.
- Open PRs touching OpenClaw: NVIDIA-NeMo#3902 and NVIDIA-NeMo#2733 edit this README, and
NVIDIA-NeMo#4082 moves the pin to 2026.6.35. `git merge-tree` shows this PR adds no
conflicts with any of them.
- `pre-commit run --all-files`: passed.

## Rollouts

N/A: README-only change, with no code or config changes.

## Compatibility and benchmark impact

None from this PR. Following the advice can change rollouts with long
episodes or long tool results, because `context_window` also sets when
OpenClaw compacts and how much of a tool result it keeps.

## Checklist

- [x] I have read the [contributing
guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md).
- [x] The change is focused; unrelated "drive-by" edits are tracked as
separate issues/PRs.
- [x] Tests added or updated and pass locally, or N/A for docs-only /
non-code changes (so CI unit/server checks pass when applicable). N/A:
docs-only.
- [x] Documentation added or updated, or N/A with justification.
- [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so
CI lint/format checks pass).
- [x] New source files include the required Apache-2.0 SPDX header. N/A:
no new files.
- [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check
passes).

Signed-off-by: Abhishree <[email protected]>
…rness-training-routing

Signed-off-by: Ehsan Hosseini-Asl <[email protected]>

# Conflicts:
#	responses_api_agents/openclaw_agent/scripts/openclaw_agent_deps.sh
@ehosseiniasl
ehosseiniasl force-pushed the ehosseiniasl/multi-harness-training-routing branch 2 times, most recently from 95cf80e to 7529292 Compare October 13, 2026 06:56
@yaoyu-33
yaoyu-33 marked this pull request as draft November 18, 2026 01:57
@yaoyu-33

Copy link
Copy Markdown
Contributor

We’re doing some cleanup of the open PR list. This PR has had no activity for over a month, so I’ve moved it back to draft.

If this change is still needed, please resolve any merge conflicts and mark the PR ready for review again when it’s ready to merge. Thanks!

@github-actions github-actions Bot removed the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:training Training framework integrations and training-data interfaces complexity:high Cross-component or shared-contract change with a large review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants