Skip to content

feat(eval): save the masked config beside rollouts from gym eval run - #4908

Merged
prokotg merged 7 commits into
mainfrom
prokotg/eval-run-resolved-config
Oct 28, 2026
Merged

prokotg merged 7 commits into
mainfrom
prokotg/eval-run-resolved-config

Conversation

@prokotg

@prokotg prokotg commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • gym eval run (end-to-end and --no-serve) writes <stem>_resolved_config.yaml beside the rollouts before collection: secrets masked (secret-shaped keys and every value under a header map), ${...} left unresolved, written atomically, overwritten per attempt.

  • New hide_secrets_in_container masks plain dict/list trees without resolving interpolations (recursively_hide_secrets raises on an unset ${oc.env:...}), plus resolved_config_path_for and write_resolved_config.

  • Both maskers (this one, and recursively_hide_secrets, which the exporters and config logging use) also mask the password in a scheme://user:password@host URL and keep the rest of the URL. That is only a precaution: secrets belong behind ${oc.env:NAME} or env.yaml, never literal in a config, and the docs say so. Query parameters, webhook URLs with the secret in the path and JDBC-style strings are not masked.

  • CLI reference: an "Output files" table for gym eval run, including the saved config.

No behavior change beyond the extra file. Part of #2977 (export-aware evaluation runs).

Overall goal

gym eval export is ATIF-only today. The goal is pluggable exporters that receive a finished run (the rollouts file and its sibling files) and decide what to read or upload, so runs reach MLflow, W&B or EvalRDL without live exporters and gym eval submit can export after each benchmark.

  • gym eval export <exporter> +rollouts_jsonl_fpath=... +key=value, with atif as the default.
  • RunArtifacts derives a run's files; the saved config records what the run was configured to do, which is why this PR comes first.
  • mlflow and wandb reuse the live exporters; atif and evalrdl read run files, and non-trivial ones run in an isolated venv.
  • <stem>_<exporter>_export_done prevents exporting a run twice. Settings and credentials come from the export command, never from the masked saved config.

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. This PR: save the masked, unresolved config from gym eval run
  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. EvalRDL exporter (feat(eval): export a finished run to EvalRDL with gym eval export evalrdl #4965)
  7. 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) (feat(orchestration): run exports after each benchmark of gym eval submit #4974)
  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

  • test_resolved_config.py and test_secret_utils.py: 30 passed (masking, header maps, URL passwords, unresolved interpolations, overwrite, --no-serve writes before collecting). pre-commit: passed.
  • test_cli_eval.py does not collect locally (devtools missing); same on main.

Rollout evidence

N/A: no agent, verifier or model behavior is touched. The --no-serve call site has a unit test; the end-to-end one is # pragma: no cover and no smoke gym eval run was run.

@copy-pr-bot

copy-pr-bot Bot commented Oct 22, 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 added this pull request to stack #4910 October 22, 2026 10:40
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters feature New capabilities, enhancements, or enablement work labels Oct 22, 2026
@prokotg
prokotg marked this pull request as ready for review October 22, 2026 11:12
@prokotg
prokotg requested a review from marta-sd October 22, 2026 11:13
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team October 22, 2026 11:13
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Oct 22, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

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.

HOLD — one BLOCKER in credential masking and one RISK in CLI coverage.

Completed static review of all five changed files and directly affected configuration, CLI dispatch, and collection paths. Tests were inspected but could not be executed in this read-only review.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/secret_utils.py Outdated
masked = {}
for key, value in data.items():
if isinstance(value, dict):
masked[key] = hide_secrets_in_container(value)

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.

BLOCKER — Custom authentication headers remain readable in the saved config

Failure / blast radius: hide_secrets_in_container({"openai_default_headers": {"X-Auth": "credential-canary"}}) returns the credential unchanged: the dictionary branch ignores the secret-shaped parent, and X-Auth does not match the key predicate. This is a supported credential path: the model config accepts arbitrary string headers, and passes them to its upstream client. The new sidecar writer therefore persists that live credential in an artifact described as safe to share. Expected: custom header values are masked too.

Correction: Handle the supported header credential map before ordinary structural recursion. A narrow replacement for this dictionary branch is:

if isinstance(value, dict):
    if key == "openai_default_headers":
        masked[key] = {name: MASKED_VALUE for name in value}
    else:
        masked[key] = hide_secrets_in_container(value)

This suggestion is source-traced, not executed; verify before adopting. Do not instead blanket-mask every dictionary with a secret-shaped name: structural namespaces such as token_id_capture contain nonsecret run settings that must remain inspectable.

Preservation / acceptance: Add proposed helper and writer regressions using openai_default_headers={"X-Auth": "credential-canary", "Authorization": "Bearer another-canary"}; both saved values must be ****, header names must survive, neither canary may occur in the file, and the input must remain unchanged. Also assert token_id_capture={"enabled": true, "sink": "pkg:Sink"} remains intact. Retain the existing tests asserting scalar/list secret masking and preservation of unresolved ${...} strings.

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.

Fixed in fae9b7c. hide_secrets_in_container now masks every value under any header-named map (header names are kept), which also covers vllm_model and switchyard_model. Added regressions with your canaries; token_id_capture stays intact.

Comment thread nemo_gym/cli/eval.py
OmegaConf.to_container(rollout_collection_config_dict)
)

