Repository navigation
feat(orchestration): run exports after each benchmark of gym eval submit - #4974
Conversation
|
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. |
087b5a0 to
ce9e5df
Compare
|
/ok to test ce9e5df |
a14be2f to
bfef0de
Compare
bfef0de to
bb934a5
Compare
bb934a5 to
1afa68f
Compare
|
/review |
1afa68f to
a91df25
Compare
|
/review |
|
/ok to test 14a633b |
|
|
||
| @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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…f the driver Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…run again 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]>
…not see 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]>
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]>
… step Signed-off-by: Tomasz Grzegorzek <[email protected]>
|
/ok to test d034070 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/41672239161 |
Summary
gym eval submitruns exports on each benchmark's finished rollouts.job.exportis the default for every benchmark; a benchmark'sexportoverride it setting by setting (nestedmetamerges), andnulldrops an inherited export. Acommandbenchmark takes none of the defaults. Slurm only.gym eval run. The eval runs as a child, withTERMforwarded 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.exitand is the job's exit code; a failing export never changes it. Benchmarks without exports render the same script as before.python3 -m nemo_gym.orchestration.export_step <exporter> +key=value ..., which runs the same exporter asgym eval exportand keeps its outcome inresult_json_fpath(a setting of the step, not of the exporters;gym eval exportis unchanged):{"state": "running"}while in progress, thenstate,exit_code,erroranddetail(also for a settings error).succeededorskippedresults are not repeated; failed, interrupted or unreadable ones are retried. Submit uses<benchmark dir>/exports/<exporter>.result.json: no file means never attempted,runningmeans interrupted.rollouts_jsonl_fpathandresult_json_fpath(the config may not), and names runs unless the config does:mlflow_run_nameandwandb_nameas<benchmark>-<gym job id>, andatifsession_idand output folder.agent_versionforatifstays the user's.wandb_api_keyand useWANDB_API_KEYfrom the environment),exporton acommandbenchmark or Kubernetes compute, and an export duplicating a live exporter enabled inrun.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
With this config
gpqaruns themlflowandatifexports andaime24runs none. The tail rendered forgpqa(shortened):Credentials are not export settings:
resolved-config.yamland--resolve-onlyoutput are shared, and submit resolves${oc.env:...}references before writing them. Provide them through the environment instead, withdriver.envandhost:VAR(a reference in the record, the value only in the owner-only job script), for exampledriver.env: {WANDB_API_KEY: "host:WANDB_API_KEY"}withexport.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 exportpluggable so a finished run can go to tracking systems without live exporters, andgym eval submitcan export after each benchmark.gym eval run(feat(eval): save the masked config beside rollouts from gym eval run #4908)RunArtifactsand path derivation helpers (feat(eval): add RunArtifacts to derive a run's files from its rollouts path #4909)Exporterbase class and registry, starting withatif, plus the positional exporter CLI argument (--formatdeprecated) (feat(eval): add the Exporter base class and registry, with atif as the first exporter #4911)mlflowandwandbexport: 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)gym eval submitintegration: anexportmap with job-level defaults and per-benchmark overrides, validation, install extras, and a job-script tail (Slurm only at first)Validation
bashwith a fakepython3: success, failed run (not exported, exit code kept), failing export (exit code unchanged, others still run), quoting, andTERMreaching 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.gym eval submit --dry-runwith a config like the example rendered the expected tails.Follow-ups
nemo_gym.orchestration.export_stepis what such a job would run, and the exporters themselves would not change.Known gaps
runsettings. A live exporter switched on by aconfig_pathsfile, anenv.yamlor thegym_installcheckout is not detected before submit; the run is then logged twice, andgym eval exportwarns and names the live run. Documented in the orchestration configuration page.gym eval resubmitor a rerun in place, delete an export's result file (and<stem>_<exporter>_export_donefor mlflow and wandb) to export again.Rollout evidence
N/A: no agent, verifier or model behavior is touched. A benchmark without
exportrenders the same script as before.