Skip to content

feat(orchestration): run exports after each benchmark of gym eval submit - #4974

Merged
prokotg merged 20 commits into
mainfrom
prokotg/eval-export-submit
Nov 3, 2026
Merged

prokotg merged 20 commits into
mainfrom
prokotg/eval-export-submit

Conversation

@prokotg

@prokotg prokotg commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • gym eval submit runs exports on each benchmark's finished rollouts. job.export is the default for every benchmark; a benchmark's export override it setting by setting (nested meta merges), and null drops an inherited export. A command benchmark takes none of the defaults. Slurm only.
  • Exports are the tail of the driver step, in the container that runs gym eval run. The eval runs as a child, with TERM forwarded to it, and exports run only after it exits 0, so a failed or partial run is never exported. Its exit code goes to <benchmark dir>/eval.exit and is the job's exit code; a failing export never changes it. Benchmarks without exports render the same script as before.
  • Each export runs as a small step, python3 -m nemo_gym.orchestration.export_step <exporter> +key=value ..., which runs the same exporter as gym eval export and keeps its outcome in result_json_fpath (a setting of the step, not of the exporters; gym eval export is unchanged): {"state": "running"} while in progress, then state, exit_code, error and detail (also for a settings error). succeeded or skipped results are not repeated; failed, interrupted or unreadable ones are retried. Submit uses <benchmark dir>/exports/<exporter>.result.json: no file means never attempted, running means interrupted.
  • Submit sets rollouts_jsonl_fpath and result_json_fpath (the config may not), and names runs unless the config does: mlflow_run_name and wandb_name as <benchmark>-<gym job id>, and atif session_id and output folder. agent_version for atif stays the user's.
  • Submit validates exports before sending anything: unknown exporter or setting, settings an exporter would not accept (each exporter's own model is checked; a W&B export may leave out wandb_api_key and use WANDB_API_KEY from the environment), export on a command benchmark or Kubernetes compute, and an export duplicating a live exporter enabled in run.
  • The Gym install gets extras only for in-process exporters (mlflow, wandb); mlflow and wandb get SDK-free settings models (MLflowExportConfig, WandbExportConfig) so submit can validate without the SDKs. Docs: an "export" section in the orchestration configuration page, the Slurm driver steps, and the export step in the Slurm driver steps.

Part of #2977 (export-aware evaluation runs).

Example

job:
  output_path: /lustre/me/gym-jobs
  export:                           # default for every benchmark
    mlflow:
      mlflow_tracking_uri: https://mlflow.example.com
      mlflow_experiment_name: gym
      mlflow_run_tags: {suite: nightly}
driver:
  gym_install: {ref: main}
  env:
    MLFLOW_TRACKING_TOKEN: host:MLFLOW_TRACKING_TOKEN   # read from the submitting shell, kept out of the config
  benchmarks:
    gpqa:
      run: {config_paths: [benchmarks/gpqa/config.yaml]}
      export:
        mlflow: {mlflow_experiment_name: gym-gpqa}      # overrides the experiment, keeps the URI and the tags
        atif:
          agent_version: 1.0.0
    aime24:
      run: {config_paths: [benchmarks/aime24/config.yaml]}
      export:
        mlflow: null                                    # no MLflow export for this benchmark

With this config gpqa runs the mlflow and atif exports and aime24 runs none. The tail rendered for gpqa (shortened):

"$@" &                                         # gym eval run
...
echo "$gym_run_rc" > <benchmark dir>/eval.exit
if [ "$gym_run_rc" -eq 0 ]; then
    python3 -m nemo_gym.orchestration.export_step mlflow +mlflow_tracking_uri=... +mlflow_experiment_name=gym-gpqa \
        +rollouts_jsonl_fpath=<benchmark dir>/artifacts/rollouts.jsonl \
        +result_json_fpath=<benchmark dir>/exports/mlflow.result.json ... || true
    python3 -m nemo_gym.orchestration.export_step atif +agent_version=1.0.0 ... || true
fi
exit "$gym_run_rc"

Credentials are not export settings: resolved-config.yaml and --resolve-only output are shared, and submit resolves ${oc.env:...} references before writing them. Provide them through the environment instead, with driver.env and host:VAR (a reference in the record, the value only in the owner-only job script), for example driver.env: {WANDB_API_KEY: "host:WANDB_API_KEY"} with export.wandb: {wandb_project: p}. The exporters read the key from the environment.

PR plan

Separate PRs; steps 1-8 are stacked (stack #4910). Goal: make gym eval export pluggable so a finished run can go to tracking systems without live exporters, and gym eval submit can export after each benchmark.

  1. save the masked, unresolved config from gym eval run (feat(eval): save the masked config beside rollouts from gym eval run #4908)
  2. RunArtifacts and path derivation helpers (feat(eval): add RunArtifacts to derive a run's files from its rollouts path #4909)
  3. Exporter base class and registry, starting with atif, plus the positional exporter CLI argument (--format deprecated) (feat(eval): add the Exporter base class and registry, with atif as the first exporter #4911)
  4. post-run mlflow and wandb export: shared metrics flattening, BaseExporter.export() and the already-exported guard (feat(eval): export a finished run to MLflow or W&B with gym eval export #4914)
  5. isolated-venv subprocess runner for directory exporters (feat(eval): add IsolatedExporter to run an exporter's backend work in its own venv #4915)
  6. a second isolated-venv exporter (feat(eval): export a finished run to EvalRDL with gym eval export evalrdl #4965)
  7. This PR: gym eval submit integration: an export map with job-level defaults and per-benchmark overrides, validation, install extras, and a job-script tail (Slurm only at first)
  8. contributor guide: add an exporter (user-facing docs land in each step's PR) (docs(contribute): add a guide to writing an exporter for gym eval export #5077)

Validation

  • New tests cover the merge rules, derived settings, extras, every validation error, the rendered script with and without exports, and the result-file protocol. The tail runs in real bash with a fake python3: success, failed run (not exported, exit code kept), failing export (exit code unchanged, others still run), quoting, and TERM reaching the run. The rendered entrypoint also passes awkward values (spaces, apostrophes, numeric-looking strings, ${oc.env:...}) to the export step so that Hydra reads them back as the same values, and the step was run for real, end to end, on an ATIF export. pre-commit: passed.
  • A real gym eval submit --dry-run with a config like the example rendered the expected tails.

Follow-ups

  • Exports run as the tail of the benchmark's own job. Running them as their own job on a CPU partition, so that no GPUs are held during uploads, an export failure is separate from an evaluation failure and the export gets its own walltime, is tracked in Run gym eval submit exports as their own job after the benchmark #5358. nemo_gym.orchestration.export_step is what such a job would run, and the exporters themselves would not change.

Known gaps

  • Not run on a real Slurm cluster; no status command shows the results yet; no Kubernetes support.
  • The check that rejects a live exporter plus the same export only sees the benchmark's run settings. A live exporter switched on by a config_paths file, an env.yaml or the gym_install checkout is not detected before submit; the run is then logged twice, and gym eval export warns and names the live run. Documented in the orchestration configuration page.
  • After gym eval resubmit or a rerun in place, delete an export's result file (and <stem>_<exporter>_export_done for mlflow and wandb) to export again.

Rollout evidence

N/A: no agent, verifier or model behavior is touched. A benchmark without export renders the same script as before.

@prokotg
prokotg added this pull request to stack #4910 October 23, 2026 11:51
@copy-pr-bot

copy-pr-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@prokotg

prokotg commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test ce9e5df

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

@prokotg
prokotg force-pushed the prokotg/eval-export-submit branch 2 times, most recently from a14be2f to bfef0de Compare October 27, 2026 07:18
@prokotg
prokotg force-pushed the prokotg/eval-export-submit branch from bfef0de to bb934a5 Compare October 27, 2026 07:31
@prokotg
prokotg force-pushed the prokotg/eval-export-submit branch from bb934a5 to 1afa68f Compare October 27, 2026 07:45
@prokotg

prokotg commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/review

@prokotg
prokotg force-pushed the prokotg/eval-export-submit branch from 1afa68f to a91df25 Compare October 27, 2026 07:58
@prokotg

prokotg commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

/review

@prokotg

prokotg commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 14a633b

Comment thread nemo_gym/artifacts/exporter_registry.py Resolved
Comment thread nemo_gym/config/config_types.py Outdated

@property
def is_available(self) -> bool:
# A post-run export can authenticate from WANDB_API_KEY in the environment, so the key is optional here.

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.

I think MLFlow can also read key and uri from env vars, it would be good to unify how they behave. But this is probably for a followup PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, and I'd keep it out of this PR. Opened #5499 for it. One wrinkle I wrote down there: with no URI the client quietly falls back to a local store, so making it optional needs a check against the job's env.

_FINAL_STATES = (ExportState.SUCCEEDED.value, ExportState.SKIPPED.value)


def _write_json_atomically(path: Path, payload: dict[str, Any]) -> None:

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.

something to watch out for: files created with this function will have 0600 permissions, conversely to 0644 a direct open on the target path would give you. if we want to have files shareable with others or exportable by others (e.g. RDL automatic intake), we need to change permissions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It really depends on umask of the environment, whether it's open or a different binary. We can force it to 0644 but then we're by-passing any cluster management philosophy :D

Comment thread nemo_gym/orchestration/export_step.py Resolved
Comment thread nemo_gym/orchestration/exports.py Resolved
job.exports and a benchmark's exports name the exporters to run on its finished rollouts, merged setting by
setting. Slurm jobs run them as the tail of the driver step, after a successful gym eval run, and keep each
outcome in exports/<exporter>.result.json. Submit validates the exports before sending anything.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…are and run

job.export and a benchmark's export match the gym eval prepare, run and export commands they configure.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…nvironment

Submit validated a W&B export with the live exporter's readiness check, which
requires wandb_api_key as a setting. A post-run export can authenticate from
WANDB_API_KEY in the environment, so the export's settings model now needs only
the project and run name when no key is given. An empty or masked key is still
rejected, and a live W&B exporter next to the same export is still refused.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…v, not export settings

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…t tail

The tail only shell-quoted each setting, and the shell quotes are gone by the
time Hydra parses the argument. A string such as agent_version "1" reached
gym eval export as the number 1 and was rejected, and a label such as
nightly(run) was a parse error. Each export setting is now written so that
Hydra's own parser reads it back as the same value and type, and quoted only
when it would not. Run and prepare arguments are unchanged. The string quoting
helper moves from the CLI module to cli/utils so orchestration does not reach
into a private CLI function.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…and fix two error paths

Writing the exports directory and eval.exit after the run is best effort now,
so a filesystem failure there can no longer replace the evaluation's exit code
or skip the exports. A shared-settings error in gym eval export, such as a
missing rollouts_jsonl_fpath, is written to the result file as a failed
result instead of leaving it as never attempted. An EvalRDL meta that is not a
mapping now reaches the settings model and gets its configuration error instead
of an AttributeError.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…valuation has succeeded

Exports run in the driver step after gym eval run, so the service watcher kept
supervising the model service while an export, possibly a long EvalRDL upload,
was still running. A service lost then killed the driver and the job returned 1
although the evaluation had succeeded, which made the auto-resume chain reload
the model for nothing. The export tail now creates a marker file for this
attempt (named after the Slurm job id) as soon as the run exits 0, and the
watcher leaves the driver to finish once it exists. A service lost while the
evaluation runs still ends the job.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…export

The result file that tells a job's exports apart (running, final state, skip a
finished export, retry an interrupted one) is job bookkeeping, so it now lives in
nemo_gym.orchestration.export_step, which the driver step runs for each export:
python3 -m nemo_gym.orchestration.export_step <exporter> <overrides>. gym eval
export is back to what it is on main, and result_json_fpath is a setting of the
step, not of every exporter.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…ark directory

A submitted run's rollouts sit in <bench>/artifacts, so without a label the SDK
named the upload after that directory. Label it <benchmark>-<job id> like the other
exporters, and add an EvalRDL run_dir setting that submit points at the benchmark
directory so driver logs and eval.exit are part of the run.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…heir exporters

The two settings models sat in config_types.py because the exporter modules import
their SDKs at the top, and submit has to validate settings without the SDKs. They now
live in SDK-free modules next to the exporters, so every ExportConfig is beside its
exporter. The registry points all four settings models at their current module paths
instead of the deprecated aliases.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
hydra_literal and the parse check behind it are general-purpose, not specific to
orchestration, so they move to utils/text.py with their own tests. flatten_export_args
stays in orchestration, where the setting-name rule it applies lives.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
…ready exported

A skipped result only means the export reached a final state in an earlier attempt, which an exporter can
reach for reasons other than the run having been exported. The previous state stays in the detail.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
The logs and artifacts directory names, rollouts.jsonl, the exports directory, eval.exit,
the per-attempt eval.succeeded marker and the result file suffix were string literals
repeated across the Slurm and Kubernetes executors, the job script and the exports. They
are constants in orchestration/jobs.py now, next to the manifest and resolved-config
names, and the export settings the orchestrator sets are named too. Rendered scripts
are unchanged.

Signed-off-by: Tomasz Grzegorzek <[email protected]>
@prokotg

prokotg commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test d034070

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41672239161

This branch was previously deployed

1 inactive deployment
public — d0340702 Deployed Nov 3, 2026 by copy-pr-bot[bot] via release / finalize / notify #9616
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:orchestration Job submission, deployment, services, and lifecycle management 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.

4 participants