write_resolved_config(global_config_dict, output_fpath)

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.

RISK — The sidecar is missing for gym eval run --no-serve

Failure / blast radius: This call covers only end-to-end collection. CLI dispatch routes gym eval run --no-serve --agent a --input tasks.jsonl --output run.jsonl to collect_rollouts, which never invokes the writer. That supported mode produces rollouts without the promised sibling config, leaving subsequent artifact consumers unable to recover its run configuration.

Correction: Keep this end-to-end call, and add the same write to collect_rollouts immediately after validating RolloutCollectionConfig, before collection starts:

from nemo_gym.resolved_config import write_resolved_config
# ... existing config loading and validation ...
write_resolved_config(global_config_dict, Path(config.output_jsonl_fpath))

Use the original global config, not a Pydantic dump, so interpolation strings remain unresolved. This is a source-traced suggestion, not an executed patch; verify before adopting. The invariant is that both eval run dispatch branches save the masked sidecar before collection, without making no-serve start servers.

Preservation / acceptance: Proposed regression: provide a minimal valid no-serve config and mock the async collector; inside its invocation assert the sibling YAML already exists, secrets are masked, and a nonsecret interpolation remains literal. Invoke twice with different attempt values and expect the second value, with no temporary files left. Retain the router assertions that default runs dispatch end-to-end and no-serve runs dispatch to standalone collection. Verify the existing end-to-end write still occurs before RunHelper.start, including custom-driver runs.

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.

Fixed in fae9b7c. collect_rollouts now writes the sidecar right after validating RolloutCollectionConfig, before collection starts; the end-to-end write is unchanged. Added a test that mocks the collector and checks the file exists inside the call, secrets are masked, interpolations stay literal, and a second attempt overwrites the first.

@prokotg

prokotg commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

/review

marta-sd
marta-sd previously approved these changes Oct 22, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

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.

SHIP — both prior findings are fixed; no eligible BLOCKER or RISK remains.

  • Header masking now masks custom authentication-header values while retaining header names and nonsecret structural settings. The regressions cover both prior credential canaries, input preservation, and token_id_capture preservation.
  • Standalone collection now writes the sidecar before collecting. The new regression checks masking, literal interpolations, and overwrite behavior. The end-to-end write remains before server startup.

Completed the follow-up comparison against the prior-reviewed head across all five changed files and directly affected configuration and CLI paths. No new escalation-eligible regression found. Static review only; tests were inspected, not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@prokotg

prokotg commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

@marcromeyn thanks for checking this against the head. I reproduced the URL case. I'd like to push back a bit on how to handle it, because I think some of it is the wrong layer.

The file keeps ${...} interpolations unresolved, so base_url: ${oc.env:MODEL_URL} never puts a credential in it. A leak only happens when someone writes the literal secret into a config or onto the command line, and then it's also in their YAML, shell history and process list, where masking the saved copy doesn't help.

