Repository navigation
feat(orchestration): composability in gym eval submit - #3142
Merged
Merged
Conversation
Signed-off-by: Tomasz Grzegorzek <[email protected]>
9 tasks done
marta-sd
reviewed
Sep 8, 2026
Signed-off-by: Tomasz Grzegorzek <[email protected]>
marta-sd
approved these changes
Sep 8, 2026
jkyi-nvidia
pushed a commit
that referenced
this pull request
Sep 11, 2026
### What changed `gym eval submit` previously loaded its `--config` YAML with a plain `OmegaConf.load()` + dotlist merge — no real Hydra composition, and overrides silently accepted `+key=value` for keys that already existed. This MR rewires `_eval_submit` (`nemo_gym/cli/main.py`) to compose the config through real Hydra (`hydra.compose` + `initialize_config_dir`, pointed at the `--config` file's own directory), so: - A `--config` file can now use a Hydra `defaults:` list to pull in config groups from subdirectories (e.g. `compute: slurm`, `services: vllm`) instead of being a single flat file. - CLI overrides follow real Hydra semantics: bare `key=value` overrides an existing key, `+key=value` only adds a new key (errors if the key already exists), `++key=value` does either — replacing the old lenient dotlist behavior. - Config groups themselves can be swapped from the CLI, e.g. `compute=slurm_large`. ### Root-level scratch namespace support Since `SubmitConfig` is a strict pydantic model (`extra="forbid"`), any root-level key outside its schema would fail validation — but such a key can be useful purely as an interpolation source shared across independently-composed group files (e.g. pinning an image tag once, referenced by both `services/*.yaml` and `driver/*.yaml`). `_eval_submit` now resolves all interpolations first, then strips any root-level key that isn't one of `SubmitConfig`'s declared fields before validating, so scratch namespaces work without needing to satisfy the schema themselves. ### Tests Added `tests/unit_tests/test_cli_eval_submit.py` (11 cases) covering: - Flat-config backward compatibility - Override semantics (bare / `+` / rejection of `+` on existing keys) - Config-group composition and swapping - Repeated in-process calls (`GlobalHydra` reset) - Scratch-namespace resolve-then-strip behavior ### Docs / example Added `examples/slurm_vllm_composed/`, a fully worked example mirroring `slurm_vllm_1IN.yaml` but split across Hydra config groups (`compute/`, `services/`, `driver/`, `job/`), including: - A `compute/slurm_large.yaml` alternate profile - A root-level `image_tags` scratch namespace consumed by both `services/vllm.yaml` and `driver/ifbench.yaml`, demonstrating shared version pinning across independently-composed files ###⚠️ Behavior change for reviewers Override syntax is now strict Hydra (`+` only for new keys) rather than the old lenient dotlist merge. Any existing scripts/docs relying on `+key=value` against pre-existing keys need updating to drop the `+`. --------- Signed-off-by: Tomasz Grzegorzek <[email protected]> Signed-off-by: Junkeun Yi <[email protected]>
5 tasks done
jeffwillette
pushed a commit
to jeffwillette/Gym
that referenced
this pull request
Sep 17, 2026
…id --config (NVIDIA-NeMo#3445) ## What does this PR do? Fixes NVIDIA-NeMo#2688 (`[VDR][v0.6.0] CLI-8c0bb15d`). `gym eval submit --config X` was the only `--config` consumer that let user mistakes escape as Python tracebacks: - a path that does not exist (or is a directory) died inside Hydra `compose` with a ~60-line `MissingConfigException` traceback whose search-path dump never names the offending path; - a file that exists but has the wrong shape leaked a raw `pydantic_core.ValidationError` traceback, because `_handle_pydantic_validation_error` only recognises `BaseNeMoGymCLIConfig` subclasses and `SubmitConfig` is an orchestration model. > Note: the issue quotes `OmegaConf.load` at `main.py:443` raising `FileNotFoundError`. Since NVIDIA-NeMo#3142 the loader is Hydra `compose`, so the exception type and line moved (`MissingConfigException`, ~`main.py:600`), but the symptom is identical and reproduces on current `main`. ### Changes - **`_eval_submit` is wrapped in `exit_cleanly_on_config_error`** (the decorator every other `gym env`/`gym eval` command already uses) and **checks `Path(args.config).is_file()` before Hydra sees the path**, raising a `ConfigError` that names it. - **`SubmitConfig` validation errors are rendered as a `ConfigError` naming the file**, with the same `missing required configuration: ...` / `invalid configuration: path (reason)` wording as the generic handler. The field formatting is extracted from `_handle_pydantic_validation_error` into a shared `_describe_validation_errors` (pure move, no behaviour change) so the two paths cannot drift. I went with rendering the error inside `_eval_submit` rather than the issue's alternative of making `SubmitConfig` a `BaseNeMoGymCLIConfig`: that base class carries a `sys.argv`-sniffing `--help` validator that does not belong on an orchestration model, and the generic handler's `+key=<value>` hint would be misleading when the fields live in a YAML file. ### Before / after Same inputs, `--dry-run`, on `main` (787ac2b) vs this branch. Exit code is 1 in every error case both before and after; only the output changes. **1. `--config` points at a file that does not exist** (the issue's first case) ``` $ gym eval submit -c missing.yaml --dry-run ``` Before — 80 lines: ``` Traceback (most recent call last): File ".../bin/gym", line 10, in <module> sys.exit(main()) ... hydra.errors.MissingConfigException: Cannot find primary config 'missing'. Check that it's in your config search path. Config search path: provider=hydra, path=pkg://hydra.conf provider=main, path=file:///abs/path provider=schema, path=structured:// ``` After — 1 line: ``` Error: Submit config '/abs/path/missing.yaml' was not found. Check the path is spelled correctly and is relative to your working directory. ``` (A directory passed as `--config` gets the same treatment: `... is a directory, not a file.`) **2. `--config` exists but is not a submit config** (the issue's second case) ``` $ printf 'foo: 1\nbar: hello\n' > wrong_shape.yaml $ gym eval submit -c wrong_shape.yaml --dry-run ``` Before — 41 lines: ``` Traceback (most recent call last): File ".../bin/gym", line 10, in <module> sys.exit(main()) ... pydantic_core._pydantic_core.ValidationError: 6 validation errors for SubmitConfig services Field required [type=missing, input_value={'foo': 1, 'bar': 'hello'}, input_type=dict] For further information visit https://errors.pydantic.dev/2.13/v/missing ... bar Extra inputs are not permitted [type=extra_forbidden, input_value='hello', input_type=str] For further information visit https://errors.pydantic.dev/2.13/v/extra_forbidden ``` After — 1 line: ``` Error: Submit config '/abs/path/wrong_shape.yaml' is invalid: missing required configuration: services, compute, driver, job. invalid configuration: foo (Extra inputs are not permitted); bar (Extra inputs are not permitted). ``` Errors deeper in the schema keep their location, e.g. `invalid configuration: job.output_path (Input should be a valid string)`, and `SubmitConfig`'s own cross-field `@model_validator` failures render the same way (`<config> (Value error, driver.policy_model 'nope' does not match any service (svc).)`) instead of a traceback that echoes the whole config. A valid config produces byte-identical `--dry-run` output before and after. ### Testing - `tests/unit_tests/test_cli_eval_submit.py`: new `TestEvalSubmitConfigFileErrors` (missing file, directory, wrong shape, nested dotted path, cross-field `@model_validator`) plus two `main()`-level tests asserting exit 1, the `Error:` line, and no traceback. `test_typo_in_top_level_key_is_rejected` now asserts the `ConfigError` (and names the rejected key) instead of the raw `ValidationError` that was the bug. - All 8 new/changed tests fail on `main` without the source change and pass with it. - `pytest tests/unit_tests/ -m "not sandbox"`: 4138 passed. - `pre-commit run` on the changed files: clean. - Manual CLI check of both error paths and the happy path (`--dry-run` against a valid config) as above. ### Out of scope / follow-up While reproducing I found that `compose()` bypasses the compact error rendering that `@hydra.main`'s `run_and_report` gives every other command, so `eval submit` also tracebacks on a `.yml` extension, malformed YAML, a missing `defaults:` group file, a non-mapping file, a bad override, and an unresolvable interpolation. Those are one root cause and deserve their own issue rather than widening this PR; I can open it with reproductions if that is useful. ## Checklist - [x] I have read the [contributing guidelines](https://docs.nvidia.com/nemo/gym/latest/contribute/development-setup). - [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). - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format/copyright pass). - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). --------- Signed-off-by: Tsvetan (Sven) Rankov <[email protected]> Signed-off-by: yaoyu-33 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: yaoyu-33 <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
gym eval submitpreviously loaded its--configYAML with a plainOmegaConf.load()+ dotlist merge — no real Hydra composition, and overrides silently accepted+key=valuefor keys that already existed.This MR rewires
_eval_submit(nemo_gym/cli/main.py) to compose the config through real Hydra (hydra.compose+initialize_config_dir, pointed at the--configfile's own directory), so:--configfile can now use a Hydradefaults:list to pull in config groups from subdirectories (e.g.compute: slurm,services: vllm) instead of being a single flat file.key=valueoverrides an existing key,+key=valueonly adds a new key (errors if the key already exists),++key=valuedoes either — replacing the old lenient dotlist behavior.compute=slurm_large.Root-level scratch namespace support
Since
SubmitConfigis a strict pydantic model (extra="forbid"), any root-level key outside its schema would fail validation — but such a key can be useful purely as an interpolation source shared across independently-composed group files (e.g. pinning an image tag once, referenced by bothservices/*.yamlanddriver/*.yaml)._eval_submitnow resolves all interpolations first, then strips any root-level key that isn't one ofSubmitConfig's declared fields before validating, so scratch namespaces work without needing to satisfy the schema themselves.Tests
Added
tests/unit_tests/test_cli_eval_submit.py(11 cases) covering:+/ rejection of+on existing keys)GlobalHydrareset)Docs / example
Added
examples/slurm_vllm_composed/, a fully worked example mirroringslurm_vllm_1IN.yamlbut split across Hydra config groups (compute/,services/,driver/,job/), including:compute/slurm_large.yamlalternate profileimage_tagsscratch namespace consumed by bothservices/vllm.yamlanddriver/ifbench.yaml, demonstrating shared version pinning across independently-composed filesOverride syntax is now strict Hydra (
+only for new keys) rather than the old lenient dotlist merge. Any existing scripts/docs relying on+key=valueagainst pre-existing keys need updating to drop the+.