I'll mask the password in scheme://user:pw@host. It's an unambiguous shape, and it covers the usual database, proxy and index URLs. That's only a precaution though: making sure secrets don't end up literal in a config is the user's responsibility, and the saved file isn't a guarantee.

I'd stop there for URLs. Query parameters would be guesses by name, and several real shapes can't be reached by masking at all: webhook URLs with the secret in the path (Slack, Discord), JDBC and ODBC-style strings (Password=...), and secrets inside command strings. I'd rather document the contract ("secrets go behind ${oc.env:...} or env.yaml, never literal") and maybe warn at save time as a follow-up.

On the other note, the env block comes from orchestration, which isn't saved here, so the masking mechanism doesn't apply to it. Orchestration env values already need an explicit lit:, host: or runtime: prefix.

On the EvalRDL reader not reading <stem>_resolved_config.yaml yet: Alex is aware, and the follow-up is on their side (his note on #4965).

A credential pasted into a URL under an ordinary key (base_url, a DSN, a
tracking URI) was written to the saved config and to the exporters in plain
text. The password in scheme://user:password@host is now masked and the rest
of the URL stays. This is only a precaution; the docs say secrets belong
behind ${oc.env:NAME} or env.yaml.

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

prokotg commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

/review

The detector reads scheme://user:password@host in the tests, the docstring and
the docs row as credentials. Reword the prose so it no longer carries the
pattern, and allowlist the example URLs in the tests.

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

prokotg commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7c4ebf5

@iguehring-nvidia iguehring-nvidia left a comment

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.

Approving on Marta's stead.

@prokotg
prokotg added this pull request to the merge queue Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

Merged via the queue into main with commit be126bf Oct 28, 2026
54 of 57 checks passed
@prokotg
prokotg deleted the prokotg/eval-run-resolved-config branch October 28, 2026 13:08
@athitten athitten mentioned this pull request Oct 28, 2026
7 tasks done
marcromeyn added a commit that referenced this pull request Nov 2, 2026
Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>
marcromeyn added a commit that referenced this pull request Nov 2, 2026
Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>
marcromeyn added a commit that referenced this pull request Nov 3, 2026
Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>
marcromeyn added a commit that referenced this pull request Nov 11, 2026
Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>
marcromeyn added a commit that referenced this pull request Nov 12, 2026
Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>
marcromeyn added a commit that referenced this pull request Nov 20, 2026
Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>
aiden200 pushed a commit to aiden200/Gym that referenced this pull request Nov 20, 2026
…ch (NVIDIA-NeMo#5134)

* feat(eval): record run provenance and the served models before dispatch

Writes <stem>_provenance.json beside the rollouts before the first rollout is
dispatched: Gym version and commit, model, dataset and sampling identifiers
(credentials dropped from URL-like values), fingerprints of the materialized
inputs, prompts and templates, the seed, and an Eval Factory config reference
when the caller passes one (efb_config_ref).

Each model server's backends are asked once what they serve (GET
<base_url>/models): the served id and, for vLLM, the loaded checkpoint (root),
so a claimed model can be checked against the served one. A hosted catalog is
narrowed to the configured model. A --no-serve collection takes the model
servers from the head server's config. A backend that does not answer, or
reports no root, is recorded as unknown with the reason; nothing is taken from
the configured names. The masked config itself is saved separately (NVIDIA-NeMo#4908), so
it is not copied here.

Signed-off-by: Marc Romeyn <[email protected]>

* fix(eval): keep provenance's model probes independent and its config walk out of credentials

A backend's malformed /models answer, an unresolved ${...} URL or a blank endpoint
file no longer discards the other servers' answers; a blank endpoint file falls
back to base_url, as the model server does. Backends are asked concurrently, so
unreachable ones cost about one timeout per run.

The config walk skips every mapping the saved config masks or whose name is a
credential (secrets, auth, headers) and environment maps (env, vllm_serve_env_vars).
The credential-name matcher moves from rollout recovery into secret_utils, beside a
shared url_without_credentials that also strips protocol-relative URLs and
passwords holding an unencoded @.

Signed-off-by: Marc Romeyn <[email protected]>

---------

Signed-off-by: Marc Romeyn <[email protected]>

This branch was previously deployed

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

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters 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.

5 